Slide 7.2: INC and DEC instructions
Slide 7.4: Implementing arithmetic expressions
Home

NEG Instruction


The NEG instruction (negate) reverses the sign of a number by converting the number to its two's complement.

NEG — Two's Complement Negation

Usage: NEG dest

Flag O D I S Z A P C
Result *     * * * * *

Calculate the two's complement of the destination operand, and stores the result in the destination.
Clocks
Operands 286 386 486 Size Bytes
reg 2 2 1 2
mem 7 6 3 2-4

Execution of 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