News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

integer overflow

Started by piotrus, April 14, 2007, 05:49:13 PM

Previous topic - Next topic

piotrus

When my program goes to 'div X2' it throws an expeption "integer overflow". X2 is a word value (0x00000002 in this case).

...
mov bx, WORD PTR [eax]
xor eax, eax
mov ax, bx
div X2
mov ecx, pEchoBuffer
mov WORD PTR [ecx+esi],ax
...

What is wrong? :)

Thanks in advance,
Peter

u

do a
xor edx,edx
beforehand. It overflows because you're dividing a large 64-bit value (probably edx>1) by the small 32-bit value.
Please use a smaller graphic in your signature.

piotrus

You were right Ultrano, the value of edx was much more > 1 :)
But it still didn`t work.
I solved the problem by replacing
div X2
with
div WORD PTR X2

Now it works :D