The NEG instruction

Negation of the contents of a register or memory location (two's complement).

Format of the NEG instruction

InstructionDescription
NEG reg/mem8Negation of reg/mem8.
NEG reg/mem16Negation 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 Author: Evgeny Sergeevich Dovgopolov

.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
Yes
PF
Yes
AF
Yes
ZF
Yes
SF
Yes
TF
No
IF
No
DF
No
OF
Yes