Section 3.4

Group 4

The legal instructions of group 4 are concerned with the division process.  Function-numbers 46 and 47 are unassigned and if encountered, will cause entry to the Monitor Routine, the program being suspended.

The functions numbered 40 to 45 each use two operands.  One of these is the signed 48-bit number y.  The other is either the signed 48-bit number x or the standard double-length number x:.  In all cases x or x: is the dividend (numerator) and y is the divisor (denominator), i.e. the instructions divide x or x: by y.

In all cases if y = 0 the Monitor Program will be entered and the program suspended.

The results occupy either one word or two, depending on the actual function used.  Single word results are written into Z in 3-address form and into X in 2-address form.  Results which occupy two words are written into Z and Z+1 in 3-address form and into X and X+1 in 2-address form.  Nothing should be assumed about the quotient and remainder of a division instruction which overflows.

Function Number 40  [0100 000]

(3)  zI' + (z*I'/yI) = xI/yI;    z*I'/yI < 1

(2)  As 3-address with xI' and x*I' in place of zI' and z*I' respectively.

Unrounded division of integers.  Divide xI by yI, writing the unrounded integral quotient into Z and the remainder into Z+1.  The remainder is always of the same sign as y and numerically less than y.  The quotient and remainder, in 3-address form, satisfy

zI'.yI + z*I' = xI

OVR is set if x is -247 and y is -1.

The results obtained for selected values of xI and yI are tabulated below.

  xI

yI

zI'

z*I'

  +37

 +5

 +7

 +2

  -37

 +5

 -8

 +3

  +37

 -5

 -8

 -3

  -37

 -5

 +7

 -2

    +1

 +5

  0

 +1

    +1

 -5

 -1

 -4

Note also that:-

i) zI' = quotient, z*F' = remainder when xF is divided yF
ii) zF' = unrounded quotient when xF is divided by yI.

Although the remainder is such that it can in turn be divided by y to give the non-negative l.s. half of a double-length quotient it is not necessary to do so, since the 42-instruction gives a result in this form.

Function Number 41  [0100 001]

(3)  zI' = (xI/yI)r or (xF/yF)r;  -½    x/y - zI' < ½

(2)  As 3-address but with xI' in place of zI'.

Rounded division of integers.  Divide x by y, to produce a rounded integral quotient, writing this into Z or X.

The rounding is such that if the rounded quotient is subtracted from the true quotient of xI/yI the difference is numerically less than ½ or equal to -½.**(See below)

** Editors note:  This should be “and greater than or equal to -½”

In fact the rounded quotient is the nearest integer to x/y and is the algebraically greater if x/y is an odd multiple of ½.

The results of some selected cases are tabulated below.

   xI       yI        zI'

  +13       +2        +7

  -13       +2         -6

  +13        -2        -6

  -13       -2        +7

  +37       +5        +7

  -37       +5        -7

OVR is set if x = -247 and y = -1.

Function Number 42  [0010 010]

(3)  z:M' = (xI/yI)r or (xF/yF)r;   e    (x/y) - z:M'  < ½ e

(2)  As 3-address but with x:M' in place of z:M'.

Division with rounded double-length quotient.  Divide x by y to give a mixed-number quotient, writing the signed integral part into Z or X and the non-negative fractional part into Z+1 or X+1.  OVR is set if

       xI = -247 and yI = -1

(or the fractional interpretations of those words).

The results given in some selected cases are tabulated below.

xI

yI

zI'

z*F'

+37

+8

+4

+0.625

-37

+8

-5

+0.375

+37

-8

-5

+0.375

-37

-8

+4

+0.625

+1

+8

 0

+0.125

+1

-8

-1

+0.875

The quotient is rounded to the nearest multiple of 2-47 and to the algebraically greater if the true value of x/y is an odd multiple of 2-48.

Note also that:-
 i)   z:F' = rounded d.l. quotient when xF is divided by yI;
ii)   z:I' = rounded d.l. quotient when xI is divided by yF.

Function Number 43  [0100 011]

(3)  zF' = (xF/yF)r or (xI/yI)r ;  e x/y - zF' < ½ e ,  |x| < |y| or x = -y

(2)  As 3-address but with xF' in place of zF'.

Rounded division of x by y producing a fractional quotient, which is written into Z, or X.  The operands must be such that x is numerically less than y or is equal to -y.  OVR is set if neither of these conditions is satisfied.  If x and y have the same scaling factor (e.g. if both are fractions or if both are integers) than z' is a fraction.

The result is the multiple of 2-47 nearest to the true value of x/y and is the algebraically larger if x/y is an odd multiple of 2-48.

Note also that zI’ = (xI/yF)r

This instruction can be used, following a 44-instruction, to produce a rounded standard double-length quotient when x: is divided by y.

Function Number 44  [0100 100]

(3)  zI' + (z*I'/yI) = x:I/yI ;  0 z*I'/yI < 1

(2)  As 3-address but with xI' and x*I' in place of zI' and z*I'.

Unrounded division with double-length dividend (numerator).

The standard d.l. number x: is divided by the s.l. number y producing an integral quotient and a remainder.  The quotient is written into Z or X and the remainder into Z+1 or X+1.  OVR is set if z' exceeds single-length capacity.  If x: is not in standard form the OMP is entered; the OMP does a 'partial justify' and obeys the instruction.

For comments and examples relating to the values of quotients and remainders please see under function-number 40; in essence functions 40 and 44 differ only in using single-and double-length dividends respectively.

If the remainder from a 44-instruction is divided by the original divisor (using a 43-instruction) the result is necessarily a non-negative fraction.  Thus if a is a standard d.l. number in A100 and A101 and if b is an s.l. number in A200 then after obeying the instructions

44      A100     A200     A7
43      A8        A200

A7 and A8 will together contain the standard d.l. mid-point (rounded) value of a/b, with the signed integral part in A7 and the non-negative fractional part in A8.

Function number 45  [0100 101]

(3)  zF' = (x:F/yF)r or (x:M/yI)r ;  e (x:F/yF) - zF' < ½ e
(2)  As 3-address but with xF' in place of zF'

Rounded division with double-length dividend.   Divide the standard d.l. number x: by the s.l. number y to produce a rounded fractional quotient, writing this quotient into Z or X.  The operands must be such that |x:F| < |yF| or x:F = -yF.  OVR is set if neither of these conditions is satisfied.  If x: is not in standard form, the O&MP is entered; the OMP does a 'partial justify' and obeys the instruction.

The result is that multiple of 2-47 which is nearest to the true value of x:F/yF being the algebraically larger if the true quotient is an odd multiple of 2-48.

Note also that

zI' = (x:M/yF)r or (x:I/yI)r ;  (x:M/yF) - zI' < ½

i.e. the quotient may be regarded as the rounded integral quotient when x:M is divided by yF or when x:I is divided by yI.

Function number 46  [0100 110]

Function number 47  [0100 111]

Illegal instructions