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

Functions

def print_insn_detail (insn)
 
def test_class ()
 

Variables

string SPARC_CODE = b"\x80\xa0\x40\x02\x85\xc2\x60\x08\x85\xe8\x20\x01\x81\xe8\x00\x00\x90\x10\x20\x01\xd5\xf6\x10\x16\x21\x00\x00\x0a\x86\x00\x40\x02\x01\x00\x00\x00\x12\xbf\xff\xff\x10\xbf\xff\xff\xa0\x02\x00\x09\x0d\xbf\xff\xff\xd4\x20\x60\x00\xd4\x4e\x00\x16\x2a\xc2\x80\x03"
 
string SPARCV9_CODE = b"\x81\xa8\x0a\x24\x89\xa0\x10\x20\x89\xa0\x1a\x60\x89\xa0\x00\xe0"
 
tuple all_tests
 

Function Documentation

◆ print_insn_detail()

def test_sparc.print_insn_detail (   insn)

Definition at line 20 of file test_sparc.py.

20 def print_insn_detail(insn):
21  # print address, mnemonic and operands
22  print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))
23 
24  # "data" instruction generated by SKIPDATA option has no detail
25  if insn.id == 0:
26  return
27 
28  if len(insn.operands) > 0:
29  print("\top_count: %u" % len(insn.operands))
30  c = 0
31  for i in insn.operands:
32  if i.type == SPARC_OP_REG:
33  print("\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
34  if i.type == SPARC_OP_IMM:
35  print("\t\toperands[%u].type: IMM = 0x%s" % (c, to_x_32(i.imm)))
36  if i.type == SPARC_OP_MEM:
37  print("\t\toperands[%u].type: MEM" % c)
38  if i.mem.base != 0:
39  print("\t\t\toperands[%u].mem.base: REG = %s" \
40  % (c, insn.reg_name(i.mem.base)))
41  if i.mem.index != 0:
42  print("\t\t\toperands[%u].mem.index: REG = %s" \
43  % (c, insn.reg_name(i.mem.index)))
44  if i.mem.disp != 0:
45  print("\t\t\toperands[%u].mem.disp: 0x%s" \
46  % (c, to_x_32(i.mem.disp)))
47  c += 1
48 
49  if insn.cc:
50  print("\tCode condition: %u" % insn.cc)
51  if insn.hint:
52  print("\tHint code: %u" % insn.hint)
53 
54 
55 # ## Test class Cs
size_t len
Definition: 6502dis.c:15
def print_insn_detail(insn)
Definition: test_sparc.py:20
def to_x_32(s)
Definition: xprint.py:36

References len, and xprint.to_x_32().

Referenced by test_class().

◆ test_class()

def test_sparc.test_class ( )

Definition at line 56 of file test_sparc.py.

56 def test_class():
57  for (arch, mode, code, comment) in all_tests:
58  print("*" * 16)
59  print("Platform: %s" % comment)
60  print("Code: %s" % to_hex(code))
61  print("Disasm:")
62 
63  try:
64  md = Cs(arch, mode)
65  md.detail = True
66  for insn in md.disasm(code, 0x1000):
67  print_insn_detail(insn)
68  print ()
69  print("0x%x:\n" % (insn.address + insn.size))
70  except CsError as e:
71  print("ERROR: %s" %e)
72 
73 
def test_class()
Definition: test_sparc.py:56
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_sparc.all_tests
Initial value:
1 = (
2  (CS_ARCH_SPARC, CS_MODE_BIG_ENDIAN, SPARC_CODE, "Sparc"),
3  (CS_ARCH_SPARC, CS_MODE_BIG_ENDIAN+CS_MODE_V9, SPARCV9_CODE, "SparcV9"),
4 )

Definition at line 14 of file test_sparc.py.

◆ SPARC_CODE

string test_sparc.SPARC_CODE = b"\x80\xa0\x40\x02\x85\xc2\x60\x08\x85\xe8\x20\x01\x81\xe8\x00\x00\x90\x10\x20\x01\xd5\xf6\x10\x16\x21\x00\x00\x0a\x86\x00\x40\x02\x01\x00\x00\x00\x12\xbf\xff\xff\x10\xbf\xff\xff\xa0\x02\x00\x09\x0d\xbf\xff\xff\xd4\x20\x60\x00\xd4\x4e\x00\x16\x2a\xc2\x80\x03"

Definition at line 11 of file test_sparc.py.

◆ SPARCV9_CODE

string test_sparc.SPARCV9_CODE = b"\x81\xa8\x0a\x24\x89\xa0\x10\x20\x89\xa0\x1a\x60\x89\xa0\x00\xe0"

Definition at line 12 of file test_sparc.py.