eZ80 docs
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Input / Output

The instructions in this section are included for completeness, but are not usable in user privileged code. Attempting to use an out instruction will trigger a reset and in will return garbage.

IN

Reads a byte from the port located at a 16-bit address formed by the value in a and imm8. The upper byte of the address is the value in a, and the lower byte is imm8. The byte read from the port is then stored in a.

  • Opcode: 11011011 imm8
  • Bytes: 2
  • Flags:
    • None
  • Cycles: 2F + 1R

Reads a byte from the port located at the 16-bit address in bc to reg8.

  • Opcode: 11101101 01 reg8 000

    Register Bit Field
    a 111
    b 000
    c 001
    d 010
    e 011
    h 100
    l 101
  • Bytes: 2

  • Flags:

    • S: Affected as defined
    • Z: Affected as defined
    • H: Reset
    • P/V: Detects parity
    • N: Reset
  • Cycles: 2F + 1R

Reads a byte from the port located at 16-bit address bc and affects flags accordingly.

  • Opcode: 11101101 01110000
  • Bytes: 2
  • Flags:
    • S: Affected as defined
    • Z: Affected as defined
    • H: Reset
    • P/V: Detects parity
    • N: Reset
  • Cycles: 2F + 1R

IN0

Reads a byte from port imm8 and affects flags accordingly.

  • Opcode: 11101101 00110000 imm8
  • Bytes: 3
  • Flags:
    • S: Affected as defined
    • Z: Affected as defined
    • H: Reset
    • P/V: Detects parity
    • N: Reset
  • Cycles: 3F + 1R

Reads a byte from port imm8 and stores it into reg8.

  • Opcode: 11101101 00 reg8 000 imm8
    Register Bit Field
    a 111
    b 000
    c 001
    d 010
    e 011
    h 100
    l 101
  • Bytes: 3
  • Flags:
    • S: Affected as defined
    • Z: Affected as defined
    • H: Reset
    • P/V: Detects parity
    • N: Reset
  • Cycles: 3F + 1R

IND

Reads a byte from the port located at the 16-bit address in bc, which is then stored at the address in hl. Both b and hl are decremented, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10101010
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

INDR

Reads a byte from the port located at the 16-bit address in bc, which is then stored at the address in hl. Both b and hl are decremented, and the Z flag is set if b is decremented to 0. This operation is repeated until b is equal to 0.

  • Opcode: 11101101 10111010
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * b

INDRX

Reads a byte from the port located at the 16-bit address in de, which is then stored at the address in hl. Both bc and hl are decremented, and the Z flag is set if bc is decremented to 0. This operation is repeated until bc is equal to 0.

  • Opcode: 11101101 11001010
  • Bytes: 2
  • Flags:
    • Z: Set if bc is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * bc

IND2

Reads a byte from the port located at the 16-bit address in bc, which is then stored at the address in hl. Both b, c, and hl are decremented, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10001100
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

IND2R

Reads a byte from the port located at the 16-bit address in de, which is then stored at the address in hl. Both bc, de, and hl are decremented, and the Z flag is set if bc is decremented to 0. This operation is repeated until bc is equal to 0.

  • Opcode: 11101101 10011100
  • Bytes: 2
  • Flags:
    • Z: Set if bc is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * bc

INDM

Reads a byte from port c, which is then stored at the address in hl. Both b, c, and hl are decremented, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10001010
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

INDMR

Reads a byte from port c, which is then stored at the address in hl. Both b, c, and hl are decremented, and the Z flag is set if b is decremented to 0. This operation is repeated until b is equal to 0.

  • Opcode: 11101101 10011010
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * b

INI

Reads a byte from the port located at the 16-bit address in bc, which is then stored at the address in hl. Then, b is decremented and hl is incremented by 1, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10100010
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

INIR

Reads a byte from the port located at the 16-bit address in bc, which is then stored at the address in hl. Then, b is decremented and hl is incremented by 1, and the Z flag is set if b is decremented to 0. This operation is repeated until b is equal to 0.

  • Opcode: 11101101 10110010
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * b

INIRX

Reads a byte from the port located at the 16-bit address in de, which is then stored at the address in hl. Then, bc is decremented and hl is incremented by 1, and the Z flag is set if bc is decremented to 0. This operation is repeated until bc is equal to 0.

  • Opcode: 11101101 11000010
  • Bytes: 2
  • Flags:
    • Z: Set if bc is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * bc

INI2

Reads a byte from the port located at the 16-bit address in bc, which is then stored at the address in hl. Then, b is decremented and c and hl are both incremented by 1, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10000100
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

INI2R

Reads a byte from the port located at the 16-bit address in de, which is then stored at the address in hl. Then, bc is decremented and de and hl are both incremented by 1, and the Z flag is set if bc is decremented to 0. This operation is repeated until bc is equal to 0.

  • Opcode: 11101101 10010100
  • Bytes: 2
  • Flags:
    • Z: Set if bc is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * bc

INIM

Reads a byte from port c, which is then stored at the address in hl. Then, b is decremented and c and hl are both incremented by 1, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10000010
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

INIMR

Reads a byte from port c, which is then stored at the address in hl. Then, b is decremented and c and hl are both incremented by 1, and the Z flag is set if b is decremented to 0. This operation is repeated until b is equal to 0.

  • Opcode: 11101101 10010010
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * b

OTDM

Outputs the value pointed to by hl to port c. Both b, c, and hl are decremented, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10001011
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

OTDMR

Outputs the value pointed to by hl to port c. Both b, c, and hl are decremented, and the Z flag is set if b is decremented to 0. This operation is repeated until b is equal to 0.

  • Opcode: 11101101 10011011
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * b

OTDRX

Outputs the value pointed to by hl to the port located at the 16-bit address in de. Both bc and hl are decremented, and the Z flag is set if bc is decremented to 0. This operation is repeated until bc is equal to 0.

  • Opcode: 11101101 11001011
  • Bytes: 2
  • Flags:
    • Z: Set if bc is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * bc

OTIM

Outputs the value pointed to by hl to port c. Then, b is decremented and c and hl are both incremented by 1, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10000011
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

OTIMR

Outputs the value pointed to by hl to port c. Then, b is decremented and c and hl are both incremented by 1, and the Z flag is set if b is decremented to 0. This operation is repeated until b is equal to 0.

  • Opcode: 11101101 10010011
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * b

OTIRX

Outputs the value pointed to by hl to the port located at the 16-bit address in de. Then, bc is decremented and hl is incremented by 1, and the Z flag is set if bc is decremented to 0. This operation is repeated until bc is equal to 0.

  • Opcode: 11101101 11000011
  • Bytes: 2
  • Flags:
    • Z: Set if bc is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * bc

OUT

Outputs the value in a to the port located at a 16-bit address formed by the value in a and imm8. The upper byte of the address is the value in a, and the lower byte is imm8.

  • Opcode: 11010011 imm8
  • Bytes: 2
  • Flags:
    • None
  • Cycles: 2F + 1W

Outputs the byte in reg8 to the port located at the 16-bit address in bc.

  • Opcode: 11101101 01 reg8 001

    Register Bit Field
    a 111
    b 000
    c 001
    d 010
    e 011
    h 100
    l 101
  • Bytes: 2

  • Flags:

    • None
  • Cycles: 2F + 1R

OUT0

Outputs the value in reg8 to port imm8.

  • Opcode: 11101101 00 reg8 001 imm8
    Register Bit Field
    a 111
    b 000
    c 001
    d 010
    e 011
    h 100
    l 101
  • Bytes: 3
  • Flags:
    • None
  • Cycles: 3F + 1W

OUTD

Outputs the value pointed to by hl to the port located at the 16-bit address in bc. Both b and hl are decremented, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10101011
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

OTDR

Outputs the value pointed to by hl to the port located at the 16-bit address in bc. Both b and hl are decremented, and the Z flag is set if b is decremented to 0. This operation is repeated until b is equal to 0.

  • Opcode: 11101101 10111011
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * b

OUTD2

Outputs the value pointed to by hl to the port located at the 16-bit address in bc. Both b, c, and hl are decremented, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10101100
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

OTD2R

Outputs the value pointed to by hl to the port located at the 16-bit address in de. Both bc, de, and hl are decremented, and the Z flag is set if bc is decremented to 0. This operation is repeated until bc is equal to 0.

  • Opcode: 11101101 10111100
  • Bytes: 2
  • Flags:
    • Z: Set if bc is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * bc

OUTI

Outputs the value pointed to by hl to the port located at the 16-bit address in bc. Then, b is decremented and hl is incremented by 1, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10100011
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

OTIR

Outputs the value pointed to by hl to the port located at the 16-bit address in bc. Then, b is decremented and hl is incremented by 1, and the Z flag is set if b is decremented to 0. This operation is repeated until b is equal to 0.

  • Opcode: 11101101 10110011
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * b

OUTI2

Outputs the value pointed to by hl to the port located at the 16-bit address in bc. Then, b is decremented and c and hl are both incremented by 1, and the Z flag is set if b is decremented to 0.

  • Opcode: 11101101 10100100
  • Bytes: 2
  • Flags:
    • Z: Set if b is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + 1R + 1W + 1

OTI2R

Outputs the value pointed to by hl to the port located at the 16-bit address in de. Then, bc is decremented and de and hl are both incremented by 1, and the Z flag is set if bc is decremented to 0. This operation is repeated until bc is equal to 0.

  • Opcode: 11101101 10110100
  • Bytes: 2
  • Flags:
    • Z: Set if bc is decremented to 0, reset otherwise
    • N: Set if msb of data is 1, reset otherwise
  • Cycles: 2F + (1R + 1W + 1) * bc

TSTIO

Reads a byte from port c. Then, a bitwise AND operation is performed on the byte read with imm8, and flags are affected accordingly.

  • Opcode: 11101101 01110100 imm8
  • Bytes: 3
  • Flags:
    • S: Affected as defined
    • Z: Affected as defined
    • H: Set
    • P/V: Detects parity
    • N: Reset
    • C: Reset
  • Cycles: 3F + 1R