Rizin
unix-like reverse engineering framework and cli tools
TestSystemz Class Reference

Static Public Member Functions

static void print_ins_detail (Capstone.CsInsn ins)
 
static void main (String argv[])
 

Static Public Attributes

static Capstone cs
 

Static Package Functions

static byte[] hexString2Byte (String s)
 

Static Package Attributes

static final String SYSZ_CODE = "ed000000001a5a0f1fffc2098000000007f7eb2affff7f57e301ffff7f57eb00f0000024b24f0078ec180000c17f"
 

Static Private Member Functions

static String hex (int i)
 
static String hex (long i)
 

Detailed Description

Definition at line 9 of file TestSystemz.java.

Member Function Documentation

◆ hex() [1/2]

static String TestSystemz.hex ( int  i)
inlinestaticprivate

Definition at line 26 of file TestSystemz.java.

26  {
27  return Integer.toString(i, 16);
28  }
lzma_index ** i
Definition: index.h:629

References i.

◆ hex() [2/2]

static String TestSystemz.hex ( long  i)
inlinestaticprivate

Definition at line 30 of file TestSystemz.java.

30  {
31  return Long.toString(i, 16);
32  }

References i.

◆ hexString2Byte()

static byte [] TestSystemz.hexString2Byte ( String  s)
inlinestaticpackage

Definition at line 11 of file TestSystemz.java.

11  {
12  // from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
13  int len = s.length();
14  byte[] data = new byte[len / 2];
15  for (int i = 0; i < len; i += 2) {
16  data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
17  + Character.digit(s.charAt(i+1), 16));
18  }
19  return data;
20  }
size_t len
Definition: 6502dis.c:15
static RzSocket * s
Definition: rtr.c:28

References i, len, and s.

Referenced by main().

◆ main()

static void TestSystemz.main ( String  argv[])
inlinestatic

Definition at line 68 of file TestSystemz.java.

68  {
69 
70  final TestBasic.platform[] all_tests = {
71  new TestBasic.platform(Capstone.CS_ARCH_SYSZ, 0, hexString2Byte(SYSZ_CODE), "SystemZ"),
72  };
73 
74  for (int i=0; i<all_tests.length; i++) {
76  System.out.println(new String(new char[16]).replace("\0", "*"));
77  System.out.println("Platform: " + test.comment);
78  System.out.println("Code: " + TestBasic.stringToHex(test.code));
79  System.out.println("Disasm:");
80 
81  cs = new Capstone(test.arch, test.mode);
82  cs.setDetail(Capstone.CS_OPT_ON);
83  Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
84 
85  for (int j = 0; j < all_ins.length; j++) {
86  print_ins_detail(all_ins[j]);
87  System.out.println();
88  }
89  System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
90 
91  // Close when done
92  cs.close();
93  }
94  }
static String stringToHex(byte[] code)
Definition: TestBasic.java:30
static Capstone cs
static byte[] hexString2Byte(String s)
static final String SYSZ_CODE
static void print_ins_detail(Capstone.CsInsn ins)
tuple all_tests
Definition: test_arm.py:18
-lz4-versions
int replace(char *string, const char *token, const char *fmt,...)
Definition: tms320_dasm.c:325

References test_arm.all_tests, cs, hexString2Byte(), i, print_ins_detail(), replace(), TestBasic.stringToHex(), and SYSZ_CODE.

◆ print_ins_detail()

static void TestSystemz.print_ins_detail ( Capstone.CsInsn  ins)
inlinestatic

Definition at line 34 of file TestSystemz.java.

34  {
35  System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
36 
37  Systemz.OpInfo operands = (Systemz.OpInfo) ins.operands;
38 
39  if (operands.op.length != 0) {
40  System.out.printf("\top_count: %d\n", operands.op.length);
41  for (int c=0; c<operands.op.length; c++) {
43  if (i.type == SYSZ_OP_REG)
44  System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
45  if (i.type == SYSZ_OP_ACREG)
46  System.out.printf("\t\toperands[%d].type: ACREG = %s\n", c, i.value.reg);
47  if (i.type == SYSZ_OP_IMM)
48  System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
49  if (i.type == SYSZ_OP_MEM) {
50  System.out.printf("\t\toperands[%d].type: MEM\n", c);
51  if (i.value.mem.base != SYSZ_REG_INVALID)
52  System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, ins.regName(i.value.mem.base));
53  if (i.value.mem.index != SYSZ_REG_INVALID)
54  System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, ins.regName(i.value.mem.index));
55  if (i.value.mem.length != 0)
56  System.out.printf("\t\t\toperands[%d].mem.length: 0x%x\n", c, i.value.mem.disp);
57  if (i.value.mem.disp != 0)
58  System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
59  }
60  }
61  }
62 
63  if (operands.cc != 0)
64  System.out.printf("\tConditional code: %d\n", operands.cc);
65 
66  }
@ SYSZ_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: systemz.h:42
@ SYSZ_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: systemz.h:41
@ SYSZ_OP_ACREG
Access register operand.
Definition: systemz.h:43
@ SYSZ_OP_REG
= CS_OP_REG (Register operand).
Definition: systemz.h:40
@ SYSZ_REG_INVALID
Definition: systemz.h:48
#define c(i)
Definition: sha256.c:43
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4

References c, i, if(), SYSZ_OP_ACREG, SYSZ_OP_IMM, SYSZ_OP_MEM, SYSZ_OP_REG, and SYSZ_REG_INVALID.

Referenced by main().

Member Data Documentation

◆ cs

Capstone TestSystemz.cs
static

Definition at line 24 of file TestSystemz.java.

Referenced by main().

◆ SYSZ_CODE

final String TestSystemz.SYSZ_CODE = "ed000000001a5a0f1fffc2098000000007f7eb2affff7f57e301ffff7f57eb00f0000024b24f0078ec180000c17f"
staticpackage

Definition at line 22 of file TestSystemz.java.

Referenced by main().


The documentation for this class was generated from the following file: