Slide 7.2: INC and DEC instructions Slide 7.4: Implementing arithmetic expressions Home |
NEG
Instruction
NEG
instruction (negate) reverses the sign of a number by converting the number to its two's complement.
NEG — Two's Complement Negation |
||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
NEG
instruction causes the value of its operand to be replaced by its negative.
– X |
–[X + 0] |
– X |
.data X SWORD -1234h .code neg X movsx eax, X call WriteHex |
.data X SWORD 0EDCCh .code neg X+0 movsx eax, X call WriteHex |
.data X SWORD 0h, 0EDCCh .code mov ebx, OFFSET X neg [ebx] mov eax, [ebx] call WriteHex |
Output | Output | Output |