The DIV instruction
Unsigned division.
The DIV instruction format
| Instruction | Description |
|---|---|
| DIV reg/mem8 | Unsigned division of AX by a byte. Result: AL = quotient, AH = remainder. |
| DIV reg/mem16 | Unsigned division of DX:AX by a word. Result: AX = quotient, DX = remainder. |
Divides the unsigned value in the ax register (for a byte divisor) or the dx:ax register (for a word divisor) by the source operand (the divisor) and stores the result: the quotient and the remainder.
Non-integer results are truncated to 0. The remainder is always smaller in magnitude than the divisor. Overflow (for example, division by 0 or a quotient that does not fit in AL/AX) is signaled by exception #DE (divide error).
Usage example
title .model small .stack 100h code segment public ; Start of the code segment assume cs:code main proc ; Start of the main procedure mov al, 73 ; Copy the value 73 into the al register mov bl, 4 ; Copy the value 4 into the bl register cbw ; Perform sign extension of the al register to ax div bl ; Perform unsigned division of ax by bl mov ax, 4C00h ; Copy the process termination function number into ah and the value into al int 21h ; Call the interrupt main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".
Processor status flags
CF
?PF
?AF
?ZF
?SF
?TF
NoIF
NoDF
NoOF
?