The legal functions in this group are concerned with converting data from one form to another within the working store.

**Function-number [1010 000]**

(See also Section 4.4.6)

In the description of the effects of this function, the following notation is used, in addition to that specified in Section 0.4.

x_{i} - the i-th character in the word
x; i=0(1)7

y_{i} - the i-th character in the word
y; i=0(1)7

n -
contents of a register in the arithmetic unit.

d_{i} - the value of the l.s. 4 bits of
x_{i
}G_{i} - the m.s. 2 bits of x_{i
}r_{i} - the value of the l.s. 4 bits of
y_{i
}T_{i} - the m.s. 2 bits of y_{i}

F - denotes a failure; the Monitor Routine is entered and the failure is regarded as being caused by an impermissible operand (see 5.2).

3-address: z'
= r_{7}(r_{6}(.....(r_{1}(r_{0}z+d_{0})+d_{1})+....)+d_{7
}2-address; x' = r_{7}(r_{6}(.....(r_{1}d_{0}+d_{1})+d_{2})+...)+d_{7}

OVR will be set if the binary integer would exceed single-length capacity. This cannot happen from a single 2-address 100-instruction but may happen if using two 100-instructions as in the example later in this section. Given a number, as 6-bit characters, in X, convert it to a binary integer according to radices set in Y, writing the result into Z or X. In 3-address form the initial content of Z is taken into account in forming the binary integer but not in 2-address form.

In essence, the function operates as follows:- in
3-address form z is copied into a register in the A.U.; in 2-address form this
register is cleared. The content of
this register is then multiplied by r_{0}, the value of the l.s. 4 bits
of character y_{0}. To the
result is added d_{0}, the value of the l.s. 4 bits of character x_{0}.
Then this result is in turn multiplied by r_{1}, and d_{1}
added. This process of
multiplication and addition is repeated until all characters have been dealt
with.

Since the radices r_{i} are set by program,
the 100-instruction permits conversion of mixed-radix data.

It should be noted that the arithmetical processes involved require that, in the chosen internal code, the digits 0, 1, 2, ...., 11 shall be such that the values of their l.s. 4 bits shall be the value of the digit, e.g. 7 must have 0111 as its l.s. 4 bits.

The various T_{i}, the m.s. 2 bits in each
radix character, are used to prescribe checks and special actions to be made
concerning the G_{i}, the m.s. 2 bits of the appropriate
datum-character; namely:-

If
T_{i} is

(i) 00,
perform conversion if G_{i} is 00 or 01

(ii) 01,
perform conversion if G_{i} is also 01

(iii) 10, perform
conversion regardless of G_{i
}(iv) 11,
perform conversion regardless of G_{i} and also treat
d_{i} as zero.

Also, in cases (i), (ii) and (iii) a
check is made that d_{i} < r_{i}.
Failure to satisfy any one or more of these checks leads to an
‘impermissible operand’ interruption followed by entry to the monitor
routine.

(A flow-diagram of the full process is given on page 4 of this section.)

These checks are designed primarily to facilitate reading from punched cards. In fact, the 100-function is suitable only for fixed-format data; it should not be used for variable-format data.

Referring to section 4.4 pp 2, 3
and 4, it is seen that if a single hole is punched in a card column (usually
representing a digit 0 to 9 in the card code) then the v (or x_{i})
character formed on reading that column has the value of d_{i} equal to
the number of the row punched while G_{i} is made 01.
Thus, if this character is converted by a radix character with T_{i}
= 01, a check is made that there is one hole, and only one, in rows 0 to 9 of
the card, i.e. that the punching represents a decimal digit. If the punching may be a single hole in any row (i.e. a
duodecimal digit) then G_{i} will be 00 (if rows 10 or 11 punched) or 01
(if single punching in rows 0 to 9) and, to convert and check, T_{i}
should be 00.

T_{i}
= 11 may be used to ignore non-numerical characters within the fixed format.

The
various possible T_{i}, namely 00, 01,10 and 11 may be set on program
input by adding 0, 16, 32 and 48 respectively to the value of r_{i}.
Thus, to set r_{i} = 10 and T_{i} = 01, the character y_{i}
can be written as 26 or as 10+16.

If the characters to be converted are in a single word and if the programmer is prepared to overwrite them by the binary integer then a 2-address 100-instruction can be used. If the characters occupy more than one word or if the characters must not be overwritten, the 3-address form should be used (in the latter case, Z must first be cleared to zero). Thus, suppose that a sterling quantity has been read, in character form into A100 and A101, the m.s. characters being in A100. To produce a single-length binary result when converted to pence, the sum must not exceed £586406201480/10/7 of which the first 7 digits (up to 5864062) may be right-justified in A100, and the last 5 digits of £ together with two digits for shillings and one for pence may be in A101.

To convert this sum to binary pence, the following instructions may be used:

14 ACC 0

100 A100 RAD1 ACC

100 A101 RAD2 ACC

with the radices

RAD1) 10, 10, 10, 10, 10, 10, 10, 10

RAD2) 10, 10, 10, 10, 10, 2, 10, 12

ignoring any checking requirements.

The first instruction clears an accumulator, ready to receive the result of the first 100-instruction, which converts the m.s. digits of £'s as an ordinary decimal number. The second 100-instruction completes the decimal conversion of the £'s and then carries out the mixed-radix conversions to shillings and pence successively. (If the m.s. data-characters are in an accumulator, the first instruction is not necessary and the second can be 2-address.)

**Function Number 101 [1010
001]**

In the description of this function-number, the following notation is used, in addition to that of Section 0.4.

C_{i}, the complete 6-bit character formed in the inner loop.

f_{i}, the
currently remaining fractional part of the number being converted.

d_{i}, the
value of the l.s. 4 bits of the character formed in the inner loop

r_{i}, the
value of the l.s. 4 bits of the i-th radix-character

T_{i}, the m,s, 2 bits of the i-th radix-character

b, an indicator. Initially clear, this is set when the first significant character is formed.

q, an indicator. It is set if the sign of the number to be converted is not
the same as the sign of y, otherwise it is clear.

3-address: x' = characters resulting from conversion of z according to information
in Y and Y+1.

2-address: x' =
characters resulting from conversion of x according to information in Y and Y+1

Y contains an number by which z (or x) is to be divided (see Examples in Section 10.2 for particular cases). Y+1 contains characters each of which represents one radix and zero-suppression information for the appropriate character. y=0 causes impermissible operand action.

A flow-diagram for the 101-instruction is given on page 7 of this section. Broadly, the operation of this instruction can be described as follows.

The number N to be converted is read from Z or X. If the signs of N and y are not the same, q is set to record the fact. N is then divided by y to give a non negative result and the stored quotient is inverted if q is set. The fractional part is rounded up to 32 binary places.

If the integral part of the quotient is non-zero, OVR and b are set to record the fact that preceding significant digits exist (but will not be produced by this instruction alone).

The fractional
part f_{0} of the quotient is then multiplied by r_{0}. In general the result has an integral part d_{0} and
a fractional part f_{1}. d_{0}
is converted to the appropriate character C_{0} (by adding l6 if d_{0}
≠
0 or by special action if d_{0} = 0), which is stored.
Thereafter f_{1} is multiplied by r_{1}, giving d_{1},
C_{1} and f_{2}; f_{2} is multiplied by r_{2}
and so on until all eight successive characters have been formed.
These are then written away in X.

The effects of the various
possible T_{i} are:-

If T_{i} is 00 a
non-significant zero is converted as: __SP
__If T

If T

If T

These T_{i} are set by adding
0, 16, 32 and 48 respectively to the corresponding radix.
**It should be noted that a zero produced by radix 1 or 2** (radix 1
always produces a zero) is treated as non-significant, even though a significant
digit may have been produced previously.

OVR is set if:-

(i)
|y| ≯
|z| (or |x| if 2-address) i.e. if, when z (or x) is divided by y, the integral
part is non-zero.

(ii) If q
is set (i.e. z_{s} (or x_{s}) ≠
y_{s}) and the character immediately preceding the first significant
digit-character is anything other than SP so that it cannot be replaced by a
minus-sign.

The number in Y is normally the
product of the radices given in Y+1. If
this is not so the effect is to divide the number to be converted by y/Pr_{i}
- though care must be taken if the result is required exactly as the initial
division is only evaluated to 32 binary places.
For examples of this use of the 101-instruction see section 10.2.

Note that if one of x or y is negative and no significant digit is stored than the result is undefined.

**Function Number 102 [1010
010]**

3-address:
z_{G}' = x_{F}.2^{Y}
2-address: x_{G}'
= x_{F}.2^{Y}

Convert a fixed-point number to
floating-point form; multiply the fixed-point fraction in X by 2^{Y}, Y
being treated as signed, and convert the result to standard single-length
floating-point form, writing it into Z or X.
The conversion may be rounded or unrounded (see section
5.2.5). Floating-point overflow will occur if the result is
numerically too large (see section 5.2.3) and underflow if the result is
numerically too small (see 3.9).

Y may be regarded as a shift-number and is formed according to the rules given in section 3.5, page 3.

The fraction x_{F} may
have been produced by some arithmetical operation which set OVR.
If the overflow was of one bit only, the correct result from
102-instruction is still obtained, as follows.

If, when the 102-instruction is
encountered, OVR is clear, the conversion proceeds normally.
However, if OVR is set then ±2.0
is added to x_{F} before it is standardised, the sign being opposite to
that of x_{F}. The number of places needed to standardise the result
(negative if OVR set) is then subtracted from 128+Y and this result stored as
the exponent (l.s. 8 bits in x_{G}).
Thus it is necessary to ensure that the state of OVR at the instant a
102-instruction is obeyed is the same as its state immediately after the
formation of x_{F}, regardless of what may have happened to OVR in the
meantime. Also, of course,
derivation of x_{F} by multiplication, shifting or division may produce
more than 1 bit of overflow.

OVR is left clear unless z_{G}'
overflows.

**Function Number 103
[1010 011]**

3-address:
z_{F}' = x_{G}.2^{Y}
2-address: x_{F}'
= x_{G}.2^{Y}

Convert a floating-point number
to fixed-point form: multiply the standard single-length floating-point number
in X by 2^{Y}, Y being treated as signed, convert it to a fixed-point
rounded fraction, and write the result into Z or X.

If x is not properly standardised, suspension will occur/due to 'impermissible operand'. OVR will occur if the result is not within single-length range for a fixed-point fraction.

Y may be regarded as a shift-number and is formed according to the rules of section 3.5 page 3.

**Function Number 104 [1010
100]**

Conversion after input from punched-card: given four pairs of characters in X, extract the corresponding four characters in the internal code from a code table starting in Y, then:-

3-address:
z_{u}' = z_{m}, z_{m}
= the four characters formed.

2-address: x_{u}' = 0,
x_{m}' = the four characters formed.

OVR cannot be set.

The main details of the
conversion and sample code-tables are given in section 4.4, pp.7 to 11.
The generation, by hardware, of the four pairs of characters in X is
described in section 4.4 pp.2, 3 and 4. Erroneous
punching will be detected either automatically on reading the card (case (iii)
of section 4.4.3) or by an 'erase' character being extracted from the
code-table to represent the wrongly-punched column.
The latter case can be detected by program by using an 84-or
85-instruction to search for __ER__ in the result of the 104-instruction (by
putting Z=63 in the 84- or 85- instruction).

Suppose that a card has been read in Mode 2 into the store area BUFF to BUFF+19, that the table of section 4.4 p.10 is in TAB to TAB+23 and that it is required to convert the data from columns 1 to 8 to alpha-numeric characters in A7. Then the instructions

104 BUFF TAB
A7

104 BUFF+1 TAB
A7

84 ERROR A7
63

will do this and jump to ERROR if any of these eight columns carried illegal punching.

If these columns represent purely numerical data to be converted to binary it is not necessary to use the 104-instruction, since the stored v characters are directly related to the value of the numerical digit punched. Thus if columns 1 to 8 represent the eight digits of a decimal number (with zeros punched), the number may be converted to binary by

52 BUFF 24
A7

10 A7
(BUFF+1)

100 A7
RAD

with RAD) 10+16, 10+16, 10+16, 10+16, 10+16, 10+16, 10+16, 10+16

an error-interruption occurring if the punching in any column is not confined to a single hole in rows 0 to 9, possibly with punching in rows 10 and 11. Normally, a column punched in both curtates represents a non-numerical character. Consequently this method of conversion, by ignoring the u-characters, may convert non-numerical characters (whether punched legitimately or in error) as numerical characters.

The detailed action of the instruction is as follows:

Bits 2-5 of characters 0 and 4 of x are taken in the order

D26, D27, D28, D29, D2, D3, D4, D5

the first five of these bits are used as the word modifier and the last three as a character modifier, relative to Y. This modifier gives a character from the table which is the first of the four characters formed. The other three characters are formed similarly from characters 1 and 5, 2 and 6, 3 and 7 respectively of x. If x has been read from cards in a coded mode the bottom 4 bits of 0 are guaranteed to have a value less than 12, whatever the punching, so that in this case a 24 word table is sufficient. If x is an arbitrary word, 32 words of table may be needed.

**Function Number 105
[1010 101]**

**Function Number 106
[1010 110]**

**Function Number 107
[1010 111]**

These three function-numbers are unassigned and therefore illegal in any form.