Unsigned Arithmetic

Name:
ADDU $X,$Y,$ZADDU $X,$Y,Z
SUBU $X,$Y,$ZSUBU $X,$Y,Z
MULU $X,$Y,$ZMULU $X,$Y,Z
DIVU $X,$Y,$ZDIVU $X,$Y,Z

Specification:

ADDU: u($X) ← (u($Y) + u($Z)) mod 264
SUBU: u($X) ← (u($Y) -u($Z)) mod 264
MULU: u(rH $X) ← u($Y) * u($Z)
DIVU:
u($X) ← { ⌊u(rD $Y) / u($Z)⌋ if u($Z) > u(rD)
u(rD) otherwise

u(rR) ← { u(rD $Y) mod u($Z) if u($Z) > u(rD)
u($Y) otherwise
The special register rD is prepended to the register $Y to form a 128 bit number. This number is divided by $Z and the result is stored in $X. The remainder is stored in special register rR.

If, however, rD ≥ $Z, then the result of the division would be greater than 264 and the quotient will not be computed. Instead, rD is stored in $X and $Y is stored in rR. In Donald Knuth's "The Art of Computer Programming", Volume 2, "Seminumerical Algorithms", Chapter 4.3.1 will explain how to use this instruction to implement division of high-precision numbers with 128 bit or more.

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

Timing:
ADDU: 1υ
SUBU: 1υ
MULU: 10υ
DIVU: 60υ

Description:

These instructions perform arithmetic operations on unsigned numbers. They never cause overflow or other exceptions, not even if dividing by zero.

See also:

Signed Arithmetic.