EI
General Purpose Arithmetic and CPU Control Group
Expansion:
Enable Interrupts
Usage:
ei
EI instruction is used to enable the CPU's interrupt system again, after we may have prevented interrupt requests from being processed using the DI instruction.
| Instruction | Description | Opcode |
|---|---|---|
| DI | Enable Interrupts | FB |
Example
; Example
di ; disable interrupts
; critical section of code starts here
ld a, $01 ; load a value into register A
out ($FE), a ; output the value to port 254 (e.g., turn on the beeper)
nop ; no operation (short delay)
nop ; no operation (short delay)
ld a, $00 ; load a value into register A
out ($FE), a ; output the value to port 254 (e.g., turn off the beeper)
; critical section of code ends here
ei ; enable interrupts