| <<< DIV Instruction | Index | Signed Integer Division >>> |
The following fragment performs 8-bit unsigned division (83h/2), producing a quotient of 41h and a remainder of 1:
mov ax, 83h ; dividend
mov bl, 2 ; divisor
div bl ; quotient AL = 41h, remainder AH = 01h
The following instructions perform 16-bit unsigned division (8003h/100h), producing a quotient of 80h and a remainder of 3.
Note that DX contains the high part of the dividend, so it must be cleared before the DIV instruction executes:
mov dx, 0 ; clear high part of the dividend
mov ax, 8003h ; set low part of the dividend
mov cx, 100h ; set divisor
div cx ; quotient AX = 0080h, remainder DX = 0003h
The following fragment performs 32-bit unsigned division using a memory operand as the divisor:
.data
dividend QWORD 0000000800300020h
divisor DWORD 00000100h
.code
mov edx, DWORD PTR [dividend + 4] ; high doub1eword
mov eax, DWORD PTR [dividend] ; low doubleword
div divisor ; quotient EAX = 08003000h, remainder EDX = 00000020h
| <<< DIV Instruction | Index | Signed Integer Division >>> |