In preparing problems for numerical solution by means of an automatic calculating machine it is apparent that different problems have many parts in common. These parts could therefore be prepared once and for all in a form sufficiently flexible to be used in different problems thus forming a library which would be of great assistance to all users.
We now define the following terms:
The following advantages arise from the use of such a library:
In order to produce a workable library it is necessary to code subroutines in such a way that they can be taken directly into the store of a machine. In the case of a machine such as EDSAC in which orders all refer to absolute storage locations each sub-routine can be placed in the store in one set of positions only. Thus if one order refers to, or operates on another order of the same sub-routine it will need to be adjusted when the sub-routine is moved from one storage location to another.
Example: to replace the number in storage location 100 by its modulus:
Storage Order Interpretation Location n A 100 Add contents of 100 to Acc n+1 E n+4 Examine sign of Acc; if +ve select the contents of (n+4) as the next order otherwise proceed serially n+2 S 100 Subtract contents of 100 from Acc n+3 S 100 Subtract contents of 100 from Acc n+4 T 100 Transfer the contents of the Acc to 100
The meaning of the above orders is invariant only if the second order is adjusted according to its location in the store.
This difficulty could be overcome in four ways:
We have adopted this last solution at Cambridge for the use of our punched tape library as it does not involve an increase of equipment and overcomes most of the troubles experienced. In many ways it is a more flexible solution than would result from increasing our equipment. We have named the special sub-routine referred to in (4) above, the CO-COORDINATING-ORDERS.
Another difficulty arises from the fact that, although it is desirable to have sub-routines available to cover all possible requirements it is also undesirable to allow the size of the resulting library to increase unduly. However, a sub-routine may be made more versatile by the use of parameters associated with it, thus reducing the total size of the library.
We may divide the parameters associated with sub-routines into two classes:
The co-ordinating orders use the external parameters (l) by combining them with the sub-routine, order by order, and placing the corresponding adjusted sub-routine in the store, just as if it had been coded for the particular values, given to the external parameters. This means that the sub-routine is much simpler and shorter than it would be if it had to modify itself by means of internal parameters each time it was used. Thus the use, where possible, of external parameters reduces the complexity of sub-routines.
Sub-routines may be divided into two types, which we have called OPEN and CLOSED. An open sub-routine is one which is included in the routine as it stands whereas a closed sub-routine is placed in an arbitrary position in the store and can be called into use by any part of the main routine.
The combination of closed sub-routines, and internal parameters in the main routine is very attractive and in some ways may be considered as equivalent to an exceedingly large multi-address order code.
An example of the plan of the input tape for a typical problem is given below:
The following description of the working of the co-ordinating orders we have selected may be of interest.
Each order in a sub-routine is punched on the paper tape followed by an additional code letter which enables the co-ordinating orders to deal with it appropriately.
The following is a selection from the code:
Code letter | Meaning as interpreted by co-ordinating orders |
---|---|
D | Number all subsequent orders with the code letter θ from the position of this order in the store. |
θ | This order is numbered with reference to the previous D order. |
F | This order requires no modification. |
K | Use the order as an external parameter. |
H | Add the 1st external parameter to this order. |
M | Add the 2nd external parameter to this order. |
Suppose that there is a sub-routine in the library which will take the modulus of the difference of the contents of storage locations n and m and place it in location 1, where n and m are determined by external parameters. We will illustrate giving n and m the values of 100 and 110.
Order Code Letter 0 T 1 D clear acc 1 A H add n to acc 2 E 5 θ if acc is +ve, transfer control to 5 3 S H) change sign of 4 S H) acc 5 T 1 F put modulus in location 1 6 A M 7 E 10 θ 8 S M) change sign of acc if negative 9 S M) 10 S H form difference 11 E 14 θ change sign of 12 T 1 F) difference if 13 S 1 F) negative 14 T 1 F put answer in location 2
P 100 K) external parameters P 110 K) punched for problem T 1 D) A H) E 5 θ) s H) S H) T 1 F) A M) E 10 θ) S M) from library S M) S H) E 14 θ) T 1 F) S 1 F) T 1 F)
Storage Order in Storage Location Location P T 1 P+1 A 100 P+2 E P+5 P+3 S 100 P+4 S 100 P+5 T 1 P+6 A 110 P+7 E P+10 P+8 S 110 P+9 S 110 P+10 S 100 P+11 E P+14 P+12 T 1 P+13 S 1 P+14 T 1
Thus using a set of co-ordinating orders which may be of various kinds it is practical to make use of a library of sub-routines, oven with the restricted order code of the EDSAC and if one uses the same orders for the main programme in the store the coding of the main programme is simplified. This in some small way illustrates how it is possible to make calculating machines organise their own problems, and thus - apart from anything else - make them less liable to errors from the fallible human element.