# Chapter 3: The Instruction Code

The 64 possible functions are now described. The full instruction code is given in Appendix 3.

Functions in Groups 0 to 3 are termed Basic Functions, and these together with the Transfer Functions of Group 4, have in common the fact that the N digits always specify the address of a location, although in some cases (functions 00, 01 and 06), the content of that location does not enter into the operation.

The uses of the N digits in the functions of Groups 5 to 7 are given in the appropriate sections below. The times taken to perform all functions are given in Appendix 3.

## 3.1 Group 0

Note: None of the functions in this group affects the content of any store location.

Function 00 Do Nothing

The usefullness of this instruction will be appreciated when the use of the B digit is understood.

Function 01 Negate

The content of the accumulator is negated.

Function 02 Replace and Count

The existing C(A) is deleted and replaced by a number equivalent to C(N) + 2-38.

Function 03 Collate

A new word is formed which has a 1 in each position in which there are 1's in both C(A) and C(N), and 0's elsewhere. C(A) is then deleted and replaced by this new word.

### Example 5

The collate function may be used when it is desired to extract the wanted number from a location in which two numbers have been packed. Returning to the case of Example 4 in section 2.3.4, if the word containing the two numbers is in location 300 and the integer 524287 is stored in location 276, the following instructions suffice to get the right-hand number into the accumulator on its own:

 Address Instructions F1 N1 B F2 N2 740 30 300 03 276
For the effect is to collate
0 0000 0000 0000 1111 1110 0000 0000 0101 0101 01
with the collating constant
0 0000 0000 0000 0000 0001 1111 1111 1111 1111 11
and thus obtain
0 0000 0000 0000 0000 0000 0000 0000 0101 0101 01

C(N) is added to C(A), which is deleted and replaced by the sum.

Function 05 Subtract

C(N) is subtracted from C(A), which is deleted and replaced by the difference.

Function 06 Clear

C(A) is deleted and replaced by zero.

C(A) is subtracted from C(N), C(A) is deleted and replaced by the difference.

The result is the negative of that produced by function 05.

## 3.2 Groups 1 to 3

In Groups 1 to 3, the operations performed are similar to those described above, but whereas in Group 0 the result is placed in the accumulator and the store remains unaffected, the arrangements in Groups 1 to 3 vary. Appendix 3 lists these, and it can be appreciated that the availablity of so wide a choice of functions enables very compact programmes to be written for 803.

To "replace" is to delete C(A) and substitute a copy of C(N), to "write" is to delete C(N) and substitute a copy of C(A), and to "exchange" is to do both at once.

## 3.3 Group 4 - Transfer Instructions

Transfer or, as they are somtimes called, "jump" instructions are inserted in a programme wherever it is desired that the computer should obey instructions in a sequence different from that in which they have been stored. Some examples of this have already been given in 1.4, and others are given below.

Function 40 Transfer, unconditionally, to first instruction

This causes the computer to break normal sequence, carry out the first instruction in location N, and continue then in normal sequence from that new point until a further transfer instruction comes to be obeyed.

### Example 6

When the computer has completed a calculation, it must be stopped. But the speed of the computer is too great for a human operator to stop it at the right instant. An instruction to stop must therefore be written into the programme. There is no specific instruction "stop" in the code, so recourse is made to a "dynamic stop".

Suppose that the last two instructions of a calculation are in location 843. Then in 844 we may place, as first instruction, "40 844".

It is left to the reader to work out what happens.

There is a loudspeaker on the keyboard, which emits a distinctive high-pitched noise when the speaker comes to a dynamic stop.

Function 41 Transfer to the first instruction if (and only if) C(A) is negative

If the sign digit in the accumulator is a 1 (content negative) when this instruction is obeyed, the action is as for function 40. But if the sign digit is a 0 (content zero or positive), the instruction is interpreted as "do nothing".

### Example 7

Suppose that, in some iterative process, certain steps of a calculation need to be performed 6 times. This could be organised as in the programme below in which the entry point is the first instruction in location 10.
 Address Instructions F1 N1 B F2 N2 9 -5 This is the way in which the number -5 x 2-38 is expressed on a programme sheet 10 30 9 20 8 place -5 in location 8 11 ) ) The instructions to be obeyed 6 times 15 ) 16 32 8 41 11 Increase the content of location 8 by 1, and repeat the set of instructions if neccesary 17 Next part of programme.

When the instruction 32 8 is obeyed for the first time, the number which comes into the accumulator is -5. On the second occasion it is -4, then -3, -2, -1 and finally after the sixth iteration, 0.

In the above programme "a count is kept in location 8" or "location 8 is used as a count location". The number placed in the count location at the start of such a process is called a "count constant". The action of placing a count constant in a count location is termed "setting a count".

Function 42 Transfer to first instruction if (and only if) C(A) is zero.

If the content of the accumulator is zero when the computer obeys this instruction, the action is as for function 40. But if the content is not zero, the instruction is interpreted as "do nothing".

Function 43 Transfer to first instruction if (and only if) the overflow indicator is set, and clear the overflow indicator.

The overflow indicator is tested, and if it is found to be in the set condition, the action is for Function 40, coupled with the fact that the overflow indicator is cleared. But if the overflow indicator is found to be in the clear condition, the instruction has the same effect as "do nothing".

Appendix 4 gives a complete list of all the functions which can cause overflow.

If it is desired to use the overflow indicator to test whether some function or group of functions has caused overflow, it is neccesary to ensure that the overflow indicator is clear before these take place. This may require the insertion of an instruction whose only effect is "clear overflow indicator (if set)". The instruction 43 (N+1) placed in the second position of location N has this effect.

Functions 44, 45, 46 and 47

These functions are identical in operation to 40, 41, 42 and 43, except that where a transfer takes place it is to the second instruction in the specified location instead of the first.

Any function of Group 4, except for 43 and 47, may be used to produce a dynamic stop. In the case of functions 41, 42, 45 and 46 the stop is conditional.

### 3.3.1 Exercises

1. Write the two sets of instructions which cause the computer to compare C(416) and C(417) and then clear 418 if and only if they are
1. unequal
2. equal
1. Why can neither function 43 nor 47 be used to produce a dynamic stop.
2. Write the instructions which cause the computer to add C(735) and C(736) and then stop if the sum is in excess of capacity, but go on to the next part of the program otherwise, with the sum in the accumulator.
2. C(24) and C(25) are two positive numbers. Write a program which places a number equal to the greater in location 26, using any of the functions you require from Groups 0 to 5. (Target: 5 instructions).

## 3.4 Group 5 - Multiplication, Division and Shift Functions

When two fractions of equal length (e.g. +.23 and -.47) are multiplied, the answer is, in general, twice as long as either (-.1081). Similarly, if two computer words each of 38 fractional digits and one sign digit are multiplied, the full product has 76 fractional digits and one sign digit. Provision is made in 803 to "extend" the accumulator in this and certain other cases to accomodate one such double-length number. This is held in the such a way that the sign digit and the next 38 digits are in the accumulator itself, while the remaining 38 digits fill the extension, which is termed the Auxiliary Register (A.R.)

Group 5 functions are the only ones that affect the A.R.; none of them affects the store.

In the case of functions 52, 53 and 56, (multiply and divide), the N digits specify the address of a location in the store. In function 57 (read A.R.), The N digits are not used. In functions 50, 51, 54 and 55 (shifts), the seven right-hand N digits specify a number N; this N has therefore a range from 0 to 127 inclusive, and if N = 145 say, then N = 17.

Function 50 Halve the double-length number N times

The digits of the double length number are shifted N places to the right, the N right-hand digits being lost. If the original number is positive or zero, N zeros are inserted at the left-hand end; if it is negative N ones are inserted.

Thus the sign of the number is maintained, and the effect is a true division by 2N, subject to any error occuring through loss of right-hand digits.

### Example 3

If the double length numbers 1/2 and -1/2

 i.e.: 0 1000 0000................................0000 0000 and 1 1000 0000................................0000 0000 and halved 4 times, the results are 0 0000 1000................................0000 0000 and 1 1111 1000................................0000 0000 which are 1/32 and -1/32 respectively.

### Exercise 8

Verify that if the double-length number 10 x 2-76 be halved twice the result is 2 x 2-76.

Function 51 Shift C(A) right N places, Clear A.R.

The digits in the accumulator are shifted N places to the right, the N right-hand digits being lost, and N zeros are inserted at the left. The A.R. has no part in this process: it is cleared as a separate operation.

### Exercise 9

Verify the following:

(a) If the number in the accumulator is -3/4, and the function 51 1 be performed, the result is +5/8.

(b) If the double-length number is 27 x 2-39, and the function 51 2 be performed, the resulting double-length number is 3 x 2-38.
(27 = 11011).

Function 52 Multiply with double-length product

The existing C(A) is multiplied by C(N). C(A) and the existing content of the A.R. (which is not used in the function) are deleted and replaced by the double-length product.

Function 53 Multiply with single-length rounded product. Clear A.R.

The existing C(A) is multiplied by C(N). C(A) is deleted and replaced by the left-hand 39 digits of the product, rounded off to be as nearly correct as possible. The A.R., whose original content is not used in the function is cleared.

### Example 9

If 9 x 2-20 and 3 x 2-20 are multiplied by function 52, the result is 27 x 2-40, held as a double length number. 27 in binary is 11011, so the result appears thus:
Accumulator A.R.
0..................0001 10 11 0000..................0000

But if function 53 be used, the process is, in detail as follows:

1. the double-length product is formed.
2. the quantity 2-39 is artificially added.
3. the left-hand 39 digits of the result are placed in the accumulator, the other 38 digits are lost, and the A.R. is cleared.

The arithmetic may be represented thus:

Accumulator A.R.
(a) 0....................0001 10 11 0000.................0000
+ 1
(b) 0....................0001 11 01 0000.................0000
(c) 0....................0001 11 00 0000.................0000
which is 7 x 2-38, the correct approximation

Function 54 Double the double-length number N times

In this function, the digits of the double-length number are moved N places to the left, N zeros are inserted at the right-hand end, and the N left-hand digits are lost. Unless overflow takes place the effect is multiplication by 2N.

If N >= 38, the A.R. is clear after this function.

Function 55 Double C(A) N times. Clear A.R.

The digits in the accumulator are moved N places to the left, N zeros are inserted at the right-hand end, and the N left-hand digits are lost. Unless overflow occurs, the effect is multiplication by 2N.

The A.R. has no part in this process; it is cleared as a separate action.

Function 56 Divide. Clear A.R.

Division is the inverse of multiplication, in that as a x b = ab, so ab / b = a. Just as it is useful to have a double length "ab" (product) in multiplication, so it is useful to have a double length "ab" (numerator, or dividend) in division.

Function 56 therefore consists of the division of the double-length number by C(N). C(A) is deleted, and replaced by the single-length, unrounded quotient. The A.R. is cleared in the process.

When the numerator can be adequately expressed by a single-length number in the accumulator, care must be taken to ensure that the A.R. is clear before division takes place.

A note regarding the accuracy of the process used is given in Appendix 4B, and the arithmetic is discussed in Appendix 5.

### Example 10

1. C(151) = a x 2-38, C(152) = b x 2-38

To place a/b x 2-38 in location 153

 Address Instructions F1 N1 B F2 N2 387 30 151 50 38 Form a x 2-76 388 56 152 20 153 Divide, forming a/b x 2-38 and write.
2. C(251) = a x 2-19, known to be positive
C(252) = b x 2-19, To place a/b x 2-19 in location 253
 487 30 251 51 19 Form a x 2-38 and clear A.R. 488 56 252 20 253 Divide, and write result.
3. C(351) = a x 2-19, sign unknown, C(352) b x 2-19

State of A.R. not known. To place a/b x 2-19 in location 253

 587 51 0 30 351 Clear A.R., replace a x 2-19 588 50 19 56 352 Divide a x 2-38 by b x 2-19 589 20 353 Write result.

The instructions 51 0 and 55 0 have the effect "Clear the A.R.", and no other.

The existing C(A) is deleted, and replaced by a word comprising a zero in the sign digit position and a copy of the 38 digits of the A.R. content in the remaining positions.

The A.R. is not affected.

This provides, in effect, a fast double-length left shift of 38 places, subject to the following provisos:

1. That the sign digit will be wrong if the number is negative.
2. That the A.R. is not cleared.

The second of these points is usually of little consequence: in fact, it may well be found to be an advantage. How the former is overcome is shown below.

### Exercise 10

Verify that the following process is satisfactory, and that it is faster than if the instruction 54 38 were used:

a and b are integers of unknown sign, in locations 643 and 644. It is required to place the integer ab in location 645, it being known that ab is of smaller magnitude than 237.

 Address Instructions F1 N1 B F2 N2 412 30 643 52 644 ab x 2-76 413 57 0 54 1 Double signless ab x 2-38 414 50 1 16 645 Store signed ab x 2-38

### Example 11

This emphasises the advantage of multiplying double-length and dividing, successively, whenever an expression of the form

```                a.c.e......
b.d......
```
Suppose that a, b and c are stored to scale p (where p may be of the form 2-r or not), in locations 141 to 143. To evaluate ac/b and place it to scale p in location 144, we need:
 Address Instructions F1 N1 B F2 N2 614 30 141 52 143 a x p : ac x p2 615 56 142 20 144 (ac/b) x p :
This gives a clue as to the method used to rescale after multiplication or before division when using scales not the form 2-r. For if we make b=1 the result is ac x p; if c = 1, the result is (a/b) x p.

### Example 12

To extract the positive square root of a fraction, x.

If the formula yn+1 = 1/2(yn + x/yn) be used to generate a series of numbers yi, it can be shown that successive values of yi converge monotonically to the square root of x whatever initial value y1 be taken.

In adapting this process to the 803, y1 = 1-2-38 is chosen as this is the largest positive number which can be held, and must therefore be greater than or equal to the desired root. Thus, until the best possible approximation to the root is found each new yi is less than the previous, and yn+1 - yn is negative.

Ideally, yn+1 - yn should eventually reach zero, but rounding errors may bring about a situation in which it oscillates between �2-38. The process is therefore repeated until some yn+1 - yn is zero or positive, at which stage the programme "exits with yn in the accumulator".

### Programme

It is assumed that x is in the accumulator, and that the A.R. is clear. The entry point is the first instruction in location 501.
 Address Instructions F1 N1 B F2 N2 501 41 501 42 507 If negative stop. If zero exit. 502 20 509 30 508 Write x 503 20 510 30 509 Write y1. Replace x. 504 56 510 04 510 Form 2yn+1 = yn + x/yn 505 51 1 15 510 Write yn+1, form yn+1-yn 506 45 503 07 510 if negative, repeat: if positive, exit with yn. 507 40 511 00 0 EXIT 508 +274 877 906 943 1 - 2-38 509 x 510 y 511 Next part of programme
The reader is advised to work through this example to find the square root of 1 - 2-38. Attention is invited to 2.4.1 and to Appendix 4B.

## Group 6

Group 6 instructions are not allocated in the basic 803, the group having been reserved for special use in installations having additional equipment. In the basic machine they are interpreted as "do nothing".

See Appendix 5 for details of functions available when an Automatic Floating-Point Unit is fitted to the 803.

## Group 7

Group 7 functions are mainly concerned with inut and output, and are considered below individually.

Function 70 Read the Word Generator

On the keyboard there is a set of buttons, called the Word Generator, on which a computer word can be set manually.

In function 70, the existing C(A) is deleted, and replaced by a copy of the word set on the word generator. The N digits in the instruction are not used

This process can be used, in conjunction with other buttons on the keyboard, to place a few words in the computer by hand whenever the need arises.

It is also possible, by writing function 70 instructions in a programme, to enable the operator to control the way in which the computer obeys that programme.

### Example 13

In some particular application of a computer, the calculation consists of two separate parts, A and B, of which the second part may take two different forms, B1 and B2. Whether B1 or B2 is used is at the discretion of the operator.

The instructions comprising part A end in location 200, B1 commences in 301, and B2 in 401. If the operator depresses the top left hand (sign digit) button of the word generator, B1 is used. If he depresses the next button to it B2 is used. If he depresses neither, or both, the computer waits until one and one only is depressed.

### Programme

 Address Instructions F1 N1 B F2 N2 200 Last instructions of A. 201 70 0 45 203 Read: To 203(rh) if 1..... 202 55 1 41 401 Double: To B2 if 01..... 203 40 201 55 1 Return if 00....: Double 204 41 201 40 301 Return if 11...: To B1 if 10...

In this function one character is obtained from the input tape, and the five-digit binary number obtained therefrom is "mixed" into the five right-hand positions of the accumulator. The instruction to read Input Channel 1 is usually preceded by a 06, 16 or 55 5 instruction, so that (at least) the five right-hand positions in the accumulator are clear when function 71 is performed. If such is the case, the effect is to insert the character into the right-hand end of the accumulator.

If, however, any or all of the five right-hand digits of the acuumulator are not zeros when function 71 is performed, the effect obtained in each digit position is defined by:

0 + 0 = 0; 0 + 1 = 1; 1 + 0 = 1; 1 + 1 = 1, without carry.

After the character has been read, the tape reader drive mechanism operates, and the tape is moved forward to bring the next character into the reading position. If the next function 71 instruction is so placed in the programme that the computer reaches it before the tape has been moved far enough, a circuit known as the "tape reader busy line" automatically holds the computer up until the tape reader is ready. However, the speed of the Elliott tape reader is such that this is not likely to happen under normal circumstances.

The time taken for the tape to be moved depends upon the type of tape reader fitted.

### Example 14

A two-digit decimal number has been punched on the input tape, and the tape has been placed in the reader in such a way that the first character is in the reading position.

The following programme reads this number, and stores it as an integer in location 98. The entry point is the first instruction in location 100.

 Address Instructions F1 N1 B F2 N2 99 +15 Collating constant 100 06 0 71 0 Read first character 101 03 99 20 98 Delete parity digit 102 24 98 55 3 multiply by 10, and store in 98 103 24 98 06 0 104 71 0 03 99 Read second character, delete parity digit, if any. 105 24 98 Add to number in 98

### Exercise 11

How long would it take an 803 completed before December 1960 (see Appendix 3) take to obey the above if the tape reader's maximum speed is one character every

1. 9.36 milliseconds
2. 2.16 milliseconds

Note: These times are quoted for exercise only, and are not typical of the equipment provided)

Function 72

This is described, with functions 75, 76 and 77 below

Function 73 Write the address of this instruction

The N digits in the instruction specify the address of a location. The action is:

C(N) is deleted, and replaced by a word in which the right-hand nineteen digits correspond to the instruction "00 M", where M is the address of the instruction contining the 73 instruction. The state of the left-hand part of the new C(N) varies.

This instruction is generally used in conjunction with the B digit when utilising subroutines, and detailed discussion is therefore postponed until these topics are reached.

Function 74 Punch Specified Character on Output Channel 1

In this function, the character with telecode value N, where N in this case corresponds to the five right-hand N digits of the instruction, is punched to the output tape.

The other N digits are ignored: no numbers in the computer are affected.

When the neccesary signals have been sent to the punch, the computer is then free to proceed with other activity. But if the next function 74 instruction is so placed in the programme that the computer is ready to obey it before the punch has finished the punching process, a circuit kmown as the "punch busy line" automatically holds the computer up until the punch is ready.

### Example 15

The instruction 74 19 causes the punching of the character which a teleprinter interprets as S or 3 according to the shift in use.

The instruction 74 115 has the same effect.

Functions 72, 75, 76 and 77 Channel 2 functions

The 803 has been designed in such a way that a variety on input and output devices or a magnetic film backing store may be attached to what is termed channel 2.

The interpretation of functions 72, 75, 76 and 77 is described in separate publications relating to the applications of such devices.

In computers in which use is not made of Channel 2, function 72 is interpreted as "clear the accumulator" and functions 75, 76 and 77 as "do nothing".

 Previous Chapter Contents Next Chapter