from capstone import ( CS_AC_READ, CS_AC_WRITE, CS_ARCH_C166, CS_MODE_LITTLE_ENDIAN, Cs, ) from capstone.c166_const import ( C166_CC_Z, C166_MEM_BIT, C166_MEM_DIRECT, C166_MEM_SHORT, C166_OP_IMM, C166_OP_MEM, C166_OP_REG, C166_REG_R4, ) def test(): md = Cs(CS_ARCH_C166, CS_MODE_LITTLE_ENDIAN) md.detail = True code = bytes.fromhex("e6f434122dfe5ff4f2f46745e6103412") insns = list(md.disasm(code, 0x120100)) assert [insn.mnemonic for insn in insns] == [ "mov", "jmpr", "bset", "mov", "mov", ] assert insns[0].operands[0].type == C166_OP_REG assert insns[0].operands[0].reg == C166_REG_R4 assert insns[0].operands[0].access == CS_AC_WRITE assert insns[0].operands[1].type == C166_OP_IMM assert insns[0].operands[1].imm == 0x1234 assert insns[0].operands[1].access == CS_AC_READ assert insns[1].cc == C166_CC_Z assert insns[1].operands[0].imm == 0x120102 assert insns[2].operands[0].type == C166_OP_MEM assert insns[2].operands[0].mem.type == C166_MEM_BIT assert insns[2].operands[0].mem.base == C166_REG_R4 assert insns[2].operands[0].bit == 5 assert insns[3].operands[1].mem.type == C166_MEM_DIRECT assert insns[3].operands[1].mem.address == 0x4567 assert insns[4].operands[0].mem.type == C166_MEM_SHORT assert insns[4].operands[0].mem.address == 0xFE20 if __name__ == "__main__": test()