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

Functions

def print_insn_detail (insn)
 
def test_class ()
 

Variables

string MIPS_CODE = b"\x0C\x10\x00\x97\x00\x00\x00\x00\x24\x02\x00\x0c\x8f\xa2\x00\x00\x34\x21\x34\x56"
 
string MIPS_CODE2 = b"\x56\x34\x21\x34\xc2\x17\x01\x00"
 
string MIPS_32R6M = b"\x00\x07\x00\x07\x00\x11\x93\x7c\x01\x8c\x8b\x7c\x00\xc7\x48\xd0"
 
string MIPS_32R6 = b"\xec\x80\x00\x19\x7c\x43\x22\xa0"
 
tuple all_tests
 

Function Documentation

◆ print_insn_detail()

def test_mips.print_insn_detail (   insn)

Definition at line 23 of file test_mips.py.

23 def print_insn_detail(insn):
24  # print address, mnemonic and operands
25  print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))
26 
27  # "data" instruction generated by SKIPDATA option has no detail
28  if insn.id == 0:
29  return
30 
31  if len(insn.operands) > 0:
32  print("\top_count: %u" % len(insn.operands))
33  c = -1
34  for i in insn.operands:
35  c += 1
36  if i.type == MIPS_OP_REG:
37  print("\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
38  if i.type == MIPS_OP_IMM:
39  print("\t\toperands[%u].type: IMM = 0x%s" % (c, to_x(i.imm)))
40  if i.type == MIPS_OP_MEM:
41  print("\t\toperands[%u].type: MEM" % c)
42  if i.mem.base != 0:
43  print("\t\t\toperands[%u].mem.base: REG = %s" \
44  % (c, insn.reg_name(i.mem.base)))
45  if i.mem.disp != 0:
46  print("\t\t\toperands[%u].mem.disp: 0x%s" \
47  % (c, to_x(i.mem.disp)))
48 
49 
50 # ## Test class Cs
size_t len
Definition: 6502dis.c:15
def print_insn_detail(insn)
Definition: test_mips.py:23
def to_x(s)
Definition: xprint.py:29

References len, and xprint.to_x().

Referenced by test_class().

◆ test_class()

def test_mips.test_class ( )

Definition at line 51 of file test_mips.py.

51 def test_class():
52  for (arch, mode, code, comment) in all_tests:
53  print("*" * 16)
54  print("Platform: %s" % comment)
55  print("Code: %s" % to_hex(code))
56  print("Disasm:")
57 
58  try:
59  md = Cs(arch, mode)
60  md.detail = True
61  for insn in md.disasm(code, 0x1000):
62  print_insn_detail(insn)
63  print()
64 
65  print("0x%x:\n" % (insn.address + insn.size))
66  except CsError as e:
67  print("ERROR: %s" % e)
68 
69 
def test_class()
Definition: test_mips.py:51
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_mips.all_tests
Initial value:
1 = (
2  (CS_ARCH_MIPS, CS_MODE_MIPS32 + CS_MODE_BIG_ENDIAN, MIPS_CODE, "MIPS-32 (Big-endian)"),
3  (CS_ARCH_MIPS, CS_MODE_MIPS64 + CS_MODE_LITTLE_ENDIAN, MIPS_CODE2, "MIPS-64-EL (Little-endian)"),
4  (CS_ARCH_MIPS, CS_MODE_MIPS32R6 + CS_MODE_MICRO + CS_MODE_BIG_ENDIAN, MIPS_32R6M, "MIPS-32R6 | Micro (Big-endian)"),
5  (CS_ARCH_MIPS, CS_MODE_MIPS32R6 + CS_MODE_BIG_ENDIAN, MIPS_32R6, "MIPS-32R6 (Big-endian)"),
6 )

Definition at line 15 of file test_mips.py.

◆ MIPS_32R6

string test_mips.MIPS_32R6 = b"\xec\x80\x00\x19\x7c\x43\x22\xa0"

Definition at line 13 of file test_mips.py.

◆ MIPS_32R6M

string test_mips.MIPS_32R6M = b"\x00\x07\x00\x07\x00\x11\x93\x7c\x01\x8c\x8b\x7c\x00\xc7\x48\xd0"

Definition at line 12 of file test_mips.py.

◆ MIPS_CODE

string test_mips.MIPS_CODE = b"\x0C\x10\x00\x97\x00\x00\x00\x00\x24\x02\x00\x0c\x8f\xa2\x00\x00\x34\x21\x34\x56"

Definition at line 10 of file test_mips.py.

◆ MIPS_CODE2

string test_mips.MIPS_CODE2 = b"\x56\x34\x21\x34\xc2\x17\x01\x00"

Definition at line 11 of file test_mips.py.