Chapter 4: B-Line Modification and Subroutines

Examples have been given, in the earlier chapters of this guide, in which a programme has been so written that the computer obeys one set of instructions several times. This technique saves storage space and is of value whenever one small part of the calculation needs to be carried out more than once.

This chapter describes methods whereby this can still be done when either

  1. There must be some slight change in the instructions each time the set is used.
  2. The set is to be used on odd occasions during the course of a long calculation, rather than several times together.

B-Line Modification

Instances frequently occur in which the computer is required to carry out, several times, an action which is much the same at each repetition, but changes in some small detail each time it is performed. An elementary example is the addition of, say, 100 numbers stored in locations 100 to 199; after clearing the accumulator the functions to be performed are "add C(100)", "add C(101)", "add C(102)" ... "add C(199)". The action here is always "add", the change is an increase in the address of the addend.

Since instructions are stored in the computer in a numerical code, it is possible to cause a number to be added to an instruction, and thereby change or modify it, before it is obeyed. This could readily be done by using a function such as 24, specifying the location holding the instruction to be modified. Better still, in the addition problem considered above, would be function 22; for the addition of 2-38 to the content of a location is tantamount to an increase by 1 of the N in the second instruction therein.

But an automatic facility termed B-line Modification which is an improvement on either of the above is provided, and is as follows:

  1. If the B digit between a pair of instructions is a 0, then no modification takes place, and each instruction is obeyed as stored.
  2. But if the B digit is a 1, then after the first instruction (F1 N1) has been obeyed normally, the second instruction (F2 N2) is modified by the addition of the right-hand part of the (new) content of location N1 before being obeyed.
The modification takes place in the control section, takes no extra time, and does not affect the version of the instruction (F2 N2) held in the store.

When a location (N1) is being used to hold a modifier, it is referred to as a B-line. This term is a legacy from one of the earlier Manchester University computers, in which numbers were represented by lines of dots on a cathode ray tube. The A-line contained the accumulator, and the B-line held the modification, if any, to be made to the next instruction.

There are restrictions on the combined use of B-line modification and transfer instructions, and function 77; these are stated in Appendix 3.

It is conventional to indicate B = 1 by placing a / in the B column rather than writing a 1.

It does not matter what use is made of the N1 digits in the first instruction.

Example 16

If it is desired to have an instruction (F2 N2) modified by the content of location 173, we may write any of the following:

F1 N1 B F2 N2
00 173 / F2 N2
22 173 / F2 N2
50 173 / F2 N2
57 173 / F2 N2
74 173 / F2 N2

In the second instance, where C(173) is altered by function 22, the modification is by the new content

Example 17

A situation is frequently reached, near the end of a calculation, in which the 5 right-hand digits of the accumulator correspond to a telecode character which must be punched on the output tape. The following instruction pair causes the computer to do this:

  20 4 / 74 0
The relevant digits are placed in location 4, and the instruction 74 0 is then modified into the required output instruction before it is obeyed.

But observe that there must be no 1's in the accumulator in the F2 positions: for these would also be placed in location 4, and, when added to the the existing F2, would produce an instruction specifying some function other than 74.

Exercise 12

Verify that, in Example 17, there may be 1's elsewhere in the accumulator (e.g. in the F1 positions, or in the 8 left-hand positions), without spoiling the effect.

Exercise 13

Satisfy yourself by theoretical considerations, or by writing the whole thing out in binary, that

If C(A) is -80 x 2-38 and C(238) is S, before the computer obeys

  10 238 / 04 200
then afterwards C(A) = S + C(120)

and C(238) = -80 x 2-38

This is employed below.

Example 18

The following programme adds together 100 items, namely the contents of locations 100 to 199 inclusive, and exits with the sum in location 238. It is entered at the first instruction of location 240. (It is assumed that the sum is within capacity).

Address Instructions
F1 N1 B F2 N2
238 Count location and total store
239 -100   Count constant
240 26 238 30 239 Set total to zero: replace -100
241 10 238 / 04 200 Set count: add an item
242 12 238 41 241 Count: test for end
243 Next part of programme.

Note how the powerful "exchange" functions 10 and 12 are used. They enable the total-to-date and the count to be switched between location 238 and the accumulator. Without such functions it would be neccesary to allocate separate locations for the count and the total, and there would be more instructions in the loop.


Suppose that, during a lengthy calculation, it is neccesary to find square roots of several numbers. The need would then arise for the computer to carry out the functions of Example 12 several times, and that a considerable saving in storage requirements could be achieved by arranging that the same set of instructions is used each time, rather than having several sets, each to be used once.

This technique can be applied to any small section of programme which is designed to fulfil a standard requirement, and such sections of programme are termed subroutines. Several are available in the Elliott 803 Library of Programmes: these include, in addition to subroutines which form algebraic and trigonometrical functions of numbers, others which read numbers from the input tape or punch numbers on the output tape, carrying out the neccesary decimal-to-binary or binary-to-decimal conversion.

As far as is practicable, each subroutine is written to conform to the following standard:

  1. The first location, location p say, is spare.
  2. The entry point is location p + 1.
  3. The exit location contains the instruction pair
      00 p / 40 1
  4. If the purpose of the subroutine is to calculate the function of some number, that number must be in the accumulator at the time at which the subroutine is brought into use, and the function is in the accumulator when the subroutine exits.

The main programme and its subroutine(s) are placed in different parts of the store. Wherever it is required to employ the subroutine, an instruction pair of the following form is written in the main programme:

Address Instructions
F1 N1 B F2 N2
z 73 p   40 p+1  
z+1 Next part of main programme.

This causes the link, the "instruction" 00 z, to be placed in the spare location in the subroutine, and transfers to its entry point. When the subroutine has been obeyed, the exit instructions

  00 p / 40 1
are obeyed as "transfer to location z+1", i.e. to the next part of the main programme.

To appreciate the value of this in programming, consider again the case in which several square roots must be found during a calculation. Provided steps are taken to see that the neccesary subroutine is in location p upwards, the instruction pair

  73 p  
40 p+1
may be written as many times as is neccesary, and be regarded as the equivalent of one instruction "form the square root of C(A)". It is customary to underline each instruction which specifies a transfer to a subroutine.

This technique is employed even when a subroutine is used once during a calculation. For, by doing so, the need to have different versions of each subroutine is avoided, and so is the clerical effort of copying the instructions into the middle of a new programme.

Detailed examples are given in the next chapter.

Previous Chapter Contents Next Chapter