python: update after the latest change on PPC in the core

This commit is contained in:
Nguyen Anh Quynh 2014-10-17 21:51:13 +08:00
parent aeaff79290
commit 4d2c362aa6
5 changed files with 33 additions and 7 deletions

View File

@ -14,8 +14,8 @@ public class Ppc_const {
public static final int PPC_BC_NE = (2<<5)|4;
public static final int PPC_BC_UN = (3<<5)|12;
public static final int PPC_BC_NU = (3<<5)|4;
public static final int PPC_BC_SO = 4<<5;
public static final int PPC_BC_NS = 4<<5;
public static final int PPC_BC_SO = (4<<5)|12;
public static final int PPC_BC_NS = (4<<5)|4;
// PPC branch hint for some branch instructions
@ -29,6 +29,7 @@ public class Ppc_const {
public static final int PPC_OP_REG = 1;
public static final int PPC_OP_IMM = 2;
public static final int PPC_OP_MEM = 3;
public static final int PPC_OP_CRX = 4;
// PPC registers

View File

@ -11,8 +11,8 @@ let _PPC_BC_GT = (1 lsl 5) lor 12;;
let _PPC_BC_NE = (2 lsl 5) lor 4;;
let _PPC_BC_UN = (3 lsl 5) lor 12;;
let _PPC_BC_NU = (3 lsl 5) lor 4;;
let _PPC_BC_SO = 4 lsl 5;;
let _PPC_BC_NS = 4 lsl 5;;
let _PPC_BC_SO = (4 lsl 5) lor 12;;
let _PPC_BC_NS = (4 lsl 5) lor 4;;
(* PPC branch hint for some branch instructions *)
@ -26,6 +26,7 @@ let _PPC_OP_INVALID = 0;;
let _PPC_OP_REG = 1;;
let _PPC_OP_IMM = 2;;
let _PPC_OP_MEM = 3;;
let _PPC_OP_CRX = 4;;
(* PPC registers *)

View File

@ -10,11 +10,19 @@ class PpcOpMem(ctypes.Structure):
('disp', ctypes.c_int32),
)
class PpcOpCrx(ctypes.Structure):
_fields_ = (
('scale', ctypes.c_uint),
('reg', ctypes.c_uint),
('cond', ctypes.c_uint),
)
class PpcOpValue(ctypes.Union):
_fields_ = (
('reg', ctypes.c_uint),
('imm', ctypes.c_int32),
('mem', PpcOpMem),
('crx', PpcOpCrx),
)
class PpcOp(ctypes.Structure):
@ -35,6 +43,10 @@ class PpcOp(ctypes.Structure):
def mem(self):
return self.value.mem
@property
def crx(self):
return self.value.crx
class CsPpc(ctypes.Structure):
_fields_ = (

View File

@ -11,8 +11,8 @@ PPC_BC_GT = (1<<5)|12
PPC_BC_NE = (2<<5)|4
PPC_BC_UN = (3<<5)|12
PPC_BC_NU = (3<<5)|4
PPC_BC_SO = 4<<5
PPC_BC_NS = 4<<5
PPC_BC_SO = (4<<5)|12
PPC_BC_NS = (4<<5)|4
# PPC branch hint for some branch instructions
@ -26,6 +26,7 @@ PPC_OP_INVALID = 0
PPC_OP_REG = 1
PPC_OP_IMM = 2
PPC_OP_MEM = 3
PPC_OP_CRX = 4
# PPC registers

View File

@ -5,7 +5,8 @@ from __future__ import print_function
from capstone import *
from capstone.ppc import *
from xprint import to_x, to_hex, to_x_32
PPC_CODE = b"\x80\x20\x00\x00\x80\x3f\x00\x00\x10\x43\x23\x0e\xd0\x44\x00\x80\x4c\x43\x22\x02\x2d\x03\x00\x80\x7c\x43\x20\x14\x7c\x43\x20\x93\x4f\x20\x00\x21\x4c\xc8\x00\x21\x40\x82\x00\x14"
PPC_CODE = b"\x43\x20\x0c\x07\x41\x56\xff\x17\x80\x20\x00\x00\x80\x3f\x00\x00\x10\x43\x23\x0e\xd0\x44\x00\x80\x4c\x43\x22\x02\x2d\x03\x00\x80\x7c\x43\x20\x14\x7c\x43\x20\x93\x4f\x20\x00\x21\x4c\xc8\x00\x21\x40\x82\x00\x14"
all_tests = (
(CS_ARCH_PPC, CS_MODE_BIG_ENDIAN, PPC_CODE, "PPC-64"),
@ -36,6 +37,16 @@ def print_insn_detail(insn):
if i.mem.disp != 0:
print("\t\t\toperands[%u].mem.disp: 0x%s" \
% (c, to_x_32(i.mem.disp)))
if i.type == PPC_OP_CRX:
print("\t\toperands[%u].type: CRX" % c)
print("\t\t\toperands[%u].crx.scale: = %s" \
% (c, i.crx.scale))
if i.crx.reg != 0:
print("\t\t\toperands[%u].crx.reg: REG = %s" \
% (c, insn.reg_name(i.crx.reg)))
if i.crx.cond != 0:
print("\t\t\toperands[%u].crx.cond: 0x%s" \
% (c, to_x_32(i.crx.cond)))
c += 1
if insn.bc: