divul

Unsigned divide long, with remainder 68020

Divides a long by a long, unsigned, putting the quotient in one data register and the remainder in another.

Size .l68020 only: select opt p=68020 before any code or data

XNZVC –●●●0
  • ● set from the result
  • 0 always 0
  • – not changed

Forms

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 allowed d(An,Xn) or d(PC,Xn) mode also permits the corresponding 68020 indexed and memory indirect forms. See 68020 addressing. More
Dr:Dq
A remainder register followed by a quotient register, for example d2:d1. For divs.l and divu.l, both supply the 64-bit dividend, high long first. For divsl.l and divul.l, only Dq supplies the 32-bit dividend. The quotient replaces Dq and the remainder replaces Dr. More
#imm
An immediate value written after #: a number, character or label, such as #10, #$FF or #'a'. It must fit the operation’s size: byte -128 to 255, word -32768 to 65535, or long -2147483648 to 4294967295; signed and unsigned spellings are accepted. More

In divul.l <ea>, Dr:Dq, Dq supplies the dividend. The old value of Dr is not used. The quotient replaces Dq and the remainder replaces Dr.

Use different registers to keep both results. If Dr and Dq name the same register, only the quotient remains. This uses the same 32-bit dividend as the single-register form of divu.l. The register-pair form of divu.l takes a 64-bit dividend instead.

A zero divisor raises a division-by-zero exception through vector 5 at $14. After a successful division, N and Z describe the quotient and V is cleared. C is cleared and X is unchanged.

opt p=68020
* --- Seconds as hours and the seconds left over ---
move.l #100000, d2 ; the seconds
divul.l #3600, d1:d2 ; 27 hours, and d1 = 2800 seconds left over
move.l d2, d3 ; d3 = 27