0

I'm so new to assembly and I had this example in the book i'm learning from

%include "io.inc"

section .text
global CMAIN
CMAIN:
mov ebp, esp;
    ;write your code here
    mov eax, 444444447h
    mov ebx, 22222222h
    mov edx, 44h
    div ebx
    ret

And those are the results I'm getting run_results

EAX: 0x200
EBX: 0x22222222
EDX: 0x47

*can anyone explain to me why the final value in the EDX is 0x47 ?
*And when I put 0h in the EDX why the final value in the EAX is becoming 0x2 ?
*how is the EDX effecting the division results, if basically the division is just between EAX and EBX.
*Isn't the EDX just for storing the devision rest?

Thanks in advance :)

  • _EDX_ will contain the remainder of the division. _EAX_ contains the quotient. Division by a 32-bit operand will divide a 64-bit value (dividend in EDX:EAX) by a 32-bit value (in this case EBX is the divisor). – Michael Petch Jun 04 '17 at 17:59
  • 2
    What leads you to think that division is just between `eax` and `ebx`? Guessing? Don't do that in assembly, it doesn't work very logically. Most of the time it does, but when it does not, it bites hard. Rather just check the [docs](http://www.felixcloutier.com/x86/DIV.html) (or the full Intel docs). – Ped7g Jun 04 '17 at 18:00

0 Answers0