NEG
General Purpose Arithmetic and CPU Control Group
Expansion:
NEGate accumulator
Usage:
neg
The NEG instruction in the Z80 microprocessor is used to negate the value in the Accumulator (register A). This means it changes the sign of the value in the Accumulator. For example, if the Accumulator contains a positive value, it becomes negative, and vice versa.
| Instruction | Description | Opcode |
|---|---|---|
| NEG | NEGate accumulator | ED44 |
Example
; Example
; initialize register A with a value
ld a, 5 ; load the value 5 into register A
; negate the value in register A
neg ; register A now contains -5
; end of program
halt ; halt the processor