neg
Negate
Negates A, giving its two's complement, which is the same as subtracting A from zero.
2 bytes8 cycles
Used in
- 8-bit and 16-bit arithmetic, logic and bitsZ80 assembly
- The screen, keyboard and mouse through portsZ80 assembly
- The bigger of two numbersZ80 assembly
- A bouncing ballZ80 assembly
SZHP/VNC ●●●●1●
- ● depends on the result
- 1 always 1
Forms
negNegates A (two's complement), which is the same as subtracting A from zero.
.org 0x8000
ld a, 5
neg
halt