X86-assembly/Instructions/div

From aldeid
Jump to navigation Jump to search
You are here:
div

Description

  • The div instruction is used to perform a division.
  • Always divides the 64 bits value accross EDX:EAX by a value.
  • The result of the division is stored in EAX and the remainder in EDX.

Syntax

div value

Example

The operation 0x8003 / 0x100 can be written as follows:

Assembly python
mov edx, 0        ; clear dividend
mov eax, 0x8003   ; dividend
mov ecx, 0x100    ; divisor
div ecx           ; EAX = 0x80, EDX = 0x3
>>> hex(0x8003 / 0x100)
'0x80'
>>> hex(0x8003 % 0x100)
'0x3'

Comments

blog comments powered by Disqus