Chapter 5: Input Routines

This chapter discusses hte methods by which programmes are placed in the store of the computer, and ends with an example of a complete programme.

Although it is possible, by manipulating the buttons on the keyboard, to place a few words in the store of the computer by hand, the process is slow and liable to error. The only practical means by which a new program can be stored is to make the computer obey a set of instructions which cause it to read characters from the input tape, build the 5-digit groups obtained therefrom into words, and place these words in its own store. Such a set of instructions is permanently "built-in" in locations 0 to 3: it is referred to as "The Initial Instructions", and can be quickly brought into use whenever it is desired to re-programme the computer.

This set satisfies the main requirement of a fixed programme, namely that it should not take up much storage space. But its process of word-assembly is neccesarily very rudimentary, and to prepare the type of programme tapes which can be read by it is not very easy. For this reason, a second input routine, the Translation Input Routine (T.I.) has been written, by means of which the computer can be caused to read and translate programme tapes of a type which are easy to prepare.

5.1 The Initial Instructions

5.1.1 Method of storage

The Initial Instructions are permanently held in locations 0 to 3 and cannot be overwritten. If, for example, the instruction 20 2 is included in a programme, it will be interpreted as "do nothing".

Locations 0 to 3 differ from other locations in one othre respect: namely that if an attempt is made to use them as sources of numbers, they appear to be sources of zero. Thus the instruction 30 3 is "clear the accumulator" whilst 02 0 is "replace C(A) by 2-38." This last is of practical value at times.

The Initial Instructions use location 4 as a count location: programmes may therefore be placed in locations from 5 upwards.

5.2.1 Binary-coded Programme Tapes

The initial Instructions are designed to read what is termed a binary-coded programme tape. On such a tape each word is represented by a group of eight characters. Thus 24 18 / 31 21 is represented by the eight characters
          10101 00000 00000 10010 10110 01000 00000 10101,
in which the first digit is a one, and the remainder correspond to the binary form of the word itself.

The words of the programme are preceded by the eight-character group corresponding to the word

          00    0   00  (N-4)
where N is the address of the location in which the first word of the programme is to go.

The way in which the Initial Instructions read such a tape is described in the Elliott 803 Library of Programmes.

The Translation Input Routine

Programmes are usually written in the style shown in this guide, that is to say, in an octal/decimal code, and each programme is usually composed of a number of blocks. The T.I. has been designed to read programme tapes on which the instructions are punched in a form which is directly derived from the octal/decimal written form, the figures being interspersed with control symbols to indicate which number is what. The T.I. can also assemble one programme from several separate blocks of instructions: furthermore, it can decipher programmes which have been written in the relatively-addressed form described below.

The T.I. is not held permanently in the store. Whenever it is desired to re-programme the computer from a tape punched in the "T.I Code", it is first necessary to place the T.I. in the store by means of the Initial Instructions. For this purpose, a binary-coded programme tape of the Translation Input Routine is kept by each 803 computer. The process may sound rather complex, but in practice it takes only a few seconds.

Relative Addresses

Until the blocks of a programme have been written, their lengths are not known, and it is therefore not practicable to allocate storage space to them. But it is not possible to complete the writing of each block unless there is some means of specifying the address of any word in that or any other block: one cannot complete the instruction 40 N until one knows what N is. This apparent deadlock is resolved by a technique known as relative addressing.

Before any instructions are written, a list is made of the blocks which are needed. The blocks are numbered from 1 upwards. For example:

  1. Main Programme.
  2. Constants and working space used by 1.
  3. Input subroutine. (To read in data).
  4. Output subroutine. (To punch results).

There is no limit to the number of subroutines used, nor need the main programme be all in one block: complex calculations are usually programmed in several blocks.

Each block which does not comprise a subroutine chosen from the Elliott 803 Library of Programmes is then written separately, each address being written as though the block started in location "0,".  A comma is placed after each such relative address, thus:

          20    6,    represents "Write in location 6 of this block".
Cross-references to locations in other blocks are written thus:
          22    7,2   represents "Count in location 7, of block 2".
Absolute addresses and numerical details (N's) are indicated in the normal way, without commas, thus:
          04  128     represents "Add C(128) to C(A)".

          74   29     represents "Punch cr".

Example 19

The following is the square root programme of Example 12, re-written as a relatively-addressed subroutine, with standard entry arrangements.

          Address   Instructions
                  F1   N1  B  F2   N2
          0                             Link.
          1       41   1,     42   7,   Enter with x in accumulator and A.R. clear
          2       20   9,     30   8,
          3       20  10,     30   9,
          4       56  10,     04  10,
          5       51   1      15  10,
          6       45   3,     07  10,
          7       00   0,  /  40   1    Exit
          8       +274 877 906 943      1 - 2-38
          9                             x
         10                             yn

The directory

When the programme has been completed, storage space is allocated to the blocks, and a directory is written at the head of the whole programme. This consists of a list of the block addresses, the absolute addresses of locations 0, of each block. A copy of this goes on the proramme tape, and indicates to the T.I. where it is to place the various blocks, and enables it to decipher the relative addresses.

The T.I. occupies and uses locations 5 to (176 + B) where B is the number of blocks in the programme which it is reading. The Elliott 803 Library of Programmes contains a number of checking routines by means of which any mistakes in a new programme can be more easily diagnosed. These are customarily placed in locations at the "top" end of the store. It is therefore best to place programmes between locations 192 and 3800 unless the need arises to use more space than this.

Numerical data

The T.I can read constants as well as instructions: these should be written on a programme sheet as shown below,
  1. Integers
              +453              represents       453 x 2-38
              -9                represents       9 x 2-38
    
  2. Fractions
              +.5               represents        1/2
              -.625             represents       -5/8
    
  3. Pseudo-Instructions
    Best shown by example.
    Since 00 3 / 00 0
    is stored as 000000000000000001110000000000000000000
    this pseudo-instruction pair is a convenient way of writing 7 x 2-19.
  4. Constants to a preset scale

    When many constants, all to some scale which is not provided for above, are needed in a programme, it is possible to "adjust" the T.T. in such a way that it divides any constant which contains a decimal point by a preset scaling factor before storing it. Thus to use scale x 10-5 the scaling factor is preset to 100,000 (one hundred thousand). When this facility is in use, facility (ii) above is lost.

    Such constants should be preceded by + or - and must contain a decimal point, thus:

                               -500.
                               +17.23
                               -.006
    

    Further details of this, and all other facilities offered by the T.I. are given in the Elliott 803 Library of Programmes.

5.3 Example 20 A Complete Programme

Problem To calculate the arithmetic mean X and standard deviation SD for each of several set of numbers Xi. Each set has a reference number M and contains N items. Each item is a positive decimal fraction: Sum i < 1 for any set.

Formulae

X = 1/N Σ Xi ; SD = {1/N Σ Xi - X }

Formats

Output
The results to be printed in four columns without headings. The columns to represent:
                       M    N    Mean    SD
Input
The data tape to be punched with easch set represented by the integer M, then the integer N, and then each of the fractions Xi of the set.

Note: These formats must be decided before programming can being in earnest. The problem itself usually suggests a suitable output format: unheaded columns are being accepted here to simplify the example. The general arrangement of the input format can be determined by answering the question ‘What numbers would I need, and in which sequence, if I had to do the calculation myself?’ The detailed arrangement for each number must be in accordance with the specification(s) of the input subroutine(s) to be used: it is assumed here that this is so.

Output is described in terms of a printed page as the computer's output tape is always interpreted by a teleprinter.

Blocks

  1. Main programme.
  2. Working space for 1.
  3. Input subroutine.
  4. Print subroutine.
  5. Square root subroutine.

Subroutines

For Block 3: General Number Input Subroutine, 803 T5
Entry: Standard
Store: 55 locations
Function: Reads one integer or fraction.
A.R.: Clear on exit
For Block 4: General Number Print Subroutine 803 T6
Entry: Standard entry with parameter word in the location after that
which holds the entry instructions 73... 40... .
Exit from the subroutine is to the location after that
holding the parameter word.
Parameters:
To Print On New Line On Same Line
Fraction 40 0 / 00 0 40 0 30 0
Integer 20 0 / 00 0 20 0 30 0
Store: 131 locations.
Function: Prints C(A), regarded as a fraction or as an integer,
on the same line as the last number printed or on a new
line, according to the parameter used.
A.R.: Clear on exit.
For Block 5 Square Root Subroutine shown as Example 19 of this guide.
Entry: Standard
Store: 11 locations.
Function: Forms square root of C(A).
A.R.: Must be clear on entry: clear on exit.
Main Programme and Block 2
When the above details have been attended to, the main programme can be written. This is quite straightforward, and is given overleaf. Locations in Block 2 are allocated as the need arises, care being taken to see that no new location is taken up unless all those so far allocated are still in use. Use is made of exchange functions whenever possible. Block 2
          0,    Holds Sum Xi.
          1,    Holds Sum Xi².
          2,    Holds N x 2-38 and later 1/N.
          3,    Count location, initially holds -N x 2-38.
                Later use to hold X_bar and then X_bar².
          4,    Holds Xi.
    
Block 1
        Address          Instructions                Notes
                F1     N1     B     F2     N2
        0       73     0,3          40    1,3   Read M
        1       73     0,4          40    1,4   Print M
        2       20     0      /     00    0     Parameter for integer on new line
        3       73     0,3          40    1,3   Read N
        4       26     0,2          26    1,2   Clear Sum Xi and Sum Xi²
        5       20     2,2          21    3,2   N to 2,2: -N to 3,2
        6       73     0,3          40    1,3   read Xi and clear A.R.
        7       24     0,2          20    4,2   add to Sum Xi
        8       53     4,2          24    1,2   Xi² added to Sum Xi²
        9       02     3,2          42   11,    count and test for end of set
       10       20     3,2          40    6,    set not ended, read next item
       11       02     0            56    2,2   2-38 ÷ N x 2-38 = 1/N, as fraction.
       12       10     2,2                      1/N to 2,2 and N to Acc.
       13       73     0,4          40    1,4   Print N
       14       20     0            30    0     Parameter for integer on same line
       15       30     2,2          53    0,2   Form X_bar
       16       20     3,2          53    3,2   Form X_bar²
       17       10     3,2          00    0     X_bar² to 3,2 and X_bar to Acc
       18       73     0,4          40    1,4   Print X_bar
       19       40     0            30    0     Parameter for fraction on same line
       20       30     1,2          53    2,2   form 1/N Sum Xi² and clear A.R.
       21       05     3,2          00    0     Form SD²
       22       73     0,5          40    1,5   Form SD
       23       73     0,4          40    1,4   Print SD
       24       40     0            30    0     Parameter for fraction on same line
       25       40     0,           00    0     return to deal with next set.
    
The Complete Programme
Previous Chapter Contents Next Chapter