DI
General Purpose Arithmetic and CPU Control Group
Expansion:
Disable Interrupts
Usage:
di
DI instruction is used to disable the CPU's interrupt system, preventing any interrupt requests from being processed. This is useful when you want to ensure that a critical section of code runs without interruption.
| Instruction | Description | Opcode |
|---|---|---|
| DI | Disable Interrupts | F3 |
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