0FFh + 1 |
80h – 1 |
80h + 0FFh |
.data
X SBYTE 0FFh
.code
add X, 1
call DumpRegs
jc L1
call WaitMsg
L1: movsx eax, X
call WriteHex
|
.data
X BYTE 80h
.code
sub X, 1
call DumpRegs
jc L1
call WaitMsg
L1: movsx eax, X
call WriteHex
|
.data
X BYTE 80h
.code
add X, 0FFh
call DumpRegs
jc L1
call WaitMsg
L1: movsx eax, X
call WriteHex
|
| Output | Output | Output |
NEG instruction can produce an invalid result if the destination operand can not be stored correctly.NEG to a nonzero operand always sets the Carry flag.
–128 – 1 |
1 – 2 |
–(–128) |
.data
X SBYTE -128
.code
sub X, 1
call DumpRegs
jc L1
call WaitMsg
L1: movsx eax, X
call WriteHex
|
.data
X SBYTE 1
.code
sub X, 2
call DumpRegs
jc L1
call WaitMsg
L1: movsx eax, X
call WriteHex
|
.code
sub eax, eax
mov al, -128
neg al
call DumpRegs
jo L1
call WaitMsg
L1: call WriteHex
|
| Output | Output | Output |