ASM Inserts iDIV
//Pascal
NumX:=-40;
//Assm
MOV EAX,NumX
MOV ECX,4
IDIV ECX
MOV IntPart, EAX
Why does IntPart return 1073741815?
1
1 answers
Because the value is unsigned.
You have in EAX
a converted unsigned 4-byte integer -40, which gives the value FFFFFFD8
, or 4294967256 in decimal form.
Divided by 4, we get 3FFFFFF6
, or 1073741814 in decimal form.
Here's how your code should look right:
MOV EAX,NumX
CDQ
MOV ECX,4
IDIV ECX
MOV IntPart, EAX
The signed extension EAX
in EDX:EAX
is forgotten...
5
Author: Harry, 2016-12-21 16:21:56