# Jump Over Left Menu

### 7. EXTRACODE INSTRUCTIONS

#### 7.1 Introduction

The basic instructions consist in just those simple operations which the computer has been designed to execute directly. In the Atlas order-code, however, there are many complicated operations which the computer deals with in a special way; these are known as extracodes and are distinguished from the basic instructions by having a 1 in f0, the most-significant bit of the 10-bit function number. Upon encountering an instruction with f = 1, there occurs an automatic entry to one of many built-in subroutines, the choice being determined by the remaining three octal digits of the function number. The exit from the subroutine is again automatic, and the program proceeds in the usual way with the instruction next after the extracode, unless the extracode subroutine has initiated a jump.

##### 7.1.1 Uses of the Extracode Instructions.

As their name implies, the extracodes provide an extension of the basic order-code, including both those complicated operations which are excluded from the basic instructions, and many of the facilities which on previous machines have been obtained by the use of library subroutines.

Amongst the arithmetic instructions provided by extracodes we may instance those in which the address, interpreted as a floating-point number, is used as an operand; double-length operations; and a full range of elementary functions such as logarithm, square-root, sine etc.

An important group of extracodes deals with the special requirements of input and output and also of magnetic tape transfers; the uses of these will be discussed at some length in Chapters 8 and 9.

The organisational extracodes comprise extensive facilities designed to assist the programmer in making efficient use of the operating system of Atlas. The various aspects of this are described in later Chapters (particularly Chapters 11 and 12).

7.1.2 To the programmer, extracode instructions appear as basic instructions. The two types of instruction can be freely intermixed, and after each instruction control passes sequentially to the next (except for jump instructions). It is therefore not strictly necessary to know how the computer deals with extracode instructions, although this is given for completeness in the next section.

There are 512 function numbers available for extracodes, 1000-1777. Of these, 1000-1477 are singly-modified instructions (B-type) and 1500-1777 are doubly-modified instructions (A-type). In some of the B-type instructions, bm is used as an operand so no modification takes place.

#### 7.2 The Logical Interpretation of Extracode Instructions

When an extracode instruction is encountered the following action place:-

1. The content of Main control, b127, is increased by one to the address of the next program instruction.
2. The address is modified according to the type (i.e. N + bm for B-type, N + ba + bm for A-type) and the result stored in B119.
3. The seven Ba digits are placed in bits 15-21 of B121, unless Ba is B122 in which case B121 is left unchanged; this enables B122 to be used to specify a B-register in extracode functions exactly as in basic functions.
4. The function digits f1 - f9 are placed in extracode control, B126, as shown below.
```Bit   0    1-9    10 11 12 13 14 15 16 17 18 19 20 21-23
Value 1 000000000 f1 f2 f3 0  0  f4 f5 f6 f7 f8 f9  000
```
5. Control is switched from Main (B127) to extracode (B126).

The next instruction to be obeyed is now in the fixed store, under extracode control, at a location determined by the function digits. It is in one of 64 registers (given by f4-f9) in one of 8 tables at intervals of 256 words (given by f1-f3). The tables of 64 registers are called jump tables. In general this instruction will be an unconditional jump into a routine which performs the required function. These routines are permanently stored in the fixed-store and written in normal basic instructions. Each routine terminates with an instruction in which f1 = f3 = 1 in the function number. This is obeyed as if f1 = 0 and then control is switched back to main control (e.g. 521 is equivalent to 121 followed by extracode exit). The next instruction to be obeyed is then the one whose address is in B127; if no jump has been initiated by the extracode this instruction will be the one immediately following the extracode instruction.

The routines that perform extracodes can use B-registers 91 to 99 inclusive and always use B119, B126, and B121 (unless Ba = 122).

Examples:

1. Extracode 1714 is defined as am' = 1/s

Replace the numbers in locations 100 to 105 by their reciprocals.

```    121    1     0     5        set modifier count
2)1714   0     1     100      am' = 1/s
356    0     1     100      store
203    127   1     A2       count
```

Each time the extracode instruction is encountered b127' = b127 + 1, b121' = 0, b119' = 100 +b1 + b0, b126' = J40034140 = +1804J4 and control is switched to B126. The instruction in the jump table is

```    121    126   0     A14
```

The instructions at A14 are

```    334    0     0     A96      set am = +1
774    0     119   0        374 division 1/s, then reswitch to
main control.
96)+1
```

2. Extracode 1341 is defined as bat = ba.2n (arithmetic shift up) Shift b16 up by 2 more than the integer in B17

```    1341   16    17    2
```

This instruction sets b121' = 16D1, b119' = 2 + b17, etc. (Note that b16 is not added to b119 because 1341 is a singly-modified (B-type) extracode).

3. Shift the contents of B20 to B47 inclusive up by 5 places.

```    121    121   0     20D1     set modifier count
1)1341   122   0     5        shift. As Ba = B122, b121 is left
unchanged when the extracode is
entered.
172    121   0     47D1     bt' = b121 - 47D1
220    127   121   A1       If bt ≠ 0, b121' = b121 + 0.4
and b127' = A1
```

Example 3 illustrates the use that can be made of B121 and B122 in extracodes; this is the same as their use in basic instructions except that extracodes with Ba ≠122 will overwrite B121.

#### Allocation of Functions

The extracodes are divided into sections as shown below, though there are a few functions which do not fit into this pattern. References are given for those subjects described in this chapter.

Function Subjects Reference
1000-1077 Magnetic tape routines, and Input and Output routines.. --
1100-1177 Organisational routines. --
1200-1277 Test instructions and 6-bit character operations 7.6, 7.5.2
1300-1377 B-register operations. 7.5.1
1400-1477 Complex arithmetic, vector arithmetic and miscellaneous B-type accumulator routines. 7.4.6,7.4.7
1500-1577 Double-length arithmetic and accumulator operations using the address as an operand. 7.4.4, 7.4.5
1600-1677 Logical accumulator operations and half-word packing. 7.5.3, 7.4.8
1700-1777 Arithmetic functions (log, exp, sq.rt., sin, cos, tan, etc.) and miscellaneous A-type accumulator operations. 7.4.1, 7.4.2, 7.4.3

Not all of the 512 extracode functions have been allocated and, where convenient, constants and extracode programs have been packed into the vacant jump-table locations.

This means that the use of an unallocated extracode function may result in an unassigned function interrupt or may cause some extracode to be entered incorrectly. The latter case would give the programmer wrong results.

In particular, the first location in the fixed store, J4, contains the floating-point number ½. This causes an unassigned function interrupt if extracode 1000 is encountered, since J4 is the first register of the first jump-table. Note that floating-point zero is equivalent to the instruction

```    1000   0     0     0
```

There follows a description of many of the extracodes. Where possible, the actual number of basic instructions obeyed in each extracode routine is given in the right hand column.

Appendix 3 gives an ordered summary of all the extracodes, for easy references.

#### 7.4 The Accumulator Extracodes

##### 7.4.1 The Most Used Arithmetic Functions

The following routines each have two extracode numbers. The first operates on s, which is standardised on entry. The second operates on a, which is standardised, rounded and truncated to a single-length number on entry. For this number we use the notation aq. The results are always standardised rounded numbers in Am.

Function Description Notation
1700 Place the logarithm to base e of s in Am am' = log s
1701 Place the logarithm to base e of aq in Am am' = log aq
1702 Place the exponential of s in Am am' = exp s, 43
1703 Place the exponential of aq in Am am' = exp aq, 42
1710 Place the square root of s in Am am' = +sqrt(s) ≤, 42
1711 Place the square root of aq in Am am' = +sqrt(aq) ≤, 41
1712 Place the sqaure root of (aq2 + s2) and place this in Am am' = +sqrt(aq2 + s2) ≤, 50
1720 Place the arc sine of s in Am (am' is in radians, with -π/2 ≤ am' ≤ +π/2) am' = arc sin s
1721 Place the arc sine of aq in Am (am' is in radians, with -π/2 ≤ am' ≤ +π/2) am' = arc sin aq
1722 Place the arc cosine of s in Am (am' is in radians, with 0 ≤ am' ≤ +π) am' = arc cos s
1723 Place the arc cosine of aq in Am (am' is in radians, with 0 ≤ am' ≤ +π) am' = arc cos aq
1724 Place the arc tangent of s in Am (am' is in radians, with -π/2 < am' < +π/2) am' = arc tan s
1725 Place the arc tangent of aq in Am (am' is in radians, with -π/2 < am' < +π/2) am' = arc tan aq
1726 Divide aq by s and place the arc tangent of this number in Am. am' is in radians and such that -π < am' ≤ +π am' = arc tan (aq/s)
1730 Place the sine of s in Am (s in radians) am' = sin s, 41
1731 Place the sine of aq in Am (aq in radians) am' = sin aq, 40
1732 Place the cosine of s in Am (s in radians) am' = cos s, 42
1733 Place the cosine of aq in Am (aq in radians) am' = cos aq, 41
1734 Place the tangent of s in Am (s in radians) am' = tan s, 34
1735 Place the tangent of aq in Am (aq in radians) am' = tan aq, 33
##### 7.4.2 Other Floating-Point Arithmetic Functions
Function Description Notation Instructions
1704 Place the integer part of s in A a' = int pt s QE 5
1705 Place the integer part of a in A a' = int pt a QE 4
1706 Set a' = +1, 0 or -1 as s >, =, or < zero a' = sign s Q 5-6
1707 Set a' = +1, 0 or -1 as a >, =, or < zero a' = sign a Q 4-5
1713 Raise aq to the power s and place the result in am, provided that aq ≥ 0, Fault if aq < 0 am' = aqs QRE
aq ≥ 0
1714 Place the reciprocal of s in Am am' = 1/s QREDO 4
1715 Place the reciprocal of am in Am am' = 1 / am QREDO 4
1754 Round am by R+, clear L and standardise am' = a, l' = 0 QR+ 6
1756 Interchange the contents of S and Am (with no standardising) am' = s, s' = am 8
1757 Place the result of dividing s by am in Am am' = s / am QREDO 4
1760 Square the contents of Am am' = am2 QRE 3
1774 Divide am by s and place the result in Am. The original numbers need not be standardised am' = am / s QREDO 10
1775 Divide aq by s and place the result in Am. The original numbers need not be standardised am' = aq / s QREDO 9

1774 and 1775, besides providing a division instruction which operates on unstandardised numbers, store information which enables extracodes 1776 and 1407 to calculate a quotient and remainder.

Function Description Notation Instructions
1776 When used after division extracodes 1774, 1775, 1574 or 1575, with no other extracodes in between and am unaltered, the definition of 1776 is as follows:
Place the quotient of the previous division in s and the remainder in Am, where the remainder has the sign of the divisor
s' = quotient QREDO
am' = remainder
13
1407 As 1776 except that the quotient is integral and is adjusted according to the sign of the remainder, which is specified by Ba as follows:
```
Ba   Sign of remainder
O    Same as the denominator
1    Opposite to the denominator
2    Same as the numerator
3    Opposite to the numerator
4    Same as the quotient
5    Opposite to the quotient
6    Positive
7    Negative
```
s' = adjusted intregral quotient QEDO
am' = remainder
1467 Evaluate the polynomial s0 + s1.am + s2.am2 + ... sba.amba where s0 is the number at S, s1 at S+1, etc and the order of the polynomial is given as an integer in Ba. am' = Σ sr.amr from r=0 to r=ba
where Sr = S + r QRE
6 + 3 ba
1466 Multiply the two numbers at addresses (N+ba+bm) and (N+bm) and add the double-length result into the full accumulator. Rounding takes place near the least-significant end of L. (In detail, when the double-length product has been formed, its least-significant half is first added in M to the least-significant half of the original contents of A. This addition is rounded. The rest of the product and the original contents of M are then added into A without rounding). a' = a +
C(N+bm) ×
C(N+Ba+bm) QE
18

Extracode 1415

Generate pseudo-random numbers (PRN's) in A and S (or S*) from numbers in S and S*. This extracode may be used in several ways.

1. With digit 21 of S equal to 0, the PRN is placed in S and A.
1. If s*y = 0, sx > 0 and s*x > 0, then s' will be a PRN in the range 0 to 8sy , rectangularly distributed and fixed-point (i.e. sx' is a fixed-point PRN and sy' = sy). a' will be a PRN in the range 0 to s*x.8sy (with al' = s').
2. If s*y = 0, sx < 0 and s*x < 0, then as (a) except that ranges become -8sy to 0 and -s*x.8sy-1 to 0 respectively.
3. If s*y = 0 and s*x > 0, then as (a) except that the PRN's alternate in sign.
2. With digit 21 of S = 1, the PRN's are generated in S* and A instead of S and A. The cases are as for 1, interchanging S and S* throughout.
3. 3. Two successive uses of the extracode, with digit 21 of S first = 0 and then = 1, and with sy = s*y = 0, will set PRN's in S end S*, both rectangularly distributed in the range 0 to 1. A will contain the product of two PRN's and so will be distributed in the range 0 to 1 with the probability -log xdx of being in the neighbourhood dx of x.

In all cases the generation process must be started with Sx Iand S*x containing numbers with a random mixture of binary digits, but with their least-significant bits set to 1.

##### 7.4.3 Accumulator functions suitable for Fixed-Point Working
Function Description Notation Instructions
1752 Shift ax up 12 octal places and subtract 12 from ay m' = ax.8-12
ay' = ay -12 AO
10
1753 Shift m down 12 octal places in ax and increase ay by 12 ax' = m.8-12
ay' = ay +12 AO
6
1755 Force ay to the number ny given in bits 0-8 of n, shifting ax up or down accordingly ax' = ax.8ay - ny
ay' = ny AO
17
1762 Shift ax up 12 octal places leaving ay unchanged m' = ax.812
ay' = ay AO
9
1763 Shift m down 12 octal places in ax leaving ay unchanged ax' = m.8-12
ay' = ay AO
5
1764 Shift ax up n octal places leaving ay unchanged. If n is negative, shift ax in the opposite direction. ax' = ax.8n
ay' = ay AO
17
1765 Shift ax down n octal places leaving ay unchanged. If n is negative, shift ax in the opposite direction. ax' = ax.8-n
ay' = ay AO
12
1766 Place the modulus of s in Am, without standardising. Accumulator overflow will occur if s is -1.0 am' = |s| AO 4
1767 Place the modulus of am in Am, without standardising. AO will occur if am is -1.0 am' = |am| AO 3
1772 Multiply m by sx, shifting the result up by 12 octal places to be in M, and subtracting 12 from ay m' = (m.sx)812
ay' = ay + sy -12 AO
11
1773 Divide a by s, and force ay equal to 12, shifting the result, which is in M, if necessary m' = (ax/sx).8ay - sy - 12
ay' = 12 AO
27
1452 Multiply am by s, forming the answer in Ax. Force ay to the number given in digits 0-8 of ba, and shift ax accordingly ax' = m.sx.8ay + sy - bay
ay' = bay AO
19-23
1473 Divide ax by sx, forming the answer in Ax. Force ay to the number given in digits 0-8 of ba, and shift ax accordingly ax' = (ax / sx).8ay - sy - bay
ay' = bay AO
24-28

Fixed-Point Divisions with remainder

The three extracodes 1474, 1475 and 1476 each divide some part of the accumulator by the contents of store location S, placing an unstandardised quotient q in the location whose address is ba and leaving an unstandardised remainder r in Am. In all cases, r retains the original sign of am and has a mantissa in the range 0 ≤ |rx| < |sx|. The quotient is rounded towards zero. Division overflow is set if sx = 0 or -1.0 or if |sx| ≤ |mantissa of dividend|. Both DO and AO are set when the mantissa of the dividend is equal to -1.0.

If only the remainder is required, one can avoid the need to set ba by putting Ba = B126 in the extracode instruction.

Function Description Notation Instructions
1474 Divide am by s. The exponent of q and r are given by qy = ay - sy and ry = ay -13 C(ba)' = quotient (am/s)
am' = remainder (am/s) DO AO E
20-29
1475 Divide a by s. The exponent of q and r are given by qy = ay - sy and ry = ay -13 C(ba)' = quotient (a/s)
am' = remainder (a/s) DO AO E
19-28
1476 Divide the integral part of am by s. The exponents of q and r are forced to qy = 24 -sy and ry = 12. the condition |am| < 824 |sx| must be observed, otherwise division overflow will occur and the results will be meaningless. The least-significant octal digit of q is always zero, and it is intended that usually sy = 12 so that qy = 12 also and one is working with integers. In the case ay ≤ -6 and am < 0, this extracode must be preceded by 217, 124, 124, 0 to ensure the true integral part is used.) C(ba)' = (q int pt am)/s
am' = r (int pt am / s)
AO DO E
28-37
##### 7.4.4 Double-Length Arithmetic

The double-length number s: is stored in two consecutive locations s and s + 1 as two standardised floating-point numbers, where sy ≥ s*y. s* and al are assumed to be always positive. All arithmetic is standardised, rounded and checked for exponent overflow.

Function Description Notation Instructions
1500 Add s: to a a' = a + s: 10
1501 Subtract s: from a a' = a - s: 10
1502 Negate a and add s: a' = -a + s: 14
1504 Copy s: into a a' = s: 4
1505 Copy s: negatively into a a' = -s: 3
1542 Multiply a by s: a' = a.s: 15
1543 Multiply a negatively by s: a' = -a.s: 19
1556 Store a at S: s:' = a 5
1565 Negate a a' = -a 5
1566 Form the modulus of a a' = |a| 4-6
1567 Copy the modulus of s: into A a' = |s:| 5
1576 Divide a by s: a' = a/s: 19
##### 7.4.5 Arithmetic Using the Address as an Operand

The modified address is taken as a 21-bit integer with an octal fraction. Fixed-point operations imply an exponent of 12.

Function Description Notation Instructions
1441 Store ba in S as a fixed-point number sx' = ba, sy' = 12 5
1520 Add n to am am' = am + n QRE 10
1521 Subtract n to am am' = am - n QRE 9
1524 Place n into a a' = n Q 8
1525 Place n negatively into a a' = -n Q 7
1534 Place n into a, without standardising a' = n 10
1535 Place n negatively into a, without standardising a' = -n 9
1562 Multiply am by n am' = am.n QRE 8
1574 Divide am by n am' = am/n QRE 16
1575 Divide aq by n am' = aq/n QRE 15

After 1574 and 1575, the extracodes 1776 and 1407 can be used to give a remainder and adjusted integral quotient. See section 7.4.2.

##### 7.4.6 Complex Arithmetic

The complex accumulator Ca is taken as a pair of consecutive registers, the address of the first one given by the contents of Ba in the instruction. If Ba is B0, Ca will be locations 0 and 1. As with the double-length arithmetic, s: is a number pair consisting of the two numbers at addresses S and S + 1. For Ca and S:, the real part of the number is in the first location, the imaginary part in the second. Ca may coincide with S: if desired, but the two must not partially overlap, i.e. the difference between ba and S must not equal 1. The accumulator is used for the arithmetic so its original contents on entry are spoiled. All arithmetic is standardised, rounded and checked for exponent overflow.

Function Description Notation Instructions
1400 Place the logarithm of s: in Ca ca' = log s:
1402 Place the exponential of s: in Ca ca' = exp s: 140
1403 Place the conjugate of s: in Ca ca' = conj s: 5
1410 Place the square root of s: in ca ca' = +sqrt(s:) ≤117
1411 Place the argument of s: (radians) in Am am' = arg s:
1412 Place the modulus of s: in Am am' = mod s: ≤53
1413 Form the number s cos s*, s sin s* and place these in Ca. (s* is in radians.) ca' = s.cos s*, s.sin s* 95
1414 Place the reciprocal of s: in Ca ca' = 1 / s: 15
1420 Add s: to ca ca' = ca + s: 8
1421 Subtract s: from ca ca' = ca - s: 8
1424 Copy s: into Ca ca' = s: 6
1425 Copy s: negatively into Ca ca' = -s: 6
1456 Copy ca into S: s:' = ca 5
1462 Multiply ca by s: ca' = ca.s: 18

Note: 1400 - the imaginary part of the complex logarithm will lie in the range - π (not inclusive) to π (inclusive).

1410 - of the two possible values of the complex square root, the one computed here has a non-negative real part; the remaining ambiguity about the square roots of negative real numbers is removed by computing the one whose imaginary part is positive.

##### 7.4.7 Vector Arithmetic

The following instructions operate on two vectors s1 and s2. Both vectors consist of lists of floating-point numbers stored in successive locations. In each instruction the singly-modified address n gives the number of terms in the vectors (i.e. the order) and Ba gives the starting address of s1. The next B-register after Ba, Ba*, gives the starting address of s2. Address n must be a positive integer.

Besides their uses in vector and matrix arithmetic, these instructions can be used to manipulate lists of numbers in the store.

The accumulator is used in the arithmetic so its original contents on entry are lost. All operations are standardised rounded and checked for exponent overflow.

Function Description Notation Instructions
1430 Add the vector s2, which consists of n successive numbers starting at C(ba*) into the vector s1, which consists of n successive nunbers starting at C(ba). s1' = s1 + s2 9 + 4n
1431 Subtract s2 from s1 s1' = s1 - s2 9 + 4n
1432 Multiply each term of s2 by am and store the resultant vector at s1 s1' = am.s2 10 + 4n
1433 Multiply s2 by am and add this to s1 s1' = s1 + am.s2 10 + 5n
1434 Copy s2 to s1 s1' = s2 10 + 3n
1436 Form in Am the scalar product: s1 0.s2 0 + ... + s1 (n-1).s2 (n-1), where s1 0, s1 1 ... s1 (n-1) are the numbers in s1 and s2 0, s2 1 ... s2 (n-1) are the numbers in s2 a' = Σ s1 i.s2 i, i=0,n-1 10 + 13n
1437 As 1436 but forming the scalar product to double-length accuracy in a a' = Σ s1 i.s2 i, i=0,n-1 10 + 13n
##### 7.4.8 Half-Word Packing

Half-word floating-point numbers consisting of 8-bit exponents and 16-bit mantissae are sometimes useful for low-accuracy calculations where it is necessary to reduce store usage.

Function Description Notation Instructions
1624 Transfer the floating-point number at S into the accumulator, without standardising a' = s R 6
1626 Copy ay and the 16 most-significant digits of ax into S after rounding this number in Am by forcing a one in its lowest bit if the rest of ax is non-zero s' = am R 8

#### 7.5 B-Register Arithmetic

##### 7.5.1 General B-Register Operations
Function Description Notation
1300 Place in Ba the integral part of the floating-point number s. Place the fractional part in Am. ba' = int pt of s
am' = frac pt of s
1301 Place in Ba the integral part of am. Place the fractional part in Am. ba' = int pt of am
am' = frac pt of am

The following six instructions provide integer multiplications and division of ba by n.

For 1302 - 1304, ba and n are interpreted in the normal way as 21-bit integers with a least-significant octal fraction. In the multiplication instructions octal fractions are rounded away from zero, and overflow of the answer is not detected. The accumulator is used in the calculation, but am is preserved.

Function Description Notation Instructions
1302 Multiply ba by n and place the result in Ba ba' = ba × n 23-24
1303 Multiply ba negatively by n and place the result in Ba ba' = - ba × n 22-23
1304 Divide ba by n. Place the integer quotient in Ba and the remainder, which has the sign of the dividend, in B97. ba' = int pt (ba / n)
b97' = remainder
25-28

For 1312-1314, ba and n are interpreted as 24-bit integers, and the result is again a 24-bit integer.

Function Description Notation Instructions
1312 Multiply ba by n and place the result in Ba ba' = ba × n 23-24
1313 Multiply ba negatively by n and place the result in Ba ba' = - ba × n 22-23
1314 Divide ba by n. Place the integer quotient at the least significant end of Ba and the remainder, which has the sign of the dividend, as a 24-bit integer in B97. ba' = int pt (ba / n)
b97' = remainder
25-28

The following six instructions provide general n-place shifts of numbers in B-registers.

In arithmetic shifts, the sign digit is propagated at the most-significant end of the register for shifts to the right (i.e. down).

In logical shifts the sign digit is not propagated.

For both arithmetic and logical shifts the result is unrounded on shifts down. In circular shifts, digits shifted off the most-significant end of the register reappear at the least-significant end and vice-versa. n is an integer in bits 0-20 as usual, with no octal fraction. (If n has an octal fraction the answer may be wrong by a shift of one place). In each case, if n is negative a shift of n places in the opposite direction occurs.

Function Description Notation Instructions
1340 Shift ba arithmetically to the right by n places ba' = ba.2-n 10-22
1341 Shift ba arithmetically to the left by n places ba' = ba.2n 9-21
1342 Shift ba circularly to the right by n places ba' = ba.2-n
circular shift
10-19
1343 Shift ba circularly to the left by n places ba' = ba.2n
circular shift
9-18
1344 Shift ba logically to the right by n places ba' = ba.2-n
logical shift
10-21
1345 Shift ba logically to the left by n places ba' = ba.2n
logical shift
9-20

The following are miscellaneous arithmetic instructions on half-words and index registers.

Function Description Notation Instructions
1347 Perform the logical OR operation on ba and s and place the result in S s' = ba or s 5
1353 Set B123 by writing n to it, and read the result to Ba. This sets ba equal to the position of the most significant 1 bit in bits 16-23 of n. (B123 is described in Chapter4.) b123' = n, then ba' = b123 5
1356 Set the B-test register as the result of non-equivalencing ba and s bt' = ba neqv s 7
1357 Set the B-test register as the result of non-equivalencing ba and n bt' = ba neqv n 5
1376 Set the B-test register as the result of collating ba and s bt' = ba & s 5
1377 Set the B-test register as the result of collating ba and n bt' = ba & n
1364 Preserve the digits of Ba where there are zeros in n and copy digits from Bm into Ba where there are ones in n ba' = (ba & z) or (bm & n)
where z is n with bits inverted
[also b119' = (ba neqv bm) & n]
4
1371 Dummy extracode to set up b121 and b119 b121' = ba
b119' = N + bm
1771 Dummy extracode to set up b121 and b119 b121' = Ba
b119' = N + ba + bm
##### 7.5.2 Character Data Processing
Function Description Notation Instructions
1131 Search for s in table starting at C(ba). If s can be found, ba' will record its address, otherwise the sign bit of ba' will be set to 1. Main control is re-entered at c' = c + 2, and C(c + 1) is used to specify parameters k, l, m as shown below. Up to l + 1 half-words are scanned, starting with C(ba) and continuing at intervals of k half-words, each being masked with m before comparison with s.
```bits    0-9    10-20   21-23   0-23
k       l     spare    m
interval count           mask
```

In the following two instructions S is taken as a character address, the octal fraction giving the address of the 6-bit character within the word.

Function Description Notation Instructions
1250 Place the character s in the least-significant 6 bits of Ba and clear the other digits of Ba. ba' = char s 7-10
1251 Copy the character from the least-significant 6-bits of Ba into the character position at S, leaving the other characters in the word unaltered. s' = char ba 11-18

In the following two instructions ba is interpreted as a character address, and the content of the next B-register, ba*, is interpreted as a half-word address. n is used as a count and its octal fraction must be zero.

Function Description Notation Instructions
1252 Unpack n characters. The n characters, packed in successive character positions starting at C(ba), are placed in the least-significant 6-bits of n successive half-words starting at C(ba*}. The other digits in each half-word are set to zero. 16 + int pt (6.75n)
1253 Pack n characters. Take the n characters stored in the least-significant 6-bits of n successive half-words starting at C(ba*) and pack these into n successive character positions starting at C(ba). 18+5n
##### 7.5.3 Logical Accumulator Instructions

B98 and B99 are used in these instructions as a double-length B-register. This is called the logical accumulator and denoted by G.

Function Description Notation Instructions
1204 Starting at the most-significant end, count the number of 6-bit characters which are identical in g and s, continuing only until the first dissimilar characters are found. Place the result in Ba. 10-31
1265 Shift g up by 6 places, writing overspill to Ba, and add n. ba' = m.s character of g.
g' = 26g + n
11
1601 Copy s into G g' = s 3
1604 Add s into G g' = g + s 7
1605 Add s into G, adding any overflow carry in again at the least-significant end. g' = g + s with end-around carry 12
1606 Non-equivalence s with G g' = g neqv s 4
1607 Collate s with G g' = g & s 3
1611 Replace g by its logical binary complement g' = z where z is the logical complement of g 3
1613 Copy g into S s' = g 3
1615 Copy g into Am, without standardising am' = g 4
1630 Form the logical binary complement of s and collate this with g. g' = g & z where z is the logical complement of s 5
1635 Copy am into G g' = am 4
1646 OR s with G g' = g or s 3
1652 Set Bt by the result of subtracting s from g bt' = g - s 7-9

#### Test Instructions

##### 7.6.1 Accumulator test Instructions
Function Description Notation Instructions
1200 Place n in Ba if the Accumulator overflow (AO) is set. Clear AO. ba' = n if AO is set 9
1201 Place n in Ba if AO is not set. Clear AO. ba' = n if AO is not set 7
1234 Increase main control by 2 (instead of by 1) if am is approximately equal to s. c' = c +2 if am nearly equals s 11
1235 Increase main control by 2 if am is not approximately equal to s. c' = c if am not nearly equal to s 11

For 1234 and 1235, approximate equality is defined as |(am - s) / am| < C(ba)
am must be standardised on entry. By definition, if am = 0 then am is not approximately equal to s.

Function Description Notation Instructions
1236 Place n in Ba if am is greater than zero. ba' = n if am > 0 4-6
1237 Place n in Ba if am is less than or equal to zero. am ≤ 0 3-5
1255 Place n in Ba if m is neither zero nor all ones. ba' = n if m neqv all 1's or all 0's
1727 Depending on whether am is greater than, equal to, or less than s, increase main control by 1, 2 or 3. c' = c + 1, 2, 3 as am >, =, < s 7
1736 Increase main control by 2 if the modulus of am is greater than or equal to s. c' = c+ 2 if |am| ≥ s
1737 Increase main oontrol by 2 if the modulus of am is less than s. c' = c + 2 if |am| < s

In 1234, 1235, 1727, 1736 and 1737 am is preserved but l is not.

##### 7.6.2 B-register Test Instructions
Function Description Notation Instructions
1206 Place n in Ba if the most significant 6-bit character in G is zero 4
1216 Place n in Ba if bm is greater than zero ba' = n if bm > 0
1217 Place n in Ba if bm is less than or equal to zero ba' = n if bm ≤ 0
1226 Place n in Ba if bt is lgreater than zero ba' = n if bt > 0 4-6
1227 Place n in Ba if bt is less than or equal to zero ba' = n if bt ≤ 0 3-5
1223 Place n in Ba if the B-carry digit is set ba' = n if bc = 1 4

The B-carry digit (Bc) is set to 0 or a 1 in the following basic instructions.

```    100   102   104
110   112   114
120   122   124
150   152   164
170   172
```

Bc records the final carry or borrow generated after the addition or subtraction of the most significant digits of the operands.

When the most-significant digit is taken as a sign bit, which is usually the case, Bc is not a true overflow digit. For example, adding -1 or +1 gives 0 and also sets Bc = 1 as there is a final carry. (See Chapter 4).

#### 7.7 Subroutine Entry

Function Description Notation Instructions
1100 Set link in Ba and enter subroutine at s ba' = c + 1, c' = s 6
1101 Set link in Ba and enter subroutine at n ba' = c + 1, c' = n 5
1100 Set link in Ba and enter subroutine at bm ba' = c + 1, c' = bm 6
1362 Set link in B90 and enter subroutine at n. On completion of this extracode, b121' = ba, so that Ba or ba may be used to carry information into the subroutine. b90' = c + 1, c' =n 3

The link set in Ba can be picked up as an exit from the subroutine by the instruction

```    121    127   B%    0
```

where B% is the address of the B-register (Ba) in which the link was set. It is conventional to use B90 for this purpose, and 1362 was provided for that reason.

#### 7.8 Miscellaneous Operations

Function Description Notation
1117 End program. This extracode is used to end a program unless it is monitored by the Supervisor. Certain information about the program is output, and the program cleared from the computer. (see Chapter 11.)
1120 Record the time in Ba, with hours, minutes and seconds each given by two decimal digits specified in four bits apiece, as follows:-
```bits  0-3   4-7   8-11   12-15   16-19   20-23
tens  units  tens   units   tens    units
HOURS        MINUTES        SECONDS
```
ba' = clock
1121 Record the date in Ba, with the day, month and year each given by two decimal digits specified in four bits apiece, as follows:-
```bits  0-3   4-7   8-11   12-15   16-19   20-23
tens  units  tens   units   tens    units
DAY          MONTH           YEAR
```
1124 Set the central computer V-store line 6 to n. The least-significant six bits of V-line 6 are used as follows:-
```bit    Set to 0     Set to 1
18    13 shift     12 shift      on division;
needed to
adjust remainder
for 376, 377
instructions
19    Qs ≥ 0       Qs < 0        Sign of quotient
in basic division
orders
20    AO clear     AO set
21    bt ≥ 0       bt < 0
22    bt = 0       bt ≠ 0
23    Bc clear     Bc set
```
1125 Collate the contents of the central computer V-store line 6 with n, placing the result in Ba. Any digits of v6 may thus be read. ba' = v6 & n