According to NEG and NEGU definitions,
NEG $X,Y,$Z (negate signed): s($X) := Y - s($Z).
NEGU $X,Y,$Z (negate unsigned): u($X) := (Y - u($Z)) mod 2^64.
Let's suppose $Z = s(-1)
or u(2^64 - 1)
. Then the first opcode is going to put value 1 into the $X
register when Y = 0
, and the recent one will give the same result because u(-(2^64 - 1)) mod 2^64 = 1
. Am i correct? Should NEG
instruction raise overflow exception when $Z = -2^63
?
Short answer to "Should NEG instruction raise overflow exception when $Z = -2^63?"
Logically, NEG $X,0,-2^63 should give 2^63, which is out of bounds for signed positive integers, and thus overflows. But if you're like me, you want proof that an integer overflow actually occurs. Here it is: