Mnemonics

INI

Input and Output Group
Expansion:
INput and Increment
Usage:
ini

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 increments HL while decrements B register.

INI (Input and Increment) is generally more intuitive because it reads data sequentially, storing it in memory in the natural, forward direction. However, IND (Input and Decrement) has its own use cases and advantages, especially in certain scenarios where the direction of memory storage matters. See IND for more info.

Z80.CPU instructions
Instruction Description Opcode
INI INput and Increment EDA2

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) ReadLoop: ini ; input a byte from port C ($FE), store it at (HL), increment HL, decrement B jp nz, ReadLoop ; repeat the loop if B is not zero ; after the loop, HL will be increment by the number of bytes read, ; and the memory block at $4000 will contain the data from the I/O port

See also