Assembler:Commands:DIV

command div operand

Performs an unsigned division of two operands.

Divids the data register (high) and the accumulator register (low) by the operand. Placing the quotient in the accumulator register and the remainder in the data register.

The CF, OF, SF, ZF, AF, and PF flags are undefined.

```AL AH = AH:AL/operand : byte
AX DX = DX:AX/operand : WORD
EAX EDX = EDX:EAX/operand : DWORD
RAX RDX = RDX:RAX/operand : QWORD
```

Divides (unsigned) the value in the AH:AL, DX:AX, EDX:EAX, or RDX:RAX registers (dividend) by the source operand (divisor) and stores the result in the AH:AL, DX:AX, EDX:EAX, or RDX:RAX registers.

The source operand can be a general-purpose register or a memory location. The action of this instruction depends on the operand size (dividend/divisor). Non-integral results are truncated (chopped) towards 0. The remainder is always less than the divisor in magnitude. Overflow is indicated with the #DE (divide error) exception rather than with the CF flag.

Contents

Command Parameters

Parameter Description
operand The dividend operand

Examples

```div ecx
```
```mov eax,6
mov edx,0
mov ecx,2
div ecx
// eax = 3, edx = 0
```
```mov eax,9
mov edx,0
mov esi,2
div esi
// eax = 4, edx = 1
```
```mov eax,0
mov edx,1
mov esi,0x10
div esi
// eax = 0x10000000, edx = 0
```
```mov eax,6
mov edx,0
mov [00123ABC],2
div [00123ABC]
// eax = 6, edx = 0
```
```mov eax,6
mov edx,0
mov [SomeSymbol],2
div [SomeSymbol]
// eax = 6, edx = 0
```