def __subi_rd_i(op):
    """
    Return Rd and immediate parts from a SUBI opcode.
    """
    AVR_SUBI_RD_MASK = 0x00F0
    AVR_SUBI_CONST_MASK = 0x0F0F

    imm_part = op & AVR_SUBI_CONST_MASK
    imm = ((imm_part >> 4) & 0xF0) | (imm_part & 0xF)

    # rd_part is 4 bits and indicates 16 <= Rd <= 31
    rd_part = (op & AVR_SUBI_RD_MASK) >> 4
    rd = 16 + rd_part

    return (rd, imm)