Contact us Heritage collections Image license terms
HOME ACL Associates Technology Literature Applications Society Software revisited
Further reading □ CONTENTS1. Basic Facilities2. Further Facilities3. Matrix Operations4. Programme LibraryA1. Punching ServiceA2. Running YourselfA3. Interpretation of Machine OrdersA4. At ManchesterA5. Library Programmes
ACD C&A INF CCD CISD Archives Contact us Heritage archives Image license terms

Search

   
ACLLiteratureOther manualsMercury Autocode :: Mercury Autocode Manual
ACLLiteratureOther manualsMercury Autocode :: Mercury Autocode Manual
ACL ACD C&A INF CCD CISD Archives
Further reading

CONTENTS
1. Basic Facilities
2. Further Facilities
3. Matrix Operations
4. Programme Library
A1. Punching Service
A2. Running Yourself
A3. Interpretation of Machine Orders
A4. At Manchester
A5. Library Programmes

Chapter 2: Further Facilities

The information given so far will enable the reader to attempt a fairly wide range of problems - with limited storage requirements. The use of the auxiliary store is discussed in the next few pages which describe several additional facilities. The first of these is a device for speeding up the execution time of chapters involving functions.

Quickies

Every time one of the functions sqrt (48), cos (36), log (42), tan (42), radius (48), sin (36), exp (50) and arctan (58) is referred to, 17 millisecs are spent in transferring the necessary set of instructions (subroutine) from the magnetic drum to the instruction store. Provided there is room, however, they can be included in the chapter itself. and in this case the average execution time is reduced from about 23 millisecs to 6 millisecs. Functions treated in this way are known as quickies. The number of registers required for each function is given above in parentheses. All that is necessary is to list them (each preceded by Æ) in order of preference at the end of the chapter in question, immediately before the close directive (see below). Any functions for which there is not room will be treated in the usual way.

chapter 1
variables
instructions
Æ exp
Æ sqrt
Æ sin
close

In the case of sin and cos these functions involve the same set of instructions, so that if one is treated as a quicky, the other will be also. The same applies to sqrt and radius. Finally it should be mentioned that the functions mod, int pt, fr pt, divide are automatically treated as quickies, so that there is no need to include them in a quicky list.

Rounded and unrounded arithmetical operations

In those arithmetical instructions involving a variable expression on the right hand side, each sum, difference, and product is formed to a maximum precision of 29 binary digits and rounded by making the last digit odd. If required, the rounding operation can be omitted by using the » sign instead of =. In this case the result will normally be biased, but if the quantities involved can be expressed precisely in 29 significant binary digits or less, then the » sign provides a means of performing exact arithmetical operations (excluding division) on variables. These will usually be restricted to integral values, however, since these are the only values which are converted from decimal to binary form precisely during input.

Rounding errors will be significant when using the int pt and fr pt instructions. Thus for example:

If x = 3 + 2-27, then Æ int pt(x)) gives 3 
                                 Æ fr pt(x)) gives 2-27
If x = 3 - 2-27, then Æ int pt(x)) gives 2 
                                 Æ fr pt(x)) gives 1 - 2-27
If x = 3  precisely, then Æ int pt(x)) gives 3 
                                 Æ fr pt(x)) gives 0.2-256 (zero)

If the nearest integer to x is intended, it is sufficient to use (say)

y = Æ int pt (x + 0.5) 

unless x itself is half an odd integer, in which case the result wIll again depend critically on rounding errors. Finally it should be pointed out that the int pt, fr pt. and mod instructions do not themselves introduce any rounding errors - nor of course do simple transfers.

The auxiliary variables

If the working variables are insufficient in number, then access to an auxiliary store provides up to 10752 further variables, depending on the number of chapters in the programme.

The auxiliary storage locations may be regarded as numbered 0, 1,...., 10751 but the last 512n of these are occupied by chapters 1 to n inclusive. Thus in a programme extending up to and including chapter 4 the last available location is 8703.

To use the auxiliary variables they must first be transferred to the working store, and at some time or other information must be transferred to the auxiliary store from the working store. Both of these are relatively time consuming operations, and programmes employing them require fairly careful planning.

The transfer instructions take the form

            Æ6 (x) w, n      read from auxillary store
Æ7 (x) w, n      write to auxillary store

Here the (integral) value of x (any variable expression) specifies a starting location in the auxiliary store, and the variable w is regarded as a starting location in the working store; n (any index or whole number) is the number of consecutive variables transferred. The expression x is computed without rounding, i.e., as if it were on the right hand side of a » sign. The variable w will generally be one of the main set, unless n = 1 in which case it could be a special variable. Examples are:

            Æ6 (1000) xk, 10 

Transfers the contents of auxiliary locations 1000 to 1009 (inclusive) to xk, x(k+l),.. x(k+9).

            Æ7 (d-n+1) a1, n 

Transfers the variables a1, a2, ..., an to auxiliary locations d-n+1 ,..., d.

            Æ6 (f) g, 1 

Replaces the special variable g by a number from the auxiliary store.

It is very often appropriate to associate letters with groups of numbers in the auxiliary store, e.g., when dealing with matrices. For this purpose fourteen new working variables

a' b' c' d' e' f' g' h' u' v' w' x' y' z'

are introduced. These are essentially similar to the special variables a, b, c,. .., z and indeed may be used as such if desired. It is intended, however, that they be used to designate the starting locations of groups of auxiliary variables. Thus for example by setting a' » 1000 we define a group of unlimited extent located in 1000, 1001, etc. If the group is an (n × n) matrix and recorded so that the (i,j)th element stands in a' + (i-1)n + (j-1) then the instruction Æ6 (a'+in-n) b0, n transfers the i-th row of the matrix to the working store.

The execution time for a group transfer cannot be given very precisely but is less than 17 × int pt(n/32) + 34 +0.36n msec where n is the number of variables transferred.

The instructions preserve and restore

These apply to the use of subchapters. If necessary the working variables can be preserved during the operation of the subchapter and restored on return to the main chapter. This can be done by writing the word preserve before the down instruction and the word restore immediately after it. The variables in question are dumped in hidden locations of the auxiliary store. Tbere are two dumps, the first being used by the master chapter when calling in a subchapter, and the second by a subchapter when calling in a sub-subchapter. A programme may thus extend over three levels, as illustrated below.

chapter 1
.............
preserve
down 1/2
restore
.............
chapter 2
1).........
preserve
down 1/3
restore
.............
up
chapter 3
1)
.........
up

A consequence of this arrangement is that any results calculated by the subchapter will have to be recorded in the auxiliary store in order to preserve them. Alternatively, if they are left in the working store, then the restore instruction can be postponed until they have been dealt with in the master chapter.

It is recommended, however, that subchapters be designed so as to select from, and return to, the auxiliary store all relevant material. In this form they provide a convenient means of arranging a calculation for possible future use as a packaged programme. The subchapters can be written in terms of auxiliary groups a', b', c', etc., without assigning numerical values to these variables. Instead they can be defined in terms of those used in the main chapter by including appropriate instructions between the words preserve and down. The original values of a', b', c', etc. can then be restored on returning to the main chapter. In this way each level of organisation may use its own frame of reference for the auxiliary variables. As an example, suppose that both the main chapter and the subchapter employ three groups of auxiliary variables denoted in both cases by a', b', c', and starting relative to each other as follows:

a'(sub) = c'(main)
b'(sub) = a'(main)
c'(sub) = b'(main) + 50
main chapter   a'          b'  b'+50         c'
subchapter     b'              c'            a'

The instructions for calling in the subchapter and redefining the auxiliary variables are then as follows

preserve
π » a'
a' » c'
c' » b' + 50
b' » π
down ?/?
restore

The special variable π has been used as a shunting station since in any case it will be reset on entering the new chapter (π is automatically reset to 3.14159... as a result of the instructions across, down, up, preserve, and restore). Normally it is not advisable to alter the value of π.

Operations with complex numbers

Operations with complex numbers written as number pairs are provided by instructions of the form:

(u, v) = (x, y)
(u, v) = (x, y) + (a, b)
(u, v) = (x, y) - (a, b)
(u, v) = (x, y) * (a, b)
(u, v) = (x, y) / (a, b)
(u, v) = Æ sqrt(x, y)    (u > 0)
(u, v) = Æ log(x, y)    (π > v > -π)
(u, v) = Æ exp(x, y)    (u > 0)

Here u, v; x, y; a,b denote any variables or (except in the case of u, v) signed constants. Examples of instructions in this class are

(fi, gi) = (f(i-1), g(i-1)) + (f(i+1), g(i+1))
(x, y) = Æ sqrt(1, 1)   
(a, b) = Æ log(-0.5, h)   

Not, that no instruction may contain more than one operation.

The complex functions involve the use of certain real functions, as follows:

complex sqrt     involves    sqrt
complex exp      involves    exp, sin, cos
complex log      involves    log, arctan

Thus in order to treat the complex functions as quickies, it is sufficient to list the relevant real functions. The ?-print facility does not apply to complex operations.

Double Precision Instructions

Certain limited double-length facilities have been incorporated into Autocode. These consist of the four basic arithmetical operations and, in addition, a reciprocal operation and a single copy. The instructions take the form:

(i)     ((x, y)) = ((a,b)) θ ((c, d))
(ii)    ((x, y)) = 1 / ((a,b)) 
(iii)   ((x, y)) = ((a,b))

where θ is replaced by one of + - * / corresponding to addition, subtraction, multiplication and division, and where a, b, c, d, x, y may be replaced by any variable, either working or special (see examples).

The combination ((x, y)) will be interpreted as the two parts of the double length number in the above operations, x being the more significant half and y the less significant half. On Mercury x is represented to a precision of 28 binary digits and y to 29, i.e. a total of 57 binary digits. Hence y should be at least 2-28 (about 10-9) times smaller than x; this condition will automatically hold true for pairs x, y computed by the above operations, but note that the copy in no way alters the numbers being copied. (On Atlas or Orion of course the corresponding figures will be quite different.)

There remains the problem of single to double-length conversion. Any variable or constant, expressed to a precision of at most 28 binary digits, e.g., an integer less 4 than lO8, can be converted to standard double length form by associating with it a zero less significant half, Thus if a(j-3} contains an exact quantity then to obtain a(j-3)/3 to double precision, one writes:

((x, y)) = ((a(j-3), 0)) / ((3, 0))

Notice that, if a(j-3) is not exact but contains a rounding error, then the operation is worthless, as x will contain the same relative error and y will be meaningless.

With the above considerations, the facilities described in the second paragraph of this section may be extended by noting that any pair ((a, b)) or ((c, d)) in equation (i) (ii) may be replaced by ((u, 0)) where u is any variable or constant which can be represented exactly. The following examples will illustrate these facilities.

((ai, a(i+1))) = ((bj, cj)) / ((5, 0))
((x', y')) = 1 / ((a(k-3), b(k-3)))
((x, y)) = ((2, 0)) * ((a, 0))

Double length pairs should, for convenience of use, and to avoid errors, be stored either in corresponding positions under two different letter, e.g. x3, y3 or as adjacent numbers under the same letter, e.g. vj, v(j+1), when the even sufficies will indicate the more significant part.

It is expected that double length working will be mainly used to minimise the effects of destructive cancellation in ill-conditioned problems; and that there will be no great need for double length input and output routines. For this reason these operations will be available only as the library sub-programme -512.

However, even without this, something can be done.

A number consisting of integral and fractional parts can be read as two distinct numbers and combined to form a double precision quantity as follows:

read (x)        integral part 0 ≤ abs(x) ≤ 228
read (y)        fractional part 0 < abs(y) < 1
((u, v)) = ((x, 0)) + ((y, 0))

conversely we can print a number in this form, thus

((u, v))
x = Æ int pt(u)
print (x) ?,0
y = Æ fr pt(u)
((u, v)) = ((y, 0) + ((v, 0))
print (u) 1,?

Finally, in any chapter in which any of the double-length operations are used, the directive:

double length

must be inserted after the variable directives for that chapter and before the first instruction. Thus:

a ® 4
b ® 4
double length
3) x = 4

will satisfy the requirements. This directive will use up 128 of the available 832 registers.

The space occupied by these instructions is (i) 13 - 23 registers, (ii) 9- 15 registers, (iii) 6 - 10 registers. The times for the operations are;

copy            14 µmin
addition        70 µmin
subtraction     90 µmin 
multiplication 120 µmin
reciprocal     480 µmin
division       600 µmin

Step-by-step integration of differential equations

Special facilities are provided for the integration of differential equations. The equations must be written in the form:

fi = dyi/dx = fi(x, y1,...,yn) (i = 1,...,n)

Involving the special variables x, the main variables yi fi and the index n. In addition the special variable h is used for the step length and the main variables gi, hi, are introduced for working space. The programmer must write a subsequence for calculating the fi in terms of x and the yi and which must not alter yi, gi, gi nor n, h, x. The entry should be labelled and the sequence should terminate with the special instruction 592, 0 (see Appendix 3). With these arrangements the effect of the instruction:

int step (m)

(where m is the entry to the subsequence) is to advance the integration by one step so that the initial and final values of the independent and dependent variables are respectively:

x          x+h
yi(x)    yi(x+h)

The method employed is that of Runge-Kutta, with truncation error of O(h5). However the truncation error also depends on the higher derivatives of the function and for this reason the step length may be adjusted between steps if desired. The time per step is (10n + 4T) millisecs, where T is the time (in millisecs) of the subsequence.

For example, to tabulate the solution of the equations:

dy1/dx = y12 - 1.23 y1 y2 + 2.47 y22
dy2/dx = 1.01 y12 - 0.84 y1 y2 + 1.59 y22
for x = 0 (0.2) 1
with the initial conditions
1) x=0    y1=0   y2=1
2) x=0    y1=1   y2=0

The programme would be:

    chapter 0
    f ® 2
    g ® 2
    h ® 2
    y ® 2
    n = 2                    number of equations
    h = 0.02                 step length
    m = 1(1)2
    i) = m)                  selects initial conditions
    jump (i)
11) int step (10)
    newline                  tabulate results
    print (x) 1,2
    space
    print (y1) 2,4
    print (y2) 2,4
    jump 11, 0.99 > x        test for end of range
    repeat
    end
10) f1 = y1y1 -1.23 y1y2 + 2.47 y2y2            auxillary sequence
    f2 = 1.01y1y1 -0.84 y1y2 + 1.59y2y2
    592,0
1)  x = 0                    subsequence for setting initial conditions
    y1 = 0
    y2 = 1
    jump 11
2)  x = 0
    y1 = 1
    y2 = 0
    jump 11
    close

Note that the instructions int step (10) 10) 592,0 must occur in the same chapter, although the auxillary sequence may involve transfer of control to another chapter.

Tape Code for Mercury Computer

Tape Value FS LS
. 0 FS FS
. • 1 1 A
.• 2 2 B
.•• 3 * C
•. 4 4 D
•. • 5 ( E
•.• 6 ) F
•.•• 7 7 G
• . 8 8 H
• . • 9 I
• .• 10 = J
• .•• 11 - K
••. 12 » L
••. • 13 LF M
••.• 14 SP N
••.•• 15 , O
• . 16 0 P
• . • 17 > Q
• .• 18 R
• .•• 19 3 S
• •. 20 ® T
• •. • 21 5 U
• •.• 22 6 V
• •.•• 23 / W
•• . 24 Æ X
•• . • 25 9 Y
•• .• 26 + Z
•• .•• 27 LS LS
•••. 28 . .
•••. • 29 ' ?
•••.• 30 CR π
•••.•• 31 Erase Erase

The generation of pseudo-random numbers

The recurrence relation:

xr+1 = a xr (mod 229)

is used for this purpose where a = 435. The most suitable method of working this recurrence on Mercury involves the use of un-standardised floating point numbers. The following sequences are employed:

i = 29
j = 955
k = 202
l = 140
400, 58
410 (a)    sets a to 435
i = 0
j = 1
k = 0
l = 0
400, 58
410 (x)    sets x0
             Therefore we can generate a new random number (in the range 0 < x < 1 
             but un-standardised) by the sequence:
400 (x)
540 (a)
410 (x)
             The least significant digits of x are not reliable.
t = Æ int pt(100 x)
             yields a random integer in the range 0 to 99 inclusive
             The initial value of x0 can be changed by
i = 0
j = 1
k = 1
l = 0  

The above facility will enable the user to write programmes for plant simulation and allied problems.

Estimation of time and space for Autocode programmes

Instruction                 Machine instructions           Time in µmins
Programme load                                0           3000 per instruction or directive
Arithmetic expressions                   
Each letter                                   1              1                            
Each operator                                 1              1
Each index                                    4             10
Each constant                                 3              1
Each solidus                                  4             60
Each implied multiplication                   0              5
Index expressions
Each letter                                   1              0
Each operator                                 0              1
Each implied multiplication                   4             10
Functions (arguments as above)
divide                                        6             60
mod, intpt, frpt, sign, parity                6             10
sqrt, sin, cos, tan, exp, log, arctan, radius 6            100 + 300 (access)
Control
label                                         0
jump 2                                        1              1
jump 2, conditional                           6              6
n) = 3)                                       2              2
n) = m)                                       6            300
jump (n)                                      2              2
i = p(q)r                                     6              2
repeat                                        5              5
across 2/1                                    6           2000
down 2/1                                      3           2000
up                                            3           2000
rmp                                           3           3000
end, halt                                     1 
Auxilliary transfers
Æ6 (x+yj) bk, n                              10            600 + 14n
Æ7 (x+yj) bk, n                              10            600 + 22n
preserve, restore                             4           3000
Input/output
read(a(i+1)) 10 characters                    6           1750
space                                         2           1000
newline                                       3           2000
print (x) m,n                                 8           3000 + 500(m+n)
?i                                            2           4000
?x                                            2           8000

Notes

1. Space
Although, owing to the wide variety of permissible forms, it is not possible to say exactly how many instructions will fit into a single chapter, the figure of 100 has been found to be a reasonable estimate. If a chapter becomes too long, this will be indicated during input and the 100 subsequent characters will be printed out. The psa directive used during development of the programme will also give a good idea of how the space is being used up.
In general this is all that need by done about the space occupied, but occasionally it may be necessary to estimate the space more exactly, e.g., to avoid a chapter change in an inner loop. In this case the table may be used.
Consider the expression zi = y(i+1) + xy(i-1) +3i +4/x
Each of the 9 letters        count 1 machine register giving 9 registers
Each operator not in suffix counts 1 machine register giving 4 registers
Each index not in suffix    counts 4 machine register giving 4 registers
Each constant               counts 3 machine register giving 6 registers
Each solidus                counts 4 machine register giving 4 registers
Total is 27 registers
2. Time
In many cases the ratio of computing to output time is so small that only the output need be counted when estimating the time. In other cases there Is no need to analyse anything except the inner loop since nearly all the time is spent doing these instructions.
For example zi = y(i+1) + xy(i-1) +3i +4/x
Each of the 9 letters        count  1 µmin giving  9 µmins
Each operator not in suffix counts  1 µmin giving  4 µmins
Each index not in suffix    counts 10 µmin giving 10 µmins
Each constant               counts  1 µmin giving  2 µmins
Each solidus                counts 60 µmin giving 60 µmins
Each implied multiplication counts  5 µmin giving  5 µmins
Total time is 90  µmins
3. Accuracy
The above figures have an accuracy of about 10% when applied to typical instructions.
⇑ Top of page
© Chilton Computing and UKRI Science and Technology Facilities Council webmaster@chilton-computing.org.uk
Our thanks to UKRI Science and Technology Facilities Council for hosting this site