def __io_addr_reg(op):
    """
    Return the i/o port address 'A' and register Rr/Rd from a 2-byte IN or OUT opcode sequence
    """
    AVR_IO_IN_ADDR_MASK = 0x060F  # mask for 'A' address for opcode `IN Rd,A`. nb non-contiguous
    addr_part = op & AVR_IO_IN_ADDR_MASK
    addr = ((addr_part >> 5) & 0x0030) | (addr_part & 0x0F)

    AVR_IO_IN_REG_MASK = 0x01F0
    reg_part = op & AVR_IO_IN_REG_MASK
    reg = (reg_part >> 4) & 0x01F
    return (addr, reg)