NEG Instruction


The 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 instruction causes the value of its operand to be replaced by its negative.

– X –[X + 0] – X
 INCLUDE Irvine32.inc 
 .data
  X   SWORD  -1234h
 .code
 main PROC
  neg    X
  movsx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  X   SWORD  0EDCCh
 .code
 main PROC
  neg    X+0
  movsx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
	
 INCLUDE Irvine32.inc
 .data
  X   SWORD  0h, 0EDCCh
 .code
 main PROC
  mov   ebx, OFFSET X
  neg   [ebx]
  mov   eax, [ebx]
  call  WriteHex
  exit
 main ENDP
 END main
 
Output Output Output

 

 

 

 

 

 






      “I’m not arguing, I’m just explaining why I’m right.”    
      ― Unknown