HALT
General Purpose Arithmetic and CPU Control Group
Expansion:
cpu HALTed
Usage:
halt
The HALT instruction in Z80 assembly is used to stop the CPU's execution until an interrupt is received. This is useful for saving power or waiting for an external event to occur. When the HALT instruction is executed, the CPU stops executing further instructions and enters a low-power state, waiting for an interrupt to wake it up.
| Instruction | Description | Opcode |
|---|---|---|
| HALT | cpu HALTed | 76 |
Example
; Example
ld a, $01 ; load a value into register A
out ($FE), a ; output the value to port 254 (e.g., turn on the beeper)
halt ; halt the CPU and wait for an interrupt
; after an interrupt, the CPU continues from the next instruction
ld a, $00 ; load a value into register A
out ($FE), a ; output the value to port 254 (e.g., turn off the beeper)