INDR
Input and Output Group
Expansion:
INput Decrease Repeat
Usage:
indr
Reads input from the port address found in memory at pointer C register i.e. (C) and saves the result to the address pointer (HL). It then decrements HL and B registers. This then repeats until B is zero. Please see IND for more information.
| Instruction | Description | Opcode |
|---|---|---|
| INDR | INput Decrease Repeat | EDBA |
Example
; Example
ld bc, $00FE ; load BC with the address of port 254 ($FE) and the counter in B
ld hl, $4000 ; load HL with the starting address of the memory block
ld b, $10 ; load B with the number of bytes to read (16 bytes in this example)
indr ; input a byte from port C ($FE), store it at (HL), decrement HL, decrement B
; after indr, HL will be decremented by the number of bytes read,
; and the memory block at $4000 will contain the data from the I/O port