MMIX LOGO

MMIX Instruction Set

Table of Content

Content

Signed Arithmetic

Name:
ADD $X,$Y,$ZADD $X,$Y,Z
SUB $X,$Y,$ZSUB $X,$Y,Z
MUL $X,$Y,$ZMUL $X,$Y,Z
DIV $X,$Y,$ZDIV $X,$Y,Z

Specification:
ADD: s($X) ← s($Y) + s($Z)
SUB: s($X) ← s($Y) - s($Z)
MUL: s($X) ← s($Y) * s($Z)
DIV:
s($X) ← { ⌊s($Y) / s($Z)⌋ if $Z ≠ 0
0 if $Z = 0

the integer part of the Quotient and

s(rR) ← { s($Y) mod s($Z) if $Z ≠ 0
s($Y) if $Z = 0

the remainder in special register rR.

All instructions exist in two variants. The second operand can either be a register $Z or an immediate value Z.

Timing:

ADD:
SUB:
MUL: 10υ
DIV: 60υ

Description:

These are instructions for computations with signed integers. The instructions record exceptions like overflow or division by zero in special register rA and, if enabled, cause a TRIP.

ADD: The sum $Y +$Z or $Y +Z is placed into register X using signed, two's complement arithmetic. An integer overflow exception occurs if the sum is ≥ 263 or < -263.
SUB: The difference $Y - $Z or $Y - Z is placed into register X using signed, two's complement arithmetic. An integer overflow exception occurs if the difference is ≥ 263 or < -263
MUL: The signed product of the number in register Y by either the number in $Z or the unsigned byte Z replaces the contents of register X. An integer overflow exception can occur, as with ADD or SUB, if the result is ≥ 263 or < -263.

(Consider: Immediate multiplication by powers of 2 can be done more rapidly with the SL instruction)
DIV: The signed quotient of the number in $Y divided by either the number in $Z or the unsigned byte Z replaces the contents of $X, and the signed remainder is placed in the special remainder register rR. An integer divide check exception occurs if the divisor is zero; in that case $X is set to zero and rR is set to $Y. An integer overflow exception occurs if the number -263 is divided by -1; otherwise integer overflow is impossible. The quotient of y divided by z is defined to be [y/z], and the remainder is defined to be y - [y/z]z (also written y mod z). Thus, the remainder is either zero or has the sign of the divisor.

(Consider: Dividing by z = 2t gives exactly the same quotient as shifting right via the SR command, and exactly the same remainder as anding with z - 1 via the AND command. Division of a positive 63-bit number by a positive constant can be accomplished more quickly by computing the upper half of a suitable unsigned product and shifting it right appropriately.)

See also:

Unsigned Arithmetic.

Please help to keep this site up to date! If you want to point out important material or projects that are not listed here, if you find errors or want to suggest improvements, please send email to email