FEATURES OF THE ELLIOTT 502 COMPUTER

Programming the 502

The Computer Code

  1. Machine Representation of Instructions

    Reference Letter Used and Bit Allocation
    S M G F K N
    (1) (1) (3) (3) (2) (10)

    S = Program break digit - this digit is only used when using the machine in a multi-level mode.

    M = The mode bit

    G and F (Group and Function) together form the function code and are sometimes referred to by the single letter F.

    K = The modifier,
    K = 0 No modifier
    K = 1 B-register
    K = 2 Accumulator
    K = 3 Sequence Control Register (S.C.R.)

    N = The address bits.

    For convenience, the instruction format of the 502 program sheet is arranged in a slightly different sequence, illustrated on the specimen. The G and F bits are grouped under the single heading F and are entered in the first column; and the K-digit and the store mode bit occupy the last two columns.

    Instruction Code

2.1

Group 1 - Accumulator Functions

When the mode bit, M, is zero the address bits are used as a direct operand, e.g. the order 13 24 means, write the integer 24 into the accumulator, i.e. (i) a' = 24, where a indicates the previous content of the accumulator and a' its new content.
e.g. (ii) 10 24 - add 24 into the accumulator a' = a + 24
(iii) 11 24 - subtract 24 from the accumulator a' = a - 24
(iv) 12 24 - subtract accumulator from 24 a' = 24 - a'
(v) To clear the accumulator write 13 0
(vi) To count up write 10 1
(vii) To count down write 11 1

When the mode bit is a one - represented by a colon in the program sheet - the N bits are used to specify an address in the main store. The contents of the address specified are used in these functions. Thus if we indicate the contents of a main store address by the symbol (N) the meaning of each function is as follows.
F M A B S Comments
10 : N     a' = a + (N)
11 : N     a' = a - (N)
12 : N     a' = (N) - a
13 : N     a' = (N)
Thus if the main store address 65 holds +99 and the accumulator holds +2:
F M A B S Comments
10 : 65     a' = a + 99 = 101
11 : 65     a' = a - 99 = -97
12 : 65     a' = 99 - a = 97
13 : 65     a' = 99

When F > 3 the effect is to write the result into the main store location specified by N. Thus if (N)' represents the new contents of main store location N:
F M A B S Comments
14 : N     (N)' = (N) + a
15 : N     (N)' = a - (N)
16 : N     (N)' = (N) - a
17 : N     (N)' = a

Example A

To write a program to sum x numbers stored in the main store location 600 et seq. and to store the result in location 599.

(a) Method of straight addition in the accumulator

Suppose x = 10 and the program commences at location 50.
Address of
Instruction
F M A B S Comments
50 13 : 600     Write the first number to the accumulator
51 10 : 601     Add in the second number
52 10 : 602     Add in the third number
53 10 : 603     Add in the fourth number
54 10 : 604     Add in the fifth number
55 10 : 605     Add in the sixth number
56 10 : 606     Add in the seventh number
57 10 : 607     Add in the eighth number
58 10 : 608     Add in the ninth number
59 10 : 609     Add in the tenth number
60 17 : 599     Store total

2.2

The B-register and Group 0 Orders

Group 0 orders operate on the B-register; otherwise they are identical to the group 1 orders.

Using b to denote the original contents of the B-register and b' tp denote the new contents, then:
F M A B S Comments
00   N     b' = b + N
01   N     b' = b - N
02   N     b' = N - b
03   N     b' = N

When M = 1:
F M A B S Comments
00 : N     b' = b + (N)
01 : N     b' = b - (N)
02 : N     b' = (N) - b
03 : N     b' = (N)
04 : N     (N)' = (N) + b
05 : N     (N)' = b - (N)
06 : N     (N)' = (N) - b
07 : N     (N)' = b

Example B

We could solve the problem of example A by the same method using the B-register.
Address of
Instruction
F M A B S Comments
50 03 : 600     Write the first number to the B-register
51 00 : 601     Add in the second number
52 00 : 602     Add in the third number
53 00 : 603     Add in the fourth number
54 00 : 604     Add in the fifth number
55 00 : 605     Add in the sixth number
56 00 : 606     Add in the seventh number
57 00 : 607     Add in the eighth number
58 00 : 608     Add in the ninth number
59 00 : 609     Add in the tenth number
60 07 : 599     Store total
2.3

Groups 2 and 3 Orders

When M=0 these instructions deal with operations on the contents of fast store locations.

These two groups bear the same resemblance to each other as groups 0 and 1 orders, i.e. group 2 deals with b-line operations and group 3 deals with accumulator operations. Representing the original contents of a fast store location by n and the new contents by n', then
F M A B S Comments
20   N     b' = b + n
21   N     b' = b - n
22   N     b' = n - b
23   N     b' = n
24   N     n' = b + n
25   N     n' = b - n
26   N     n' = n - b
27   N     n' = b
F M A B S Comments
30   N     a' = a + n
31   N     a' = a - n
32   N     a' = n - a
33   N     a' = n
34   N     a' = a + n
35   N     a' = a - n
36   N     a' = n - a
37   N     a' = a

Example C

To form 2x - y + 3 and write the result in address 125 where x and y are held in fast store locations 123 and 124 respectively.
F M A B S Comments
33   123     a' = x
30   123     a' = 2x
31   124     a' = 2x - y
10   3     a' = 2x - y + 3
27   125     store result

or
F M A B S Comments
23   123     b' = x
20   123     b' = 2x
21   124     b' = 2x - y
00   3     b' = 2x - y + 3
27   125     store b

When M=1, the instructions deal with the contents of a main store location specified by N, e.g. if M=1 and fast store address 64 contains +85 and main store address 85 contains +700 the instruction 33 : 64 will write 700 in the accumulator.

Thus using (n) to indicate the contents of the main store location specified by N.
F M A B S Comments
20 : N     b' = b + (n)
21 : N     b' = b - (n)
22 : N     b' = (n) - b
23 : N     b' = (n)
24 : N     (n)' = (n) + b
25 : N     (n)' = b - (n)
26 : N     (n)' = (n) - b
27 : N     (n)' = b
F M A B S Comments
30 : N     a' = a + (n)
31 : N     a' = a - (n)
32 : N     a' = (n) - a
33 : N     a' = (n)
34 : N     (n)' = (n) + a
35 : N     (n)' = a - (n)
36 : N     (n)' = (n) - a
37 : N     (n)' = a

2.4

Other Simple Instructions

Count up in store:
54 N means n' = n + 1
54 : N means (N)' = (N) + 1
Count down in store:
55 N means n' = n - 1
55 : N means (N)' = (N) - 1
2.5

The Sequence Control Register and Jump Instructions

This register holds the address of the next instruction to be obeyed; under sequential operating conditions (e.g. example A) this register will be incremented by one as each instruction is obeyed. Before operating on example A The sequence control register will be 50; as instruction 50 is being obeyed the sequence control register will change to 51 - this process continues unless the sequence control register is changed by an instruction, i.e. a Jump instruction.

(a) 50 N means jump to N in the fast store, i.e. s' = N (f.s.)
50 : N means jump to N in the main store, i.e. s' = N (m.s.)
 
(b) 51 N means reduce s by N, i.e. s' = s - N (fast store)
51 : N means reduce s by N in main store, i.e. s' = s - N (main store)
It should be noted that since the sequence control register is normally incremented by one as each instruction is being obeyed, the effect of this instruction is to jump back N-1 places from the instruction being obeyed.

A stop instruction could therefore be:
  51 1
or 51 : 1 depending on the store being used.

Conditional Jumps
(a) Test Zero
46 [:] N means if a=0 set s' = N in fast store
46 : N means if a=0 set s'=N in main store
if a ≠ 0, the sequence control register operates in the normal manner, i.e. s' = s + 1
42 [:] N means if b=0 set s'=N in fast store
42 : N means if b=0 set s'=N in main store

This allows us to do example A by another method - by using a count of ten and counting down until this is zero.

Example D

Addition of 10 numbers by using a count:
Address of
Instruction
F M A B S Comments
50 13   10     ) Set count of 10 in location 59
51 17 : 59     )
52 13 : 600     ) Form sum of ten numbers in 599
53 14 : 599     )
54 55 : 59     Count down in count location
55 13 : 59     ) Test count location
56 46 : 56     ) if zero STOP
57 54 : 52     Modify instruction 52
58 50 : 52     Jump back
There are two weaknesses in the above program:
(a)
If there is anything but zero in location 599 this would be added into the total. This difficulty can be overcome by writing zero into 599 before obeying instruction 50. If possible the neccesary instructions would be written into locations 48 and 49 and the program commenced at instruction 48. Where this is not possible the two instructions would be written elsewhere in the store followed by a jump to location 50 - this is part of the program being obeyed before the above.
(b)
If it is required to operate on this program more than once, instruction 52 would have been modified after the first time of use. It is therefore found desirable to store somewhere in the program another copy of this instruction. This can be selected and written into location 52 either before the commencement of the program or before the stop instruction.

The program can be corrected as follows:
Address of
Instruction
F M A B S Comments
46 13   0     ) Clear location which holds total
47 17 : 599     )
48 13 : 60     ) Set instruction 52
49 17 : 52     )
and it would be neccesary to write into instruction 60:
60 13 : 600

Example E

Or it could be modified as follows:
Address of
Instruction
F M A B S Comments
48 13   0     ) Clear result location
49 17 : 599     )
50 13   10     ) Set count = 10
51 17 : 63     )
52 13 : 600     ) Form sum
53 14 : 599     )
54 55 : 63     Count down in count
55 13 : 63     ) Test count = zero
56 46 : 59     )
57 54 : 52     ) Otherwise modify instruction 52
58 50 : 52     )
59 13 : 62     ) Replace instruction 52
60 17 : 52     )
61 50 : 61     ) STOP
62 13 : 600     ) Used to replace instruction 52
63           ) Used for count location

Further Conditional Jumps

44 N means if a=0 or a positive set s' = N in fast store
44 : N means if a=0 or a positive set s' = N in main store
45 N means if a is negative set s' = N in fast store
45 : N means if a is negative set s' = N in main store
47 N means if the overflow indicator is set s' = N in fast store
47 : N means if the overflow indicator is set s' = N in main store
The overflow indicator is set whenever an attempt is made to exceed the maximum capacity of the accumulator or a store location.

Thus if: 524287 + N
or: -524287 - N (where N > 1) is attempted the overflow indicator is set.

The overflow indicator is cleared when it is examined by a 47 order. No other order will clear overflow; once overflow is set it remains set until examined.

As the computer regards everything as a fraction this should be expressed as follows: x ± y = z. Overflow if set when 1 ≤ z < -1.

Jumps affecting the B-register

(a) Count up and test B not zero
40 N means b' = b + 1. If now b=0 then s'=s+1
but if now b ≠ 0 then s'=N (fast store)
40 : N means b' = b + 1. If now b=0 then s'=s+1
but if now b ≠ 0 then s'=N (main store)
(b) Count down and test non-zero in B
41 N means b' = b - 1. If now b=0 then s'=s+1
but if now b ≠ 0 then s'=N (fast store)
41 : N means b' = b - 1. If now b=0 then s'=s+1
but if now b ≠ 0 then s'=N (main store)
(c) Subroutine Jumps
43 N means jump to N in the fast store (s' = N)
43 : N means jump to N in the main store (s' = N)

In addition to changing the contents of the sequence control register to N the previous contents of the sequence control register are store[d] in b.

Thus:
b' = s+1

When the subroutine jump is from a main store program in addition to s + 1 being stored in b the most significant bit of b is set to indicate that it is from a main store program.

Example G

A further method of programming the problem of Example A would be as follows:
Address of
Instruction
F M A B S Comments
50 13   0     ) Clear result location
51 17 : 599     )
52 13 : 60     )
53 17 : 55     ) Set instruction 55
54 03   10     Set b = 10
55 13 : 600     ) Form sum
56 14 : 599     )
57 54 : 55     Count up in instruction 55
58 41 : 55     b' = b - 1 If b≠0 jump to 55
59 50 : 59     STOP
60 13 : 600    

The Auxiliary Register

When squaring a number (or multiplying a number by another number of similar size) the number of digits may be doubled, e.g. (9) 2 =81 or (90) 2 =8100 or (.5) 2 =0.25 or (.01) 2 =.0001, etc.

It is therefore found useful to have a supplementary register into which these bits can be placed. This register is known as the auxiliary register and it is 20-its long. However the most significant bit of this register[s] is frequently ignored - so it can best be regarded as a 19-bit register. Since the computer regards all numbers as fractions the multiplication of two large fractions need not neccesarily affect the auxiliary register. Thus .25 x .5 = .125.
Accumulator 00100 00000 00000 00000
X
Store specified 01000 00000 00000 00000
=
Accumulator 00010 00000 00000 00000
R 00000 00000 00000 00000

Integers are regarded by the computer as fractions scaled down by 2 -19 :

3 x 2 -19 x 3 x 2 -19 = 9 x 2 -38

or:
Accumulator 00000 00000 00000 00011
X
Store specified 00000 00000 00000 00011
=
Accumulator 00000 00000 00000 00000
R 00000 00000 00000 01001

The order that affects a register in this manner is the 64 order, i.e. double length multiplication. Thus:
64 N means ar' = a x n
64 : N means ar' = a x (N)

There is also a single-length multiplication order (65 order) - this could have been used for the first example above. This produces a rounded multiplication; the auxiliary register being cleared by the instruction. Thus:
65 N means a' = a x n and r' = 0
65 : N means a' = a x (N) and r' = 0
Just as it is desirable to have a double length product from a multiplication operation, it is also found desirable to have a double length dividend for a division operation. There are two division orders.

(1) Division with remainder (66).
In this operation the quotient appears in R and the remainder in a. Thus:
66 N means r' = ar/n and a' = ar - ar'
66 : N means r' = ar/(N) and a' = ar - (n)r'
If overflow occurs in this instruction both a and r are meaningless.
(2) Rounded Division (67)
67 N means a' = ar / n
67 : N means a' = ar/(N)

Occasionally it is found neccesary to read from or write into the auxiliary register.
(a) Transfers between store and auxiliary register.
53 N means r' = n
53 : N means r'= (N)
57 N means n' = r
57 : N means (N)' = r
(b) Shift functions. Arithmetic double-length shift (62).

In this function the N digits are used to specify the number of places to be shifted. (The most significant bit of R being regarded as non-existent). Thus 62 19 would move the auxiliary register into the accumulator.

The effect of this function is to multiply the double-length ar by 2 N . Thus 62 1 means double ar.

Right shifts: Halving operations are achieved by using this order and specifying -N in the N digits. (alternatively it is possible to specify 1024-N for right shifts). Thus 62 -19 or 62 1005 would move the accumulator into the auxiliary register.

This function is an arithmetic shift thus the correct sign is maintained unless overflow occurs.

e.g. 62 -4 would have the following effect
a = 1.1011 00111 00011 11000 r = 01111 10000 01111 11000
a'= 1.1111 10110 01110 00111 r'= 01000 11111 00000 11111

Other Functions

Single length arithmetic shift (61) has the same effect as a 62 order but it does not affect the auxiliary register.

Logical shift (60) is a single length shift of the contents of the accumulator, without sign regeneration. Zero's are inserted where digits are missing.

If the order illustrated previously had been 60 -4 the result would have been:
a'= 00001 10110 01110 00111

Collating Instructions

These orders collate the contents of the accumulator with the contents of the store specified - this is a logical operation which compares each bit of one word with the corresponding bit of the other word. If a digit is present in both, a digit is placed in the result word. Thus:
a = 01000 10001 11001 01111
n = 11111 00111 00000 00101
a & n = 01000 00001 00000 00101

52 N means a' = a & n
52 : N means a' = a & (N)
56 N means n' = a & n
56 : N means (N)' = a & (N)

Square Root Function (63)

This order finds the square root of the sum of the accumulator and the store location specified by N. Thus:
63 N means a' = (a + n) ½
63 : N means a' = (a + (N)) ½

Instruction Modification

The K-bits of an instruction can be used to indicate a register which will be used to modify the N-bits of an instruction; the contents of the register specified being added to the N-bits before the instruction is obeyed.
NOTE: It is only the N-digits which are modified - overflow from the 10 N-digits does not cause instruction modification as the operation of summing the N-digits and the modifier is performed in another register within the machine.

B-register Modification

When K = 1 the b-line is used as the modifier. This is specified on the program sheet by an oblique followed by the K-digits, thus 13 : N /1 means a' = ((N) + b).

Thus if b = 10 and the instruction 13 : 500 /1 is used this will set the contents of the main store address 510 into the accumulator.

Example H

Using a modifier to sum the numbers of example A.
Address of
Instruction
F M A B S Comments
50 13   0     ) Clear result location
51 17 : 599     )
52 03   10      
53 13 : 599 /1    
54 14 : 599      
55 41 : 53      
56 50 : 56      

All types of instructions can be modified. Thus if b = 10 and fast store location 35 holds +84:
13 5 /1 means a' = 15
33 25 /1 means a' = contents of fast store location 35 = 84
33 : 25 /1 means a' = contents of main store location 84
62 3 /1 means ar' = ar x 2 13

etc.

Accumulator modification

When k = 2 (indicated by /2) the accumulator is used as a modifier in the same manner as above.

If instruction 53 above had been 13 : 599 /2 the effect on this occasion would be to write the contents of 599 into the accumulator, and since this is zero the only effect of the program above would be to count zero into 599.

Note that it is possible to use the previous contents of the accumulator to modify an accumulator instruction; this also applies to b-line [modificatio] modification. Thus 13 10 /2 and 10 10 will have the same effect.

Example I

To sort 16 numbers into ascending order the first number being stored in fast store location 600. The program will commence at main store location 200.
Address of
Instruction
F M A B S Comments
200 03   15     Set b' = 15
201 13   0     ) set modifier = 0
202 17 : 216     )
203 07 : 217     store b
204 00 : 216     b' = b + modifier
205 33   599 /1   ) compare contents of two
206 31   600 [/1]   ) consecutive locations
207 45 : 210      
208 34   600 /1   ) exchange the values in the
209 36   599 /1   ) [in the] two locations
210 01 : 216     Subtract modifier
211 41 : 204     Count down in b and jump if not
zero
212 03 : 217     Select the b value stored in
location 217 above
213 54 : 216     Add 1 to modifier
214 41 : 203     Count down in b and if b ≠ 0
jump back
215 50 : 215     STOP
216     +0     Modifier
217     +0     b-line store at beginning of each
loop

The above program compares the contents of each loaction with the next, gradually moving the smallest to the beginning. It then takes the remaining 15 numbers and compares them, moving the smallest of these to the beginning, and then compares the remaining 14 numbers moving the smallest of them to the beginning. It continues in a similar manner until all the numbers are in their correct order.

It is possible t write negative numbers to the acuumulator or b-line directly.
i.e. 11 5 /2 will subtract a + 5 from a therefore a = -5
01 5 /1 will subtract b + 5 from b therefore b = -5

Sequence Control Modification

The sequence control register can also be used as a modifier. i.e. when K = 3 (/3 in the order code), this takes the prese[n]t contents of the sequence control register and adds these to the address digits before obeying the instruction.

NOTE:

The sequence control register will have been incremented by one before this modification takes place. Therefore 13 : 0 /3 would write the next word into the accumulator. Instruction 204 of example I could have been 00 : 11 /3 and instruction 207 could have been 45 : 2 /3.

Indirect Addressing Facilities

The sequence control register can be used as a modifier when attempting to write a subroutine for placing anywhere in the store.

Example J

Example E could be changed to a general routine for any store location as below.
Address [of]
Instruction
F M A B S [Comments]
x+0 56 : 7 /3    
+1 50 : 6 /3    
+2 13   0     ) Clear results location
+3 17 : 599     )
+4 13   10     ) Set modifier
+5 17 : 10 /3   )
+6 13 : 8 /3   ) Set instruction in x + 8
+7 17 : 1 /3   )
+8 13 : 600     ) Form sum
+9 14 : 599     )
+10 55 : 5 /3   ) Count down in modifier
+11 13 : 4 /3   )
+12 46 : 1 /3   If zero jump to end
+13 51 : 14     Jump back
+14 51 : 1     [STOP]
+15 13 : 600      
+16     +0     Modifier

Note that entry to this program is made at instruction x + 2. This is because, when using the sequence control register as a modifier, only locations following the present location can be addressed by this method, And, since in this program it is neccesary to modify an instruction after having obeyed that instruction, it is neccesary to jump to a section of program which is deliberately set before the beginning of the program proper.

Example K

Example H would therefore be written:
Address [of]
Instruction
F M A B S
x+0 13   0    
+1 17 : 599    
+2 03   0    
+3 13 : 599 /1  
+4 14 : 599    
+5 41 : 1 /3  
+6 51 : 1    
+7 51 : 5    

Size of Store

As was mentioned earlier the fast store is 1,024 words long and therefore every location from 0-1.023 can be addressed directly. This is not so in the case of the main store where there are 16.384 locations: every location > 1,023 must therefore be accessed indirectly.

(1) Use of b-line or Accumulator as Modifier
Provided that the b-line or the accumulator is not required to hold a modifier or count, the b-line or accumulator could be used to access otherwise inaccessible locations.

i.e. If b = 2048, then 13 : 74 /1 would write the contents of main store location 2122 into the accumulator.

Similarly, if a = 2048, then 03 : 74 /1[2] would write the contents of main store location 2122 into the b-register.

(2) Use of Sequence Control Register Modification
This is similar to the above; however, it has the added limitation that:
(a) No address prior to the current address can be accessed by this method.
(b) Only addresses within the next 1,024 words can be accessed with this method.
(3) Use of Group 2 and 3 Functions
This is limited unless it is found desirable to access the same location n times or to change the fast store address holding the main store address, i.e. 33 : N /1 will access the contents of the main store address specified by N + b. It will not access the contents of main store address n + b.

Peripheral Instructions Group 7

The only group 7 instructions that will be considered at this stage are:
70 1 - add the characters under the tape reader into the accumulator
73 1 - write the character under the tape reader into the accumulator
77 1 - punch the l.s. 5 bits of accumulator on paper tape.

Back - Contents - Next
Page created by Bill Purvis, last update 22nd November 2003
Contact me at: mailto:bill 'at' beeb.net