Rizin
unix-like reverse engineering framework and cli tools
test_m68k Namespace Reference

Functions

def print_read_write_regs (insn)
 
def print_insn_detail (insn)
 
def test_class ()
 

Variables

string M68K_CODE = b"\x4c\x00\x54\x04\x48\xe7\xe0\x30\x4c\xdf\x0c\x07\xd4\x40\x87\x5a\x4e\x71\x02\xb4\xc0\xde\xc0\xde\x5c\x00\x1d\x80\x71\x12\x01\x23\xf2\x3c\x44\x22\x40\x49\x0e\x56\x54\xc5\xf2\x3c\x44\x00\x44\x7a\x00\x00\xf2\x00\x0a\x28\x4e\xb9\x00\x00\x00\x12\x4e\x75"
 
tuple all_tests
 
dictionary s_addressing_modes
 

Function Documentation

◆ print_insn_detail()

def test_m68k.print_insn_detail (   insn)

Definition at line 54 of file test_m68k.py.

54 def print_insn_detail(insn):
55  if len(insn.operands) > 0:
56  print("\top_count: %u" % (len(insn.operands)))
57  print("\tgroups_count: %u" % len(insn.groups))
58 
60 
61  for i, op in enumerate(insn.operands):
62  if op.type == M68K_OP_REG:
63  print("\t\toperands[%u].type: REG = %s" % (i, insn.reg_name(op.reg)))
64  elif op.type == M68K_OP_IMM:
65  print("\t\toperands[%u].type: IMM = 0x%x" % (i, op.imm & 0xffffffff))
66  elif op.type == M68K_OP_MEM:
67  print("\t\toperands[%u].type: MEM" % (i))
68  if op.mem.base_reg != M68K_REG_INVALID:
69  print("\t\t\toperands[%u].mem.base: REG = %s" % (i, insn.reg_name(op.mem.base_reg)))
70  if op.mem.index_reg != M68K_REG_INVALID:
71  print("\t\t\toperands[%u].mem.index: REG = %s" % (i, insn.reg_name(op.mem.index_reg)))
72  mem_index_str = "w"
73  if op.mem.index_size > 0:
74  mem_index_str = "l"
75  print("\t\t\toperands[%u].mem.index: size = %s" % (i, mem_index_str))
76  if op.mem.disp != 0:
77  print("\t\t\toperands[%u].mem.disp: 0x%x" % (i, op.mem.disp))
78  if op.mem.scale != 0:
79  print("\t\t\toperands[%u].mem.scale: %d" % (i, op.mem.scale))
80  print("\t\taddress mode: %s" % (s_addressing_modes[op.address_mode]))
81  elif op.type == M68K_OP_FP_SINGLE:
82  print("\t\toperands[%u].type: FP_SINGLE" % i)
83  print("\t\toperands[%u].simm: %f", i, op.simm)
84  elif op.type == M68K_OP_FP_DOUBLE:
85  print("\t\toperands[%u].type: FP_DOUBLE" % i)
86  print("\t\toperands[%u].dimm: %lf", i, op.dimm)
87  elif op.type == M68K_OP_BR_DISP:
88  print("\t\toperands[%u].br_disp.disp: 0x%x" % (i, op.br_disp.disp))
89  print("\t\toperands[%u].br_disp.disp_size: %d" % (i, op.br_disp.disp_size))
90  print()
91 
92 # ## Test class Cs
size_t len
Definition: 6502dis.c:15
void print_read_write_regs(csh handle, cs_detail *detail)
Definition: cstool_m680x.c:13
def print_insn_detail(insn)
Definition: test_m68k.py:54

References len, and print_read_write_regs().

Referenced by test_class().

◆ print_read_write_regs()

def test_m68k.print_read_write_regs (   insn)

Definition at line 47 of file test_m68k.py.

47 def print_read_write_regs(insn):
48  for m in insn.regs_read:
49  print("\treading from reg: %s" % insn.reg_name(m))
50 
51  for m in insn.regs_write:
52  print("\twriting to reg: %s" % insn.reg_name(m))
53 

Referenced by print_insn_detail().

◆ test_class()

def test_m68k.test_class ( )

Definition at line 93 of file test_m68k.py.

93 def test_class():
94  address = 0x01000
95  for (arch, mode, code, comment) in all_tests:
96  print("*" * 16)
97  print("Platform: %s" % comment)
98  print("Code: %s " % to_hex(code))
99  print("Disasm:")
100 
101  try:
102  md = Cs(arch, mode)
103  md.detail = True
104  last_address = 0
105  for insn in md.disasm(code, address):
106  last_address = insn.address + insn.size
107  print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))
108  print_insn_detail(insn)
109  print("0x%x:\n" % (last_address))
110 
111  except CsError as e:
112  print("ERROR: %s" % e.__str__())
113 
def test_class()
Definition: test_m68k.py:93
def to_hex(s, prefix_0x=True)
Definition: xprint.py:9

References print_insn_detail(), and xprint.to_hex().

Variable Documentation

◆ all_tests

tuple test_m68k.all_tests
Initial value:
1 = (
2  (CS_ARCH_M68K, CS_MODE_BIG_ENDIAN | CS_MODE_M68K_040, M68K_CODE, "M68K"),
3 )

Definition at line 11 of file test_m68k.py.

◆ M68K_CODE

string test_m68k.M68K_CODE = b"\x4c\x00\x54\x04\x48\xe7\xe0\x30\x4c\xdf\x0c\x07\xd4\x40\x87\x5a\x4e\x71\x02\xb4\xc0\xde\xc0\xde\x5c\x00\x1d\x80\x71\x12\x01\x23\xf2\x3c\x44\x22\x40\x49\x0e\x56\x54\xc5\xf2\x3c\x44\x00\x44\x7a\x00\x00\xf2\x00\x0a\x28\x4e\xb9\x00\x00\x00\x12\x4e\x75"

Definition at line 9 of file test_m68k.py.

◆ s_addressing_modes

dictionary test_m68k.s_addressing_modes

Definition at line 15 of file test_m68k.py.