divu
Unsigned divide
Divides (unsigned) the value of the second operand by the value of the first operand (op2 / op1).
Size .w
Used in
- Arithmetic, logic and bitsM68K assembly
- Exceptions and the vector tableM68K assembly
- Multiply and divide, with the remainderM68K assembly
- A subroutine with its arguments in registersM68K assembly
- A jump tableM68K assembly
- Print a number in any base without helpM68K assembly
- A bouncing ballM68K assembly
- The snake gameM68K assembly
- Flappy birdM68K assembly
- Arithmetic, logic and bitsAssembly basics
XNZVC –●●●0
- ● set from the result
- 0 always 0
- – not changed
Forms
Operands
<ea>- An operand using one of the instruction’s supported addressing modes, such as
d0,(a0)+or4(a1). It may name a register, memory or an immediate value. More Dn- A data register,
d0tod7. 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 quotient is stored in the low 16 bits of the destination register and the remainder in its high 16 bits. The first operand is read as a word, the second as a long
* --- Result: quotient in low word, remainder in high word ---
move.l #21, d0
divu #4, d0
move.w d0, d1 ; d1 = quotient (5)
swap d0
move.w d0, d2 ; d2 = remainder (1)
* --- Large unsigned value ---
move.l #$FFFE, d3
divu #$FFFF, d3
move.w d3, d4 ; d4 = quotient (0)
swap d3
move.w d3, d5 ; d5 = remainder ($FFFE)