Difference between revisions of "Assembler:Commands:DIV"
(Created page with ''''command''' div ''operand'' Divids the data register (high) and the accumulator register (low) by the operand. Placing the quotient in the accumulator register and the remaind…') |
|||
Line 59: | Line 59: | ||
EAX EDX = EDX:EAX/operand : DWORD | EAX EDX = EDX:EAX/operand : DWORD | ||
RAX RDX = RDX:RAX/operand : QWORD | RAX RDX = RDX:RAX/operand : QWORD | ||
+ | |||
+ | |||
+ | {| class="gallery" style="background-color:#f4f4f4" | ||
+ | !align="left"|Opcode | ||
+ | !align="left"|Mnemonic | ||
+ | !align="left"|Description | ||
+ | |- | ||
+ | |F6 /4 | ||
+ | |MUL r/m8 | ||
+ | |Unsigned multiply (AX = AL * r/m8). | ||
+ | |- | ||
+ | |F7 /4 | ||
+ | |MUL r/m16 | ||
+ | |Unsigned multiply (DX:AX = AX * r/m16). | ||
+ | |- | ||
+ | |F7 /4 | ||
+ | |MUL r/m32 | ||
+ | |Unsigned multiply (EDX:EAX = EAX * r/m32). | ||
+ | |} | ||
Line 96: | Line 115: | ||
mov [00123ABC],2 | mov [00123ABC],2 | ||
div [00123ABC] | div [00123ABC] | ||
− | // eax = | + | // eax = 6, edx = 0 |
mov eax,6 | mov eax,6 | ||
Line 102: | Line 121: | ||
mov [SomeSymbol],2 | mov [SomeSymbol],2 | ||
div [SomeSymbol] | div [SomeSymbol] | ||
− | // eax = | + | // eax = 6, edx = 0 |
Revision as of 04:20, 14 March 2017
command div operand
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.
Divides (unsigned) the value in the AX, DX:AX, or EDX:EAX registers (dividend) by the source operand (divisor) and stores the result in the AX (AH:AL), DX:AX, or EDX:EAX registers.
Dividend | Divisor | Quotient | Remainder | Maximum Quotient | |
---|---|---|---|---|---|
Word/Byte | AX | r/m8 | AL | AH | 2^8 - 1 |
Doubleword/Word | DX:AX | r/m16 | AX | DX | 2^16 - 1 |
Quadword/Doubleword | EDX:EAX | r/m32 | EAX | EDX | 2^32 - 1 |
Octoword/Quadword | RDX:RAX | r/m64 | RAX | RDX | 2^64 - 1 |
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).
See the table above.
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.
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
Opcode | Mnemonic | Description |
---|---|---|
F6 /4 | MUL r/m8 | Unsigned multiply (AX = AL * r/m8). |
F7 /4 | MUL r/m16 | Unsigned multiply (DX:AX = AX * r/m16). |
F7 /4 | MUL r/m32 | Unsigned multiply (EDX:EAX = EAX * r/m32). |
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