mulu
Unsigned multiply
The default word form multiplies two unsigned 16-bit values and stores the 32-bit product in a data register.
- Arithmetic, logic and bitsM68K assembly
- bsr, rts, link and unlkM68K assembly
- trap #15 and its tasksM68K assembly
- Multiply and divide, with the remainderM68K assembly
- Stack arguments and a stack frameM68K assembly
- Recursion: factorial and FibonacciM68K assembly
- A jump tableM68K assembly
- A 2D arrayM68K assembly
- The snake gameM68K assembly
- Flappy ASMM68K assembly
- ● depends on the result
- 0 always 0
- – not changed
Forms
68020 only
These forms require the 68020. Select opt p=68020 before any code or data.
Operands
<ea>- An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With
opt p=68020, an allowedd(An,Xn)ord(PC,Xn)mode also permits the corresponding 68020 indexed and memory indirect forms. See 68020 addressing. More Dn- A data register,
d0tod7. More Dh:Dl- Two data registers for a 64-bit product, for example
d2:d1.Dlsupplies the 32-bit multiplicand. The result’s high long replacesDh, and its low long replacesDl. Use different registers for the two halves. More #imm- An immediate value written after
#: a number, character or label, such as#10,#$FFor#'a'. It must fit the operation’s size: byte-128to255, word-32768to65535, or long-2147483648to4294967295; signed and unsigned spellings are accepted. More
The source and the destination’s low word supply the inputs; the destination’s old upper word is ignored. Word multiplication clears V.
On the 68020, mulu.l multiplies two 32-bit values. In both mulu.l d0, d1 and mulu.l d0, d2:d1, the inputs are d0 and d1. The old value of d2 is not used. The single-register form keeps the low 32 bits in d1 and sets V if the product does not fit in an unsigned 32-bit result. The pair form keeps all 64 bits, with the high long in d2 and the low long in d1, and clears V. Use different registers for the high and low halves.
N and Z describe the result kept: 32 bits for word multiplication or a single-register long result, and 64 bits for a register-pair result. C is cleared and X is unchanged.
move.l #2, d0
mulu #4, d0 ; d0 = 8
* --- Word operands, long result ---
move.l #$FFFF, d1
mulu #$FFFF, d1 ; d1 = $FFFE0001