Difference between revisions of "Assembler:Commands:DIV"

From Cheat Engine
Jump to navigation Jump to search
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[Category:Assembler]]
 
'''command''' div ''operand''
 
'''command''' div ''operand''
  
Divids the data register (high) and the accumulator register (low) by the operand.
+
Performs an unsigned division of two operands.
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.
 
  
 +
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.
  
 
{| class="gallery" style="background-color:#f4f4f4"
 
{| class="gallery" style="background-color:#f4f4f4"
|+ Results
 
 
!align="left"|Dividend
 
!align="left"|Dividend
 
!align="left"|Divisor
 
!align="left"|Divisor
Line 44: Line 41:
 
|2^64 - 1
 
|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.
 
The '''CF''', '''OF''', '''SF''', '''ZF''', '''AF''', and '''PF''' flags are undefined.
Line 61: Line 50:
  
  
{| class="gallery" style="background-color:#f4f4f4"
+
<div style="padding:2px;border:1px dashed #2f6fab;background-color:#f4f4f4;">
!align="left"|Opcode
+
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.
!align="left"|Mnemonic
+
 
!align="left"|Description
+
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.
|-
+
 
|F6 /6
+
[http://c9x.me/x86/html/file_module_x86_id_72.html c9x.me/x86/html/file_module_x86_id_72.html]
|DIV r/m8
+
</div>
|Unsigned divide AX by r/m8, with result stored in AL = Quotient, AH = Remainder.
 
|-
 
|F7 /6
 
|DIV r/m16
 
|Unsigned divide DX:AX by r/m16, with result stored in AX = Quotient, DX = Remainder.
 
|-
 
|F7 /6
 
|DIV r/m32
 
|Unsigned divide EDX:EAX by r/m32, with result stored in EAX = Quotient, EDX = Remainder.
 
|}
 
  
  
Line 123: Line 102:
 
  // eax = 6, edx = 0
 
  // eax = 6, edx = 0
  
 +
{{AssemblerCommandSeeAlso}}
  
== See also ==
+
{{Template:AssemblerCommandExternalLinks}}
* [[Assembler]]
 
* [[Cheat_Engine:Auto Assembler|Auto Assembler]]
 
* [[Assembler:Commands|Assembler Commands]]
 
 
 
== External links ==
 
* [https://wikipedia.org/wiki/X86_instruction_listings wikipedia.org/wiki/X86_instruction_listings]
 
* [https://wikibooks.org/wiki/X86_Assembly/Other_Instructions wikibooks.org/wiki/X86_Assembly/Other_Instructions]
 
* [http://www.asmpedia.org/index.php?title=Main_Page asmpedia.org]
 
* [http://x86.renejeschke.de/html/file_module_x86_id_72.html x86.renejeschke.de/html/file_module_x86_id_72.html]
 

Latest revision as of 15:43, 3 January 2018

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.

c9x.me/x86/html/file_module_x86_id_72.html


Command Parameters[edit]

Parameter Description
operand The dividend operand


Examples[edit]

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

See also[edit]

External links[edit]