neg
Two's complement negation
Replaces the operand with its two's complement, which inverts every bit and then adds one.
8086 and lateraccepts the lock prefix with a memory operand
Used in
- A bouncing ballx86-64 assembly
- Sampled soundx86-64 assembly
CFPFAFZFSFDFOF ●●●●●–●
- ● depends on the result
- – not changed
Forms
Operands
r/m- A general-purpose register or memory location matching the operation’s size, for example
raxorqword [rbp-8].
NOT, similarly, performs one's complement (inverts all
the bits).
global _start
section .text
_start:
mov rax, 12
mov rbx, 5
mov rcx, 3
mov rsi, 9
neg rax
mov rax, 60 ; syscall 60: exit
xor rdi, rdi
syscall