The NEG instruction
Negation of the contents of a register or memory location (two's complement).
Format of the NEG instruction
| Instruction | Description |
|---|---|
| NEG reg/mem8 | Negation of reg/mem8. |
| NEG reg/mem16 | Negation of reg/mem16. |
Replaces the value of the operand (the destination operand) with its two's complement (0 - value). The destination operand is in a general-purpose register or in a memory location.
Usage example
In this example the number 13 (0Dh) is replaced with -13 (FFF3h).
title .model small .stack 100h code segment public ; Start of the code segment assume cs:code main proc ; Start of the main procedure mov ax, 13 ; Copy the value 13 into the ax register neg ax ; Perform negation of the ax register mov ax, 4C00h ; Copy the process termination function number into ah and the value into al int 21h ; Call the interrupt main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".
Processor status flags
CF
YesPF
YesAF
YesZF
YesSF
YesTF
NoIF
NoDF
NoOF
Yes