MIT PDP-10 'Info' file converted to Hypertext 'html' format by Henry Baker

Previous Up Next

Fixed point arithmetic ADD, SUB, IMUL, IDIV, MUL, DIV

In positive numbers bit 0 is zero. Bits 1 is most significant; bit 35 is least significant. Negative numbers are the twos complement of postive numbers. Results (of ADD, SUB or IMUL) outside the range -2^|35 to 2^|35-1 will set overflow (PC bit 0).

Each arithmetic instruction has four forms, with modifier characters (nothing), M, B and I.

ADD     C(AC) <- C(AC) + C(E);
ADDI    C(AC) <- C(AC) + E;
ADDM    C(E)  <- C(AC) + C(E);
ADDB    C(AC) <- C(AC) + C(E);  C(E) <- C(AC);

SUB     C(AC) <- C(AC) - C(E);
SUBI    C(AC) <- C(AC) - E;
SUBM    C(E)  <- C(AC) - C(E);
SUBB    C(AC) <- C(AC) - C(E);  C(E) <- C(AC);
The IMUL instructions are for multiplying numbers where the product is expected to be representable as one word.
IMUL    C(AC) <- C(AC) * C(E);
IMULI   C(AC) <- C(AC) * E;
IMULM   C(E)  <- C(AC) * C(E);
IMULB   C(AC) <- C(AC) * C(E);  C(E) <- C(AC);
The IDIV instructions are for divisions in which the dividend is a one word quantity. Two consecutive accumulators are used for the results; these are AC for the quotient, and AC+1 for the remainder (Actually, AC+1 is calculated mod 20, so if AC=17, the remainder is stored in accumulator 0.) If the divisor is zero set overflow and no divide; don't change AC or memory operands. The remainder will have the same sign as the dividend.
IDIV    C(AC) <- C(AC) / C(E);  C(AC+1) <- remainder
IDIVI   C(AC) <- C(AC) / E;  C(AC+1) <- remainder;
IDIVM   C(E)  <- C(AC) / E;
IDIVB   C(AC) <- C(AC) / C(E);  C(AC+1) <- remainder; C(E) <- C(AC);
The MUL instructions produce a double word product. A double word integer has 70 bits of significance. Bit 0 of the high order word is the sign bit. In data, Bit 0 of the low order word is ignored by the hardware. In results, bit 0 of the low word is the same as bit 0 in the high word. MUL will set overflow if both operands are -2^|35.
MUL     C(AC AC+1) <- C(AC) * C(E);
MULI    C(AC AC+1) <- C(AC) * E;
MULM    C(E)  <- high word of product of C(AC) * C(E);
MULB    C(AC AC+1) <- C(AC) * C(E);  C(E) <- C(AC);
The DIV instructions are for divisions in which the dividend is a two word quantity (such as produced by MUL). If C(AC) is greater than the memory operand then set overflow and no divide.
DIV     C(AC) <- C(AC AC+1) / C(E); C(AC+1) <- remainder;
DIVI    C(AC) <- C(AC AC+1) / E;    C(AC+1) <- remainder;
DIVM    C(E)  <- C(AC AC+1) / E;
DIVB    C(AC) <- C(AC AC+1) / C(E); C(AC+1) <- remainder;
          C(E) <- C(AC);