Indian Assembler

One of the most basic features of the assembler language provided with the simulator is the ability to include arbitrary amounts of white space, tabs and newline characters throughout the code without altering its meaning. This allows one to write programs in a much more readable and well-structured style. For example, consider the following equivalent code fragments :

    T48KP1FGKP65535FA@R1024F

and

    T 48 K
    P 1 F
    G K
    P 65535 F
    A @
    R 1024 F

The style of code that one can produce using Indian Assembler comes closer to the way programs were written for the real EDSAC. The early programmers wrote programs with the help of special paper ("coding sheets") which was pre-printed with line numbers, a column for comments, and other simple aids to make program development and debugging easier and more efficient.

However, one still had to keep track of where individual instructions would end up in memory (which obviously changes as one modifies the code) in order to reference them correctly and many seemingly trivial tasks such as initialising parts of memory to certain pre-defined constants required an in-depth knowledge of the way EDSAC operated at the bit-level.

The following extensions of Indian Assembler use features one takes for granted in modern day programming languages, and makes them available for writing programs which translate into 100% compatible EDSAC code. Further illustration of the way Indian Assembler can be used in practice is provided in the form of the new example programs which come with the simulator, as all of these were written with the aid of Indian Assembler.

Comments

The way comments are handled in Indian Assembler will seem natural to anybody used to writing programs in modern languages such as C++ and Java. Single-line comments start with the character pair "//" and indicate that all characters until the end of the line are to be ignored by the assembler. Comments may also span several lines, in which case one can use the character pairs "/*" and "*/" to indicate the beginning and the end of the comment respectively.

Comments are an essential tool for making programs easier to understand and maintain and are of particular use for rather more cryptic languages such as EDSAC code.

Labels

Symbolic labels make it easier to jump to a particular line of code in a program, as one can use meaningful identifiers for them and is free of the hassle of keeping track of the precise memory location a particular instruction will occupy. A label is set-up to refer to the line of code (i.e. the address of the next instruction when the code is loaded into memory) immediately following it by using the syntax

:<label>:

where label is a unique identifier consisting of up to 256 alphanumeric characters (i.e. letters and decimal digits).

It can then be used as an integer value representing the memory address of the instruction it was set-up for and may therefore be used as an integer constant, which is precisely what it is translated into before the code is fed to the simulator.

It should be noted that the label binding is hence done before the program is executed, and so any subsequent changes to the location of the instruction will have no effect on the value of the label.

In order to use a label, one simply types its name, as in the following example :

    :loop:
    // code for the loop body
    ...
    E loop F // goto loop if accumulator value >= 0

The simulator will display an error message if labels are used incorrectly, e.g. if one refers to a non-existent label, redefines an existing label, or uses non-alphanumeric characters as part of the identifier.

Constants

One of the main difficulties in programming the original EDSAC was inputing constants. The only way to achieve this was to input a pseudo instruction that would be represented as a bit pattern which is equivalent to the desired value. For example, the number 0.62510 would be input as the pseudo instruction J F which was represented by the same bit pattern. As a result of this, certain constants could not be represented by a single pseudo instruction and had to be produced explicitly by a sequence of instructions.

All of this made programs harder to write and read and also resulted in another source of potential errors. In order to simplify the use of numeric constants, Indian assembler provides a way of specifying constant values which may then be referred to by labels are described above. The syntax used is

CONST(<value>,<length>)

Where value is a decimal number and length is either F or D, which indicates whether the constant is to occupy an entire word or only a half word respectively.

One can then refer to the constant (which is after all just a particular bit pattern in memory) by means of a label, as in the following example:

    // code using constants :
    A i F // add 1 to accumulator
    S j F // subtract 2
    A three F // add 3
    // Constants :
    :i:CONST(1,F)
    :j:CONST(2,F)
    :three:CONST(3,F)

Like any other value in memory, constants may be modified at any time and could therefore also serve as variables initialised to a particular value.

As before, errors arising from impossible or incorrectly specified constant expressions will be reported to the user as warnings displayed at the bottom of the editor window containing the erroneous program.