Need help understanding div instruction

-1

EAX = 0x30323232

ECX = 0x000000F9

div ecx

EAX = 0x00318D0D

EDX = 0x0000008D

I can't understand why the remainder EDX is 8D. I hope someone can help me with that, Thanks.

assembly
asked on Stack Overflow Jun 28, 2014 by Mike L

1 Answer

1

Because the remainder equals what's left over after the division, i.e. the difference between the dividend and the product of the divisor and the quotient.

You divided by 0x30323232 by 0xF9 and got a quotient of 0x00318D0D. If you multiply 0x00318D0D by 0xF9 you get 0x303231A5, and therefore the remainder will be 0x30323232 - 0x303231A5 which equals 0x8D.

answered on Stack Overflow Jun 28, 2014 by Michael

User contributions licensed under CC BY-SA 3.0