# Home

### 3. THE ACCUMULATOR

#### 3.1 Floating-point numbers

When a 48-bit word is used to represent a number it is divided into 40 bits for a signed mantissa x and 8 bits for a signed exponent y.

##### Floating point Number

Digit 0 is the exponent sign, digit 8 the mantissa sign.

The exponent is an octal one, so the number represented has the value

x.8 y

The exponent is an integer and lies in the range

-128 ≤ y ≤ 127

The mantissa is a fraction, with the binary point taken to be after the sign digit, so it lies in the range

-1 ≤ x ≤ 1 - 2-39

With this system it is possible to represent positive or negative numbers whose magnitudes are approximately in the range 10-116 to 10113.

Example: One way of representing the number 8 is by a mantissa of +⅛ and an exponent of +2, i.e. as ⅛ × 8 2. Thus:-

Exponent       Mantissa
0 0000010      0.001000000............. 000

For clarity, when this is written in binary digits the exponent is spaced out away from the mantissa, the sign digits are slightly separated from the numbers, and the mantissa binary point is shown. This convention will be used in future without more explanation.

#### 3.2 The Accumulator

Floating-point arithmetic is all done in the full accumulator (A) and in order to describe the arithmetic it is first necessary to introduce the accumulator.

The accumulator has an 8-bit signed exponent ay and a double-length mantissa ax, of 78-bits and a sign bit. The mantissa Ax is regarded as being divided into M and L, M being the sign digit with the 39 more-significant digits, and L being the 39 less-significant digits. Associated with L is a sign digit called Ls. Ls is situated between M and L, and it is usually irrelevant; that is, arithmetic in the accumulator proceeds as if Ls is not present.

The accumulator is sometimes regarded as holding two single-length floating-point numbers. These are called Am and Al.

Am consists of Ay and M
Al consists of Ay and L with Ls

There are a further two digits to the left of the sign of Am. These are the guard digits and their function is explained later. It is not possible to transfer numbers into or out of the guard digits, and before an accumulator operation they are normally copies of the mantissa sign digit.

The exponent ay is held in the special B-register B124, which consists only of nine digits at its most-significant end, the other digits 9-23 being zero. The exponent is held in digits 1-8. Digit 0 is used as a guard digit, to detect if the number departs from the range -128 ≤ ay ≤ 127. Digit 1 is the sign digit and normally digit 0 is the same as digit 1. If the two digits are different, then the exponent has gone outside its permitted range. If d1 = 1 and d0 = 0, then ay > 127; if ay > 127 at the end of an accumulator operation, then Exponent Overflow is said to have occurred and in some cases the program is monitored (see section 11.1.1). If d1 = 0 and d0 = 1, then ay < -128; if ay < -128 at the end or an accumulator operation, then Exponent Underflow is said to have occurred and normally the contents of the accumulator are automatically replaced by standard floating-point zero (see section 3. 3).

Note that because of the guard digit, the position of the exponent as held in B124, (digits 1-8) is different from the position of the exponent for a number held in the store, which would be in digits 0-7.

Accumulator instructions usually involve arithmetic on two numbers, one of these being in the accumulator and the other taken from the store. Most accumulator instructions deal with standardised numbers, so these will now be described.

#### 3.3 Standardised numbers

The representation of a floating-point number is not unique. For example ½ = ½ × 80 or 1/16 × 81 or 1/128 × 82 etc. so any of the forms below represent ½.

Exponent          Mantissa            Value = ½
0 0000000       000.100000000....   ½ × 80
0 0000001       000.000100000....   1/16 × 81
0 0000010       000.000000100....   1/128 × 82

(Note that the two guard digits are shown to the left of the mantissa sign digit.)

It will be noticed that the value of a number is unchanged if unity is added to or subtracted from the exponent every tine the mantissa is shifted octally (by 3 bits) down or up, respectively.

The optimum form of storage of a number in a binary floating-point system is that in which there are the minimum number of 0's (assuming a positive number) between the binary point and the most significant 1 of the fractional part of the number. This enables the maximum number of fractional digits to contribute to the accuracy of the representation.

As Atlas has an octal exponent, shifts of the mantissa may only be by 3 bits at a time, so it is not possible to specify that there should be no 0's immediately after the point. It is possible to specify a maximum of two, and this is known as the standardised condition. A corresponding convention for a minimum number of 1's holds for negative numbers.

An Atlas standardised number is therefore such that the mantissa lies in the range:-

⅛ ≤ x < 1 or -1 ≤ x < -⅛

and it may be necessary to shift the mantissa of the number resulting from an operation up or down, adjusting the exponent accordingly, to achieve this.

If a number is not standard it is either substandard or superstandard. A substandard number is one such that -⅛ ≤ x < ⅛. The three most significant digits of ax will be the same as the sign digit (and guard digits), so the number can be standardised by octal shifts up and adjustment of the exponent. A superstandard number is one in which the mantissa has overflowed into the sign and guard digit positions, i.e. it is ≥1 or < -1 and it is detected by the guard digits not being the same as the sign digit. To standardise such a number, a single octal shift down is required, with the addition of unity to ay.

Example: the addition of 5/8 + 3/8 with a standardised instruction gives the correct result of +1 standardised; though immediately after the addition the number is superstandard.

5/8 = 5/8 × 80              0 0000000      000.101000...
+ 3/8 = 3/8 × 80            0 0000000      000.011000...
=1 = 1 × 80 (superstandard) 0 0000000      001.000000...
1 = 1/8 × 81 (standardised) 0 0000001      000.001000...

The number zero is a special case. Floating-point zero is represented by a mantissa of 0 and an exponent of -128, and this is regarded as a standardised number. Zero is specially looked for when a number is to be standardised, and, if found, no shifting takes place and the exponent is immediately set to -128.

#### 3.4 Fixed-point numbers

For some purposes it is inconvenient to deal with floating-point numbers, and accumulator instructions are provided which do not standardise the results of operations. Using these instructions it is possible to regard the binary point as being anywhere it is desired; for example, at the least significant end of M (which means regarding numbers in Am as integers between the range of -239 and 239 - 1). In this type of arithmetic, the exponents of the numbers must all be the same, and are commonly zero. If they are the same but non-zero, adjustments are required when multiplications and divisions are performed.

Superstandard numbers cannot be automatically corrected in fixed point working, so if they occur, a special Accumulator Overflow digit (AO) is set, and this digit can be inspected by the program.

For example, if the point is taken at the least significant end of M, then the numbers in the last example, 5/8 and 3/8, now have the values (238 + 236) and (237 + 236). Adding them gives a superstandard answer and sets AO.

#### 3.5 Rounding

Most accumulator instructions operate on the two numbers am and s, leaving the answer in ., This answer may be an operand in the next instruction with only am used, the digits in L being cleared before the operation. The process of cutting off these less-significant 39 digits of the answer is called truncation, and this introduces an error each time which could quickly become significant. Rounding is the name given to the process of compensating the answer so as to minimise the effect of truncation.

One method of rounding is to force a 1 (i.e. the logical OR operation) in the least significant digit of M if 1 is non-zero. If 1 is zero, no forcing takes place. In a sequence of accumulator instructions, the average error introduced by this method is zero, so no bias is introduced.

Further single-length integer arithmetic in Am can be carried out exactly without any unwanted rounding, as long as numbers never extend into L. The abbreviation R is used in describing some instruction to signify rounding in this way. Notice that L is not changed by the process of rounding.

An instruction is also provided to give rounding by adding a one to the least-significant digit of M if the most-significant digit of L is one. Again, the digits of L are left unchanged. This type of rounding is referred to as R+ Rounding. It is sometimes preferred to the method just described as less accuracy is lost, but is slightly biased in that the rounding is always upwards in the halfway case of L being a binary one followed by a string of zeros.

#### 3.6 Floating-point operations

Before two numbers in floating-point form can be added the numbers must be shifted relative to each other so that digits which have the same significance can be added together, i.e. one number is shifted octally until the two exponents are equal.

In Atlas, the number which has the smaller exponent is the one that is shifted, and it is shifted down into L, irrespective of whether it is the number in A or the number in S. There are four addition instructions, and of these, three clear L before this shifting takes place, so the addition is between am and s.

Ay is then set equal to the larger of the two exponents and the arguments are added together. The addition takes place over the 42 digits of Am with its guard digits. L remains unchanged during this stage.

After the addition, the accumulator may be standardised and rounded, standardised but not rounded, or left unstandardised and unrounded, depending on the instruction. The instructions which standardise check that exponent overflow has not occurred, the instructions which do not standardise look for accumulator overflow.

The addition instruction which does not clear L first is used mainly in double-length arithmetic. To work correctly, the exponent of s must be equal to or greater than ay, so that the contents of the accumulator are shifted down. If sy < ay then s would be shifted down into L overwriting the original contents of L.

#### Standardising and rounding accumulator instructions

We are now in a position to introduce some accumulator instructions.

Function Description Notation
320 Clear L; add the contents of S to the contents of Am; standardise the result, round by forcing a 1 into the least-significant bit of M if 1 is non-zero and check for exponent overflow. am' = am + s QRE
321 As 320 but subtract s am' = am - s QRE
322 As 320 but first negate the contents of A am' = -am + s QRE
324 Transfer the floating point number in S to Am and standardise it am' = s Q
325 As 324 but transfer negatively and check for exponent overflow am' = -s QE
326 Store am at S, leaving the contents of A unchanged s' = am
362 Clear L, multiply am by s, standardise, round and check for exponent overflow am' = am.s QRE
363 As 362 but multiply negatively am' = -am.s QRE
374 Divide am by s, leaving the quotient standardised and rounded in Am, with l' = O. Check for exponent overflow and division overflow. Both am and s must be standardised numbers am' = am / s
l'=0 QRE DO

The above are the most commonly used accumulator instructions, all but the 356 instruction leaving a standardised rounded number in Am.

Example: given four standardised floating-point numbers a, b, c, d in the first four locations of store, replace a by (a-b+c)/d2

324    0     0     3         put d into Am
362    0     0     3         form d2
356    0     0     4         store in location 4
324    0     0     0         a into Am
321    0     0     1         subtract b
320    0     0     2         add c
374    0     0     4         divide by d2
356    0     0     0         store answer in word 0

Note that register 4 is used as working space, and that Ba and Bm are zero in every instruction.

#### 3.8 The timing of instructions

In general, it is not possible to state exactly how much time any instruction will take, because this partly depends on the instructions before and after it. However, in a sequence of additions, subtractions or transfers each unmodified instruction takes about 1.6µs. If modified by bm, the time is 2.0 µs, and if modified by bm and ba the time is 2.5µs. The times for multiplication and division are 6.0 µs and about 20µs respectively. The division time depends on the numbers involved. However, another limitation on the speed is the time needed after reading a. number from a stack of core store before another number can be read from it. This is known as the cycle time of the store and is 2 µs. As alternate addresses are in the even and odd stacks, (see section 2.2) if operands are used in sequence then the cycle time is not a limitation. In the example just quoted, the sixth instruction would take 2µs because the next instruction cannot read its operand until this time is up. In the fifth and sixth instructions the operands are in different stacks so the subtraction would take 1.6µs. B-register instructions, as they use a different arithmetic unit, can continue while the accumulator is busy. During a division instruction, for example, three or four B-instructions might be completed, effectively taking no time at all.

#### 3.9 Some fixed-point Instructions

Fixed-point working has been introduced in section 3.4

Function Description Notation
330 Clear L, add s to am, leaving the result in A. Do not standardise or round but check for accumulator overflow a' = am + s AO
331 as 330 but subtract s a' = am - s AO
332 As 330 but negate am before the addition a' = -am + s AO

In these instructions, if the exponents are the same, no shifting down of either of the numbers into L takes place, so the answer will be in Am.

 334 Transfer s into Am without standardising am' = s 335 Transfer the number in S negatively into Am without standardising, and check for accumulator overflow am' = -s AO

In 335 AO would be set if s is just a one in the sign position (which we will call -1.0) as negating this sets the sign digit different from the guard digits.

 364 Shift the mantissa up one octal place, leaving the exponent unchanged. Accumulator overflow can occur, but no check is made ax' = 8 ax ay' = ay 365 Shift ax down one octal place, leaving ay unchanged ax' = ⅛ ax ay' = ay

The above two instructions are of course also useful in floating-point arithmetic, to multiply or divide by 8. Extracodes are provided to shift any specified number of places up or down.