If a have this variable:

test dd 0

and I do this on my program:

add test,xxxxx

if test goest > FFFFFFFFh it will cause an exception? or it will go to 00000000h ?

Posted on 2010-01-07 12:37:12 by hunter

if test goest > FFFFFFFFh it will cause an exception? or it will go to 00000000h ?


Assuming MASM-like syntax, I would imagine that it should wrap the value and set the carry flag.
Posted on 2010-01-07 13:33:36 by SpooK
Yeah, no exceptions here. It's just basic 2's complement arithmetic.
Posted on 2010-01-07 14:46:35 by ti_mo_n
Starting with "test" (the name of an instruction... and a Unix utility... so not a great name for a variable) at zero, what value of "xxxx" would cause it to wrap and set the carry flag? :)

Anyway, no exception. What *will* cause an exception is dividing by zero, or attempting a "div" in which the result will not fit in the destination register. This last one is a little subtle, and often bites newbies. :)

Best,
Frank

Posted on 2010-01-07 21:54:40 by fbkotler
Starting with "test" (...) at zero, what value of "xxxx" would cause it to wrap and set the carry flag? :)

I surmise his question was hypothetical and what he meant was "what happens if I overflow a variable" ^^
Posted on 2010-01-07 23:40:24 by ti_mo_n
Indeed, can't overflow from zero using any number of the same bitlength as the counter.
Posted on 2010-01-08 01:30:56 by Homer