Update java binding for PPC arch

This commit is contained in:
danghvu 2014-01-05 03:36:35 +07:00
parent 5611de05a9
commit c476765086
8 changed files with 1485 additions and 13 deletions

View File

@ -12,7 +12,9 @@ else
endif
endif
CAPSTONE_JAVA = Capstone.java Arm_const.java Arm64_const.java Mips_const.java X86_const.java Arm.java Arm64.java Mips.java X86.java
CAPSTONE_JAVA = Capstone.java Arm_const.java Arm64_const.java Mips_const.java \
X86_const.java Ppc_const.java \
Arm.java Arm64.java Mips.java X86.java Ppc.java
all: gen_const capstone tests
@ -23,7 +25,7 @@ capstone_class: jna
cd capstone; javac -classpath $(JNA) $(CAPSTONE_JAVA)
tests: jna
javac -classpath "$(JNA):capstone.jar" Test.java TestArm.java TestArm64.java TestMips.java TestX86.java
javac -classpath "$(JNA):capstone.jar" Test.java TestArm.java TestArm64.java TestMips.java TestX86.java TestPpc.java
gen_const:
cd ../; python const_generator.py java

View File

@ -37,68 +37,71 @@ public class Test {
return buf.toString();
}
public static final byte[] PPC_CODE = new byte[] {(byte)0x80, (byte)0x20, (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x3f, (byte)0x00, (byte)0x00, (byte)0x10, (byte)0x43, (byte)0x23, (byte)0x0e, (byte)0xd0, (byte)0x44, (byte)0x00, (byte)0x80, (byte)0x4c, (byte)0x43, (byte)0x22, (byte)0x02, (byte)0x2d, (byte)0x03, (byte)0x00, (byte)0x80, (byte)0x7c, (byte)0x43, (byte)0x20, (byte)0x14, (byte)0x7c, (byte)0x43, (byte)0x20, (byte)0x93, (byte)0x4f, (byte)0x20, (byte)0x00, (byte)0x21, (byte)0x4c, (byte)0xc8, (byte)0x00, (byte)0x21 };
public static final byte[] X86_CODE = new byte[] { (byte)0x8d, (byte)0x4c, (byte)0x32, (byte)0x08, (byte)0x01, (byte)0xd8, (byte)0x81, (byte)0xc6, (byte)0x34, (byte)0x12, (byte)0x00, (byte)0x00 };
static public void main(String argv[]) {
platform[] platforms = {
new platform(
Capstone.CS_ARCH_X86,
Capstone.CS_MODE_16,
Capstone.CS_OPT_SYNTAX_INTEL,
new byte[] { (byte)0x8d, (byte)0x4c, (byte)0x32, (byte)0x08, (byte)0x01, (byte)0xd8, (byte)0x81, (byte)0xc6, (byte)0x34, (byte)0x12, 0x00, 0x00 },
new byte[] { (byte)0x8d, (byte)0x4c, (byte)0x32, (byte)0x08, (byte)0x01, (byte)0xd8, (byte)0x81, (byte)0xc6, (byte)0x34, (byte)0x12, (byte)0x00, (byte)0x00 },
"X86 16bit (Intel syntax)"
),
new platform(
Capstone.CS_ARCH_X86,
Capstone.CS_MODE_32,
Capstone.CS_OPT_SYNTAX_ATT,
new byte[] { (byte)0x8d, 0x4c, 0x32, 0x08, 0x01, (byte)0xd8, (byte)0x81, (byte)0xc6, 0x34, 0x12, 0x00, 0x00 },
X86_CODE,
"X86 32bit (ATT syntax)"
),
new platform(
Capstone.CS_ARCH_X86,
Capstone.CS_MODE_32,
new byte[] { (byte)0x8d, 0x4c, 0x32, 0x08, 0x01, (byte)0xd8, (byte)0x81, (byte)0xc6, 0x34, 0x12, 0x00, 0x00 },
X86_CODE,
"X86 32 (Intel syntax)"
),
new platform(
Capstone.CS_ARCH_X86,
Capstone.CS_MODE_64,
new byte[] { 0x55, 0x48, (byte)0x8b, 0x05, (byte)0xb8, 0x13, 0x00, 0x00 },
new byte[] {(byte)0x55, (byte)0x48, (byte)0x8b, (byte)0x05, (byte)0xb8, (byte)0x13, (byte)0x00, (byte)0x00 },
"X86 64 (Intel syntax)"
),
new platform(
Capstone.CS_ARCH_ARM,
Capstone.CS_MODE_ARM,
new byte[] { (byte)0xED, (byte)0xFF, (byte)0xFF, (byte)0xEB, 0x04, (byte)0xe0, 0x2d, (byte)0xe5, 0x00, 0x00, 0x00, 0x00, (byte)0xe0, (byte)0x83, 0x22, (byte)0xe5, (byte)0xf1, 0x02, 0x03, 0x0e, 0x00, 0x00, (byte)0xa0, (byte)0xe3, 0x02, 0x30, (byte)0xc1, (byte)0xe7, 0x00, 0x00, 0x53, (byte)0xe3 },
new byte[] { (byte)0xED, (byte)0xFF, (byte)0xFF, (byte)0xEB, (byte)0x04, (byte)0xe0, (byte)0x2d, (byte)0xe5, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xe0, (byte)0x83, (byte)0x22, (byte)0xe5, (byte)0xf1, (byte)0x02, (byte)0x03, (byte)0x0e, (byte)0x00, (byte)0x00, (byte)0xa0, (byte)0xe3, (byte)0x02, (byte)0x30, (byte)0xc1, (byte)0xe7, (byte)0x00, (byte)0x00, (byte)0x53, (byte)0xe3 },
"ARM"
),
new platform(
Capstone.CS_ARCH_ARM,
Capstone.CS_MODE_THUMB,
new byte[] { 0x4f, (byte)0xf0, 0x00, 0x01, (byte)0xbd, (byte)0xe8, 0x00, (byte)0x88, (byte)0xd1, (byte)0xe8, 0x00, (byte)0xf0 },
new byte[] {(byte)0x4f, (byte)0xf0, (byte)0x00, (byte)0x01, (byte)0xbd, (byte)0xe8, (byte)0x00, (byte)0x88, (byte)0xd1, (byte)0xe8, (byte)0x00, (byte)0xf0 },
"THUMB-2"
),
new platform(
Capstone.CS_ARCH_ARM,
Capstone.CS_MODE_ARM,
new byte[] { 0x10, (byte)0xf1, 0x10, (byte)0xe7, 0x11, (byte)0xf2, 0x31, (byte)0xe7, (byte)0xdc, (byte)0xa1, 0x2e, (byte)0xf3, (byte)0xe8, 0x4e, 0x62, (byte)0xf3 },
new byte[] {(byte)0x10, (byte)0xf1, (byte)0x10, (byte)0xe7, (byte)0x11, (byte)0xf2, (byte)0x31, (byte)0xe7, (byte)0xdc, (byte)0xa1, (byte)0x2e, (byte)0xf3, (byte)0xe8, (byte)0x4e, (byte)0x62, (byte)0xf3 },
"ARM: Cortex-A15 + NEON"
),
new platform(
Capstone.CS_ARCH_ARM,
Capstone.CS_MODE_THUMB,
new byte[] { 0x70, 0x47, (byte)0xeb, 0x46, (byte)0x83, (byte)0xb0, (byte)0xc9, 0x68 },
new byte[] {(byte)0x70, (byte)0x47, (byte)0xeb, (byte)0x46, (byte)0x83, (byte)0xb0, (byte)0xc9, (byte)0x68 },
"THUMB"
),
new platform(
Capstone.CS_ARCH_MIPS,
Capstone.CS_MODE_32 + Capstone.CS_MODE_BIG_ENDIAN,
new byte[] { 0x0C, 0x10, 0x00, (byte)0x97, 0x00, 0x00, 0x00, 0x00, 0x24, 0x02, 0x00, 0x0c, (byte)0x8f, (byte)0xa2, 0x00, 0x00, 0x34, 0x21, 0x34, 0x56 },
new byte[] {(byte)0x0C, (byte)0x10, (byte)0x00, (byte)0x97, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x24, (byte)0x02, (byte)0x00, (byte)0x0c, (byte)0x8f, (byte)0xa2, (byte)0x00, (byte)0x00, (byte)0x34, (byte)0x21, (byte)0x34, (byte)0x56 },
"MIPS-32 (Big-endian)"
),
new platform(
Capstone.CS_ARCH_MIPS,
Capstone.CS_MODE_64+ Capstone.CS_MODE_LITTLE_ENDIAN,
new byte[] { 0x56, 0x34, 0x21, 0x34, (byte)0xc2, 0x17, 0x01, 0x00 },
new byte[] {(byte)0x56, (byte)0x34, (byte)0x21, (byte)0x34, (byte)0xc2, (byte)0x17, (byte)0x01, (byte)0x00 },
"MIPS-64-EL (Little-endian)"
),
new platform(
@ -107,6 +110,19 @@ public class Test {
new byte [] { 0x21, 0x7c, 0x02, (byte)0x9b, 0x21, 0x7c, 0x00, 0x53, 0x00, 0x40, 0x21, 0x4b, (byte)0xe1, 0x0b, 0x40, (byte)0xb9 },
"ARM-64"
),
new platform (
Capstone.CS_ARCH_PPC,
Capstone.CS_MODE_BIG_ENDIAN,
PPC_CODE,
"PPC-64"
),
new platform (
Capstone.CS_ARCH_PPC,
Capstone.CS_MODE_BIG_ENDIAN,
Capstone.CS_OPT_SYNTAX_NOREGNAME,
PPC_CODE,
"PPC-64, print register with number only"
),
};
for (int j = 0; j < platforms.length; j++) {

View File

@ -0,0 +1,90 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
import capstone.Capstone;
import capstone.Ppc;
import static capstone.Ppc_const.*;
public class TestPpc {
static byte[] hexString2Byte(String s) {
// from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
static final String PPC_CODE = "80200000803f00001043230ed04400804c4322022d0300807c4320147c4320934f2000214cc80021";
public static Capstone cs;
private static String hex(int i) {
return Integer.toString(i, 16);
}
private static String hex(long i) {
return Long.toString(i, 16);
}
public static void print_ins_detail(Capstone.CsInsn ins) {
System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
Ppc.OpInfo operands = (Ppc.OpInfo) ins.operands;
if (operands.op.length != 0) {
System.out.printf("\top_count: %d\n", operands.op.length);
for (int c=0; c<operands.op.length; c++) {
Ppc.Operand i = (Ppc.Operand) operands.op[c];
if (i.type == PPC_OP_REG)
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
if (i.type == PPC_OP_IMM)
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
if (i.type == PPC_OP_MEM) {
System.out.printf("\t\toperands[%d].type: MEM\n", c);
if (i.value.mem.base != PPC_REG_INVALID)
System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, ins.regName(i.value.mem.base));
if (i.value.mem.disp != 0)
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
}
}
}
if (operands.bc != 0)
System.out.printf("\tBranch code: %d\n", operands.bc);
if (operands.updateCr0)
System.out.printf("\tUpdate-CR0: True\n");
System.out.printf("\n");
}
public static void main(String argv[]) {
final Test.platform[] all_tests = {
new Test.platform(Capstone.CS_ARCH_PPC, Capstone.CS_MODE_BIG_ENDIAN, hexString2Byte(PPC_CODE), "PPC-64"),
};
for (int i=0; i<all_tests.length; i++) {
Test.platform test = all_tests[i];
System.out.println(new String(new char[16]).replace("\0", "*"));
System.out.println("Platform: " + test.comment);
System.out.println("Code: " + Test.stringToHex(test.code));
System.out.println("Disasm:");
cs = new Capstone(test.arch, test.mode);
Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
for (int j = 0; j < all_ins.length; j++) {
print_ins_detail(all_ins[j]);
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
}
}
}

View File

@ -29,6 +29,7 @@ public class Capstone {
public Arm64.UnionOpInfo arm64;
public X86.UnionOpInfo x86;
public Mips.UnionOpInfo mips;
public Ppc.UnionOpInfo ppc;
}
protected static class _cs_insn extends Structure {
@ -143,6 +144,11 @@ public class Capstone {
detail.arch.read();
op_info = new X86.OpInfo((X86.UnionOpInfo) detail.arch.x86);
break;
case CS_ARCH_PPC:
detail.arch.setType(Ppc.UnionOpInfo.class);
detail.arch.read();
op_info = new Ppc.OpInfo((Ppc.UnionOpInfo) detail.arch.ppc);
break;
default:
}
@ -221,6 +227,7 @@ public class Capstone {
public static final int CS_ARCH_ARM64 = 1;
public static final int CS_ARCH_MIPS = 2;
public static final int CS_ARCH_X86 = 3;
public static final int CS_ARCH_PPC = 4;
public static final int CS_MODE_LITTLE_ENDIAN = 0; // default mode
public static final int CS_MODE_ARM = 0; // 32-bit ARM
@ -250,6 +257,7 @@ public class Capstone {
public static final int CS_OPT_SYNTAX_INTEL = 1; // Intel X86 asm syntax - default syntax on X86 (CS_OPT_SYNTAX, CS_ARCH_X86)
public static final int CS_OPT_SYNTAX_ATT = 2; // ATT asm syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
public static final int CS_OPT_ON = 3; // Turn ON an option - this is default option for CS_OPT_DETAIL
public static final int CS_OPT_SYNTAX_NOREGNAME = 3; // PPC asm syntax: Prints register name with only number (CS_OPT_SYNTAX)
protected class NativeStruct {
private NativeLong csh;

View File

@ -0,0 +1,95 @@
// Capstone Java binding
// By Nguyen Anh Quynh & Dang Hoang Vu, 2013
package capstone;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import java.util.List;
import java.util.Arrays;
import static capstone.Ppc_const.*;
public class Ppc {
public static class MemType extends Structure {
public int base;
public int disp;
@Override
public List getFieldOrder() {
return Arrays.asList("base", "disp");
}
}
public static class OpValue extends Union {
public int reg;
public int imm;
public MemType mem;
}
public static class Operand extends Structure {
public int type;
public OpValue value;
public void read() {
readField("type");
if (type == PPC_OP_MEM)
value.setType(MemType.class);
if (type == PPC_OP_IMM || type == PPC_OP_REG)
value.setType(Integer.TYPE);
if (type == PPC_OP_INVALID)
return;
readField("value");
}
@Override
public List getFieldOrder() {
return Arrays.asList("type", "value");
}
}
public static class UnionOpInfo extends Capstone.UnionOpInfo {
public int bc;
public int bh;
public byte update_cr0;
public byte op_count;
public Operand [] op;
public UnionOpInfo() {
op = new Operand[8];
}
public void read() {
readField("bc");
readField("bh");
readField("update_cr0");
readField("op_count");
op = new Operand[op_count];
if (op_count != 0)
readField("op");
}
@Override
public List getFieldOrder() {
return Arrays.asList("bc", "bh", "update_cr0", "op_count", "op");
}
}
public static class OpInfo extends Capstone.OpInfo {
public int bc;
public int bh;
public boolean updateCr0;
public Operand [] op;
public OpInfo(UnionOpInfo op_info) {
bc = op_info.bc;
bh = op_info.bh;
updateCr0 = (op_info.update_cr0 > 0);
op = op_info.op;
}
}
}

View File

@ -0,0 +1,632 @@
// For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT
package capstone;
public class Ppc_const {
// PPC branch codes for some branch instructions
public static final int PPC_BC_LT = (0<<5)|12;
public static final int PPC_BC_LE = (1<<5)|4;
public static final int PPC_BC_EQ = (2<<5)|12;
public static final int PPC_BC_GE = (0<<5)|4;
public static final int PPC_BC_GT = (1<<5)|12;
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_LT_MINUS = (0<<5)|14;
public static final int PPC_BC_LE_MINUS = (1<<5)|6;
public static final int PPC_BC_EQ_MINUS = (2<<5)|14;
public static final int PPC_BC_GE_MINUS = (0<<5)|6;
public static final int PPC_BC_GT_MINUS = (1<<5)|14;
public static final int PPC_BC_NE_MINUS = (2<<5)|6;
public static final int PPC_BC_UN_MINUS = (3<<5)|14;
public static final int PPC_BC_NU_MINUS = (3<<5)|6;
public static final int PPC_BC_LT_PLUS = (0<<5)|15;
public static final int PPC_BC_LE_PLUS = (1<<5)|7;
public static final int PPC_BC_EQ_PLUS = (2<<5)|15;
public static final int PPC_BC_GE_PLUS = (0<<5)|7;
public static final int PPC_BC_GT_PLUS = (1<<5)|15;
public static final int PPC_BC_NE_PLUS = (2<<5)|7;
public static final int PPC_BC_UN_PLUS = (3<<5)|15;
public static final int PPC_BC_NU_PLUS = (3<<5)|7;
// PPC branch hint for some branch instructions
public static final int PPC_BH_NO = 0;
public static final int PPC_BH_PLUS = 1;
public static final int PPC_BH_MINUS = 2;
// Operand type for instruction's operands
public static final int PPC_OP_INVALID = 0;
public static final int PPC_OP_REG = 1;
public static final int PPC_OP_IMM = 2;
public static final int PPC_OP_MEM = 3;
// PPC registers
public static final int PPC_REG_INVALID = 0;
public static final int PPC_REG_CARRY = 1;
public static final int PPC_REG_CR0 = 2;
public static final int PPC_REG_CR1 = 3;
public static final int PPC_REG_CR2 = 4;
public static final int PPC_REG_CR3 = 5;
public static final int PPC_REG_CR4 = 6;
public static final int PPC_REG_CR5 = 7;
public static final int PPC_REG_CR6 = 8;
public static final int PPC_REG_CR7 = 9;
public static final int PPC_REG_CR8 = 10;
public static final int PPC_REG_CR9 = 11;
public static final int PPC_REG_CR10 = 12;
public static final int PPC_REG_CR11 = 13;
public static final int PPC_REG_CR12 = 14;
public static final int PPC_REG_CR13 = 15;
public static final int PPC_REG_CR14 = 16;
public static final int PPC_REG_CR15 = 17;
public static final int PPC_REG_CR16 = 18;
public static final int PPC_REG_CR17 = 19;
public static final int PPC_REG_CR18 = 20;
public static final int PPC_REG_CR19 = 21;
public static final int PPC_REG_CR20 = 22;
public static final int PPC_REG_CR21 = 23;
public static final int PPC_REG_CR22 = 24;
public static final int PPC_REG_CR23 = 25;
public static final int PPC_REG_CR24 = 26;
public static final int PPC_REG_CR25 = 27;
public static final int PPC_REG_CR26 = 28;
public static final int PPC_REG_CR27 = 29;
public static final int PPC_REG_CR28 = 30;
public static final int PPC_REG_CR29 = 31;
public static final int PPC_REG_CR30 = 32;
public static final int PPC_REG_CR31 = 33;
public static final int PPC_REG_CTR = 34;
public static final int PPC_REG_F0 = 35;
public static final int PPC_REG_F1 = 36;
public static final int PPC_REG_F2 = 37;
public static final int PPC_REG_F3 = 38;
public static final int PPC_REG_F4 = 39;
public static final int PPC_REG_F5 = 40;
public static final int PPC_REG_F6 = 41;
public static final int PPC_REG_F7 = 42;
public static final int PPC_REG_F8 = 43;
public static final int PPC_REG_F9 = 44;
public static final int PPC_REG_F10 = 45;
public static final int PPC_REG_F11 = 46;
public static final int PPC_REG_F12 = 47;
public static final int PPC_REG_F13 = 48;
public static final int PPC_REG_F14 = 49;
public static final int PPC_REG_F15 = 50;
public static final int PPC_REG_F16 = 51;
public static final int PPC_REG_F17 = 52;
public static final int PPC_REG_F18 = 53;
public static final int PPC_REG_F19 = 54;
public static final int PPC_REG_F20 = 55;
public static final int PPC_REG_F21 = 56;
public static final int PPC_REG_F22 = 57;
public static final int PPC_REG_F23 = 58;
public static final int PPC_REG_F24 = 59;
public static final int PPC_REG_F25 = 60;
public static final int PPC_REG_F26 = 61;
public static final int PPC_REG_F27 = 62;
public static final int PPC_REG_F28 = 63;
public static final int PPC_REG_F29 = 64;
public static final int PPC_REG_F30 = 65;
public static final int PPC_REG_F31 = 66;
public static final int PPC_REG_LR = 67;
public static final int PPC_REG_R0 = 68;
public static final int PPC_REG_R1 = 69;
public static final int PPC_REG_R2 = 70;
public static final int PPC_REG_R3 = 71;
public static final int PPC_REG_R4 = 72;
public static final int PPC_REG_R5 = 73;
public static final int PPC_REG_R6 = 74;
public static final int PPC_REG_R7 = 75;
public static final int PPC_REG_R8 = 76;
public static final int PPC_REG_R9 = 77;
public static final int PPC_REG_R10 = 78;
public static final int PPC_REG_R11 = 79;
public static final int PPC_REG_R12 = 80;
public static final int PPC_REG_R13 = 81;
public static final int PPC_REG_R14 = 82;
public static final int PPC_REG_R15 = 83;
public static final int PPC_REG_R16 = 84;
public static final int PPC_REG_R17 = 85;
public static final int PPC_REG_R18 = 86;
public static final int PPC_REG_R19 = 87;
public static final int PPC_REG_R20 = 88;
public static final int PPC_REG_R21 = 89;
public static final int PPC_REG_R22 = 90;
public static final int PPC_REG_R23 = 91;
public static final int PPC_REG_R24 = 92;
public static final int PPC_REG_R25 = 93;
public static final int PPC_REG_R26 = 94;
public static final int PPC_REG_R27 = 95;
public static final int PPC_REG_R28 = 96;
public static final int PPC_REG_R29 = 97;
public static final int PPC_REG_R30 = 98;
public static final int PPC_REG_R31 = 99;
public static final int PPC_REG_V0 = 100;
public static final int PPC_REG_V1 = 101;
public static final int PPC_REG_V2 = 102;
public static final int PPC_REG_V3 = 103;
public static final int PPC_REG_V4 = 104;
public static final int PPC_REG_V5 = 105;
public static final int PPC_REG_V6 = 106;
public static final int PPC_REG_V7 = 107;
public static final int PPC_REG_V8 = 108;
public static final int PPC_REG_V9 = 109;
public static final int PPC_REG_V10 = 110;
public static final int PPC_REG_V11 = 111;
public static final int PPC_REG_V12 = 112;
public static final int PPC_REG_V13 = 113;
public static final int PPC_REG_V14 = 114;
public static final int PPC_REG_V15 = 115;
public static final int PPC_REG_V16 = 116;
public static final int PPC_REG_V17 = 117;
public static final int PPC_REG_V18 = 118;
public static final int PPC_REG_V19 = 119;
public static final int PPC_REG_V20 = 120;
public static final int PPC_REG_V21 = 121;
public static final int PPC_REG_V22 = 122;
public static final int PPC_REG_V23 = 123;
public static final int PPC_REG_V24 = 124;
public static final int PPC_REG_V25 = 125;
public static final int PPC_REG_V26 = 126;
public static final int PPC_REG_V27 = 127;
public static final int PPC_REG_V28 = 128;
public static final int PPC_REG_V29 = 129;
public static final int PPC_REG_V30 = 130;
public static final int PPC_REG_V31 = 131;
public static final int PPC_REG_VRSAVE = 132;
public static final int PPC_REG_RM = 133;
public static final int PPC_REG_CTR8 = 134;
public static final int PPC_REG_LR8 = 135;
public static final int PPC_REG_CR1EQ = 136;
public static final int PPC_REG_MAX = 137;
// PPC instruction
public static final int PPC_INS_INVALID = 0;
public static final int PPC_INS_ADD = 1;
public static final int PPC_INS_ADDC = 2;
public static final int PPC_INS_ADDE = 3;
public static final int PPC_INS_ADDI = 4;
public static final int PPC_INS_ADDIC = 5;
public static final int PPC_INS_ADDIS = 6;
public static final int PPC_INS_ADDME = 7;
public static final int PPC_INS_ADDZE = 8;
public static final int PPC_INS_AND = 9;
public static final int PPC_INS_ANDC = 10;
public static final int PPC_INS_ANDIS = 11;
public static final int PPC_INS_ANDI = 12;
public static final int PPC_INS_B = 13;
public static final int PPC_INS_BA = 14;
public static final int PPC_INS_BCL = 15;
public static final int PPC_INS_BCTR = 16;
public static final int PPC_INS_BCTRL = 17;
public static final int PPC_INS_BDNZ = 18;
public static final int PPC_INS_BDNZA = 19;
public static final int PPC_INS_BDNZL = 20;
public static final int PPC_INS_BDNZLA = 21;
public static final int PPC_INS_BDNZLR = 22;
public static final int PPC_INS_BDNZLRL = 23;
public static final int PPC_INS_BDZ = 24;
public static final int PPC_INS_BDZA = 25;
public static final int PPC_INS_BDZL = 26;
public static final int PPC_INS_BDZLA = 27;
public static final int PPC_INS_BDZLR = 28;
public static final int PPC_INS_BDZLRL = 29;
public static final int PPC_INS_BL = 30;
public static final int PPC_INS_BLA = 31;
public static final int PPC_INS_BLR = 32;
public static final int PPC_INS_BLRL = 33;
public static final int PPC_INS_CMPD = 34;
public static final int PPC_INS_CMPDI = 35;
public static final int PPC_INS_CMPLD = 36;
public static final int PPC_INS_CMPLDI = 37;
public static final int PPC_INS_CMPLW = 38;
public static final int PPC_INS_CMPLWI = 39;
public static final int PPC_INS_CMPW = 40;
public static final int PPC_INS_CMPWI = 41;
public static final int PPC_INS_CNTLZD = 42;
public static final int PPC_INS_CNTLZW = 43;
public static final int PPC_INS_CREQV = 44;
public static final int PPC_INS_CRXOR = 45;
public static final int PPC_INS_CRAND = 46;
public static final int PPC_INS_CRANDC = 47;
public static final int PPC_INS_CRNAND = 48;
public static final int PPC_INS_CRNOR = 49;
public static final int PPC_INS_CROR = 50;
public static final int PPC_INS_CRORC = 51;
public static final int PPC_INS_DCBA = 52;
public static final int PPC_INS_DCBF = 53;
public static final int PPC_INS_DCBI = 54;
public static final int PPC_INS_DCBST = 55;
public static final int PPC_INS_DCBT = 56;
public static final int PPC_INS_DCBTST = 57;
public static final int PPC_INS_DCBZ = 58;
public static final int PPC_INS_DCBZL = 59;
public static final int PPC_INS_DIVD = 60;
public static final int PPC_INS_DIVDU = 61;
public static final int PPC_INS_DIVW = 62;
public static final int PPC_INS_DIVWU = 63;
public static final int PPC_INS_DSS = 64;
public static final int PPC_INS_DSSALL = 65;
public static final int PPC_INS_DST = 66;
public static final int PPC_INS_DSTST = 67;
public static final int PPC_INS_DSTSTT = 68;
public static final int PPC_INS_DSTT = 69;
public static final int PPC_INS_EIEIO = 70;
public static final int PPC_INS_EQV = 71;
public static final int PPC_INS_EXTSB = 72;
public static final int PPC_INS_EXTSH = 73;
public static final int PPC_INS_EXTSW = 74;
public static final int PPC_INS_FABS = 75;
public static final int PPC_INS_FADD = 76;
public static final int PPC_INS_FADDS = 77;
public static final int PPC_INS_FCFID = 78;
public static final int PPC_INS_FCFIDS = 79;
public static final int PPC_INS_FCFIDU = 80;
public static final int PPC_INS_FCFIDUS = 81;
public static final int PPC_INS_FCMPU = 82;
public static final int PPC_INS_FCPSGN = 83;
public static final int PPC_INS_FCTID = 84;
public static final int PPC_INS_FCTIDUZ = 85;
public static final int PPC_INS_FCTIDZ = 86;
public static final int PPC_INS_FCTIW = 87;
public static final int PPC_INS_FCTIWUZ = 88;
public static final int PPC_INS_FCTIWZ = 89;
public static final int PPC_INS_FDIV = 90;
public static final int PPC_INS_FDIVS = 91;
public static final int PPC_INS_FMADD = 92;
public static final int PPC_INS_FMADDS = 93;
public static final int PPC_INS_FMSUB = 94;
public static final int PPC_INS_FMSUBS = 95;
public static final int PPC_INS_FMUL = 96;
public static final int PPC_INS_FMULS = 97;
public static final int PPC_INS_FNABS = 98;
public static final int PPC_INS_FNEG = 99;
public static final int PPC_INS_FNMADD = 100;
public static final int PPC_INS_FNMADDS = 101;
public static final int PPC_INS_FNMSUB = 102;
public static final int PPC_INS_FNMSUBS = 103;
public static final int PPC_INS_FRE = 104;
public static final int PPC_INS_FRES = 105;
public static final int PPC_INS_FRIM = 106;
public static final int PPC_INS_FRIN = 107;
public static final int PPC_INS_FRIP = 108;
public static final int PPC_INS_FRIZ = 109;
public static final int PPC_INS_FRSP = 110;
public static final int PPC_INS_FRSQRTE = 111;
public static final int PPC_INS_FRSQRTES = 112;
public static final int PPC_INS_FSEL = 113;
public static final int PPC_INS_FSQRT = 114;
public static final int PPC_INS_FSQRTS = 115;
public static final int PPC_INS_FSUB = 116;
public static final int PPC_INS_FSUBS = 117;
public static final int PPC_INS_ICBI = 118;
public static final int PPC_INS_ISEL = 119;
public static final int PPC_INS_ISYNC = 120;
public static final int PPC_INS_LA = 121;
public static final int PPC_INS_LBZ = 122;
public static final int PPC_INS_LBZU = 123;
public static final int PPC_INS_LBZUX = 124;
public static final int PPC_INS_LBZX = 125;
public static final int PPC_INS_LD = 126;
public static final int PPC_INS_LDARX = 127;
public static final int PPC_INS_LDBRX = 128;
public static final int PPC_INS_LDU = 129;
public static final int PPC_INS_LDUX = 130;
public static final int PPC_INS_LDX = 131;
public static final int PPC_INS_LFD = 132;
public static final int PPC_INS_LFDU = 133;
public static final int PPC_INS_LFDUX = 134;
public static final int PPC_INS_LFDX = 135;
public static final int PPC_INS_LFIWAX = 136;
public static final int PPC_INS_LFIWZX = 137;
public static final int PPC_INS_LFS = 138;
public static final int PPC_INS_LFSU = 139;
public static final int PPC_INS_LFSUX = 140;
public static final int PPC_INS_LFSX = 141;
public static final int PPC_INS_LHA = 142;
public static final int PPC_INS_LHAU = 143;
public static final int PPC_INS_LHAUX = 144;
public static final int PPC_INS_LHAX = 145;
public static final int PPC_INS_LHBRX = 146;
public static final int PPC_INS_LHZ = 147;
public static final int PPC_INS_LHZU = 148;
public static final int PPC_INS_LHZUX = 149;
public static final int PPC_INS_LHZX = 150;
public static final int PPC_INS_LI = 151;
public static final int PPC_INS_LIS = 152;
public static final int PPC_INS_LMW = 153;
public static final int PPC_INS_LVEBX = 154;
public static final int PPC_INS_LVEHX = 155;
public static final int PPC_INS_LVEWX = 156;
public static final int PPC_INS_LVSL = 157;
public static final int PPC_INS_LVSR = 158;
public static final int PPC_INS_LVX = 159;
public static final int PPC_INS_LVXL = 160;
public static final int PPC_INS_LWA = 161;
public static final int PPC_INS_LWARX = 162;
public static final int PPC_INS_LWAUX = 163;
public static final int PPC_INS_LWAX = 164;
public static final int PPC_INS_LWBRX = 165;
public static final int PPC_INS_LWZ = 166;
public static final int PPC_INS_LWZU = 167;
public static final int PPC_INS_LWZUX = 168;
public static final int PPC_INS_LWZX = 169;
public static final int PPC_INS_MCRF = 170;
public static final int PPC_INS_MFCR = 171;
public static final int PPC_INS_MFCTR = 172;
public static final int PPC_INS_MFFS = 173;
public static final int PPC_INS_MFLR = 174;
public static final int PPC_INS_MFMSR = 175;
public static final int PPC_INS_MFOCRF = 176;
public static final int PPC_INS_MFSPR = 177;
public static final int PPC_INS_MFTB = 178;
public static final int PPC_INS_MFVSCR = 179;
public static final int PPC_INS_MTCRF = 180;
public static final int PPC_INS_MTCTR = 181;
public static final int PPC_INS_MTFSB0 = 182;
public static final int PPC_INS_MTFSB1 = 183;
public static final int PPC_INS_MTFSF = 184;
public static final int PPC_INS_MTLR = 185;
public static final int PPC_INS_MTMSR = 186;
public static final int PPC_INS_MTMSRD = 187;
public static final int PPC_INS_MTOCRF = 188;
public static final int PPC_INS_MTSPR = 189;
public static final int PPC_INS_MTVSCR = 190;
public static final int PPC_INS_MULHD = 191;
public static final int PPC_INS_MULHDU = 192;
public static final int PPC_INS_MULHW = 193;
public static final int PPC_INS_MULHWU = 194;
public static final int PPC_INS_MULLD = 195;
public static final int PPC_INS_MULLI = 196;
public static final int PPC_INS_MULLW = 197;
public static final int PPC_INS_NAND = 198;
public static final int PPC_INS_NEG = 199;
public static final int PPC_INS_NOP = 200;
public static final int PPC_INS_ORI = 201;
public static final int PPC_INS_NOR = 202;
public static final int PPC_INS_OR = 203;
public static final int PPC_INS_ORC = 204;
public static final int PPC_INS_ORIS = 205;
public static final int PPC_INS_POPCNTD = 206;
public static final int PPC_INS_POPCNTW = 207;
public static final int PPC_INS_RLDCL = 208;
public static final int PPC_INS_RLDCR = 209;
public static final int PPC_INS_RLDIC = 210;
public static final int PPC_INS_RLDICL = 211;
public static final int PPC_INS_RLDICR = 212;
public static final int PPC_INS_RLDIMI = 213;
public static final int PPC_INS_RLWIMI = 214;
public static final int PPC_INS_RLWINM = 215;
public static final int PPC_INS_RLWNM = 216;
public static final int PPC_INS_SC = 217;
public static final int PPC_INS_SLBIA = 218;
public static final int PPC_INS_SLBIE = 219;
public static final int PPC_INS_SLBMFEE = 220;
public static final int PPC_INS_SLBMTE = 221;
public static final int PPC_INS_SLD = 222;
public static final int PPC_INS_SLW = 223;
public static final int PPC_INS_SRAD = 224;
public static final int PPC_INS_SRADI = 225;
public static final int PPC_INS_SRAW = 226;
public static final int PPC_INS_SRAWI = 227;
public static final int PPC_INS_SRD = 228;
public static final int PPC_INS_SRW = 229;
public static final int PPC_INS_STB = 230;
public static final int PPC_INS_STBU = 231;
public static final int PPC_INS_STBUX = 232;
public static final int PPC_INS_STBX = 233;
public static final int PPC_INS_STD = 234;
public static final int PPC_INS_STDBRX = 235;
public static final int PPC_INS_STDCX = 236;
public static final int PPC_INS_STDU = 237;
public static final int PPC_INS_STDUX = 238;
public static final int PPC_INS_STDX = 239;
public static final int PPC_INS_STFD = 240;
public static final int PPC_INS_STFDU = 241;
public static final int PPC_INS_STFDUX = 242;
public static final int PPC_INS_STFDX = 243;
public static final int PPC_INS_STFIWX = 244;
public static final int PPC_INS_STFS = 245;
public static final int PPC_INS_STFSU = 246;
public static final int PPC_INS_STFSUX = 247;
public static final int PPC_INS_STFSX = 248;
public static final int PPC_INS_STH = 249;
public static final int PPC_INS_STHBRX = 250;
public static final int PPC_INS_STHU = 251;
public static final int PPC_INS_STHUX = 252;
public static final int PPC_INS_STHX = 253;
public static final int PPC_INS_STMW = 254;
public static final int PPC_INS_STVEBX = 255;
public static final int PPC_INS_STVEHX = 256;
public static final int PPC_INS_STVEWX = 257;
public static final int PPC_INS_STVX = 258;
public static final int PPC_INS_STVXL = 259;
public static final int PPC_INS_STW = 260;
public static final int PPC_INS_STWBRX = 261;
public static final int PPC_INS_STWCX = 262;
public static final int PPC_INS_STWU = 263;
public static final int PPC_INS_STWUX = 264;
public static final int PPC_INS_STWX = 265;
public static final int PPC_INS_SUBF = 266;
public static final int PPC_INS_SUBFC = 267;
public static final int PPC_INS_SUBFE = 268;
public static final int PPC_INS_SUBFIC = 269;
public static final int PPC_INS_SUBFME = 270;
public static final int PPC_INS_SUBFZE = 271;
public static final int PPC_INS_SYNC = 272;
public static final int PPC_INS_TD = 273;
public static final int PPC_INS_TDI = 274;
public static final int PPC_INS_TLBIE = 275;
public static final int PPC_INS_TLBIEL = 276;
public static final int PPC_INS_TLBSYNC = 277;
public static final int PPC_INS_TRAP = 278;
public static final int PPC_INS_TW = 279;
public static final int PPC_INS_TWI = 280;
public static final int PPC_INS_VADDCUW = 281;
public static final int PPC_INS_VADDFP = 282;
public static final int PPC_INS_VADDSBS = 283;
public static final int PPC_INS_VADDSHS = 284;
public static final int PPC_INS_VADDSWS = 285;
public static final int PPC_INS_VADDUBM = 286;
public static final int PPC_INS_VADDUBS = 287;
public static final int PPC_INS_VADDUHM = 288;
public static final int PPC_INS_VADDUHS = 289;
public static final int PPC_INS_VADDUWM = 290;
public static final int PPC_INS_VADDUWS = 291;
public static final int PPC_INS_VAND = 292;
public static final int PPC_INS_VANDC = 293;
public static final int PPC_INS_VAVGSB = 294;
public static final int PPC_INS_VAVGSH = 295;
public static final int PPC_INS_VAVGSW = 296;
public static final int PPC_INS_VAVGUB = 297;
public static final int PPC_INS_VAVGUH = 298;
public static final int PPC_INS_VAVGUW = 299;
public static final int PPC_INS_VCFSX = 300;
public static final int PPC_INS_VCFUX = 301;
public static final int PPC_INS_VCMPBFP = 302;
public static final int PPC_INS_VCMPEQFP = 303;
public static final int PPC_INS_VCMPEQUB = 304;
public static final int PPC_INS_VCMPEQUH = 305;
public static final int PPC_INS_VCMPEQUW = 306;
public static final int PPC_INS_VCMPGEFP = 307;
public static final int PPC_INS_VCMPGTFP = 308;
public static final int PPC_INS_VCMPGTSB = 309;
public static final int PPC_INS_VCMPGTSH = 310;
public static final int PPC_INS_VCMPGTSW = 311;
public static final int PPC_INS_VCMPGTUB = 312;
public static final int PPC_INS_VCMPGTUH = 313;
public static final int PPC_INS_VCMPGTUW = 314;
public static final int PPC_INS_VCTSXS = 315;
public static final int PPC_INS_VCTUXS = 316;
public static final int PPC_INS_VEXPTEFP = 317;
public static final int PPC_INS_VLOGEFP = 318;
public static final int PPC_INS_VMADDFP = 319;
public static final int PPC_INS_VMAXFP = 320;
public static final int PPC_INS_VMAXSB = 321;
public static final int PPC_INS_VMAXSH = 322;
public static final int PPC_INS_VMAXSW = 323;
public static final int PPC_INS_VMAXUB = 324;
public static final int PPC_INS_VMAXUH = 325;
public static final int PPC_INS_VMAXUW = 326;
public static final int PPC_INS_VMHADDSHS = 327;
public static final int PPC_INS_VMHRADDSHS = 328;
public static final int PPC_INS_VMINFP = 329;
public static final int PPC_INS_VMINSB = 330;
public static final int PPC_INS_VMINSH = 331;
public static final int PPC_INS_VMINSW = 332;
public static final int PPC_INS_VMINUB = 333;
public static final int PPC_INS_VMINUH = 334;
public static final int PPC_INS_VMINUW = 335;
public static final int PPC_INS_VMLADDUHM = 336;
public static final int PPC_INS_VMRGHB = 337;
public static final int PPC_INS_VMRGHH = 338;
public static final int PPC_INS_VMRGHW = 339;
public static final int PPC_INS_VMRGLB = 340;
public static final int PPC_INS_VMRGLH = 341;
public static final int PPC_INS_VMRGLW = 342;
public static final int PPC_INS_VMSUMMBM = 343;
public static final int PPC_INS_VMSUMSHM = 344;
public static final int PPC_INS_VMSUMSHS = 345;
public static final int PPC_INS_VMSUMUBM = 346;
public static final int PPC_INS_VMSUMUHM = 347;
public static final int PPC_INS_VMSUMUHS = 348;
public static final int PPC_INS_VMULESB = 349;
public static final int PPC_INS_VMULESH = 350;
public static final int PPC_INS_VMULEUB = 351;
public static final int PPC_INS_VMULEUH = 352;
public static final int PPC_INS_VMULOSB = 353;
public static final int PPC_INS_VMULOSH = 354;
public static final int PPC_INS_VMULOUB = 355;
public static final int PPC_INS_VMULOUH = 356;
public static final int PPC_INS_VNMSUBFP = 357;
public static final int PPC_INS_VNOR = 358;
public static final int PPC_INS_VOR = 359;
public static final int PPC_INS_VPERM = 360;
public static final int PPC_INS_VPKPX = 361;
public static final int PPC_INS_VPKSHSS = 362;
public static final int PPC_INS_VPKSHUS = 363;
public static final int PPC_INS_VPKSWSS = 364;
public static final int PPC_INS_VPKSWUS = 365;
public static final int PPC_INS_VPKUHUM = 366;
public static final int PPC_INS_VPKUHUS = 367;
public static final int PPC_INS_VPKUWUM = 368;
public static final int PPC_INS_VPKUWUS = 369;
public static final int PPC_INS_VREFP = 370;
public static final int PPC_INS_VRFIM = 371;
public static final int PPC_INS_VRFIN = 372;
public static final int PPC_INS_VRFIP = 373;
public static final int PPC_INS_VRFIZ = 374;
public static final int PPC_INS_VRLB = 375;
public static final int PPC_INS_VRLH = 376;
public static final int PPC_INS_VRLW = 377;
public static final int PPC_INS_VRSQRTEFP = 378;
public static final int PPC_INS_VSEL = 379;
public static final int PPC_INS_VSL = 380;
public static final int PPC_INS_VSLB = 381;
public static final int PPC_INS_VSLDOI = 382;
public static final int PPC_INS_VSLH = 383;
public static final int PPC_INS_VSLO = 384;
public static final int PPC_INS_VSLW = 385;
public static final int PPC_INS_VSPLTB = 386;
public static final int PPC_INS_VSPLTH = 387;
public static final int PPC_INS_VSPLTISB = 388;
public static final int PPC_INS_VSPLTISH = 389;
public static final int PPC_INS_VSPLTISW = 390;
public static final int PPC_INS_VSPLTW = 391;
public static final int PPC_INS_VSR = 392;
public static final int PPC_INS_VSRAB = 393;
public static final int PPC_INS_VSRAH = 394;
public static final int PPC_INS_VSRAW = 395;
public static final int PPC_INS_VSRB = 396;
public static final int PPC_INS_VSRH = 397;
public static final int PPC_INS_VSRO = 398;
public static final int PPC_INS_VSRW = 399;
public static final int PPC_INS_VSUBCUW = 400;
public static final int PPC_INS_VSUBFP = 401;
public static final int PPC_INS_VSUBSBS = 402;
public static final int PPC_INS_VSUBSHS = 403;
public static final int PPC_INS_VSUBSWS = 404;
public static final int PPC_INS_VSUBUBM = 405;
public static final int PPC_INS_VSUBUBS = 406;
public static final int PPC_INS_VSUBUHM = 407;
public static final int PPC_INS_VSUBUHS = 408;
public static final int PPC_INS_VSUBUWM = 409;
public static final int PPC_INS_VSUBUWS = 410;
public static final int PPC_INS_VSUM2SWS = 411;
public static final int PPC_INS_VSUM4SBS = 412;
public static final int PPC_INS_VSUM4SHS = 413;
public static final int PPC_INS_VSUM4UBS = 414;
public static final int PPC_INS_VSUMSWS = 415;
public static final int PPC_INS_VUPKHPX = 416;
public static final int PPC_INS_VUPKHSB = 417;
public static final int PPC_INS_VUPKHSH = 418;
public static final int PPC_INS_VUPKLPX = 419;
public static final int PPC_INS_VUPKLSB = 420;
public static final int PPC_INS_VUPKLSH = 421;
public static final int PPC_INS_VXOR = 422;
public static final int PPC_INS_WAIT = 423;
public static final int PPC_INS_XOR = 424;
public static final int PPC_INS_XORI = 425;
public static final int PPC_INS_XORIS = 426;
public static final int PPC_INS_BC = 427;
public static final int PPC_INS_BCA = 428;
public static final int PPC_INS_BCCTR = 429;
public static final int PPC_INS_BCCTRL = 430;
public static final int PPC_INS_BCLA = 431;
public static final int PPC_INS_BCLR = 432;
public static final int PPC_INS_BCLRL = 433;
public static final int PPC_INS_MAX = 434;
// Group of PPC instructions
public static final int PPC_GRP_INVALID = 0;
public static final int PPC_GRP_ALTIVEC = 1;
public static final int PPC_GRP_MODE32 = 2;
public static final int PPC_GRP_MODE64 = 3;
public static final int PPC_GRP_JUMP = 4;
public static final int PPC_GRP_MAX = 5;
}

View File

@ -16,5 +16,6 @@ case "$1" in
"arm64") java -classpath ${JNA}:. TestArm64 ;;
"mips") java -classpath ${JNA}:. TestMips ;;
"x86") java -classpath ${JNA}:. TestX86 ;;
* ) echo "Usage: ./run.sh [arm]"; exit 1;;
"ppc") java -classpath ${JNA}:. TestPpc ;;
* ) echo "Usage: ./run.sh [arm|arm64|mips|x86|ppc]"; exit 1;;
esac

View File

@ -0,0 +1,628 @@
# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [ppc_const.py]
# PPC branch codes for some branch instructions
PPC_BC_LT = (0<<5)|12
PPC_BC_LE = (1<<5)|4
PPC_BC_EQ = (2<<5)|12
PPC_BC_GE = (0<<5)|4
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_LT_MINUS = (0<<5)|14
PPC_BC_LE_MINUS = (1<<5)|6
PPC_BC_EQ_MINUS = (2<<5)|14
PPC_BC_GE_MINUS = (0<<5)|6
PPC_BC_GT_MINUS = (1<<5)|14
PPC_BC_NE_MINUS = (2<<5)|6
PPC_BC_UN_MINUS = (3<<5)|14
PPC_BC_NU_MINUS = (3<<5)|6
PPC_BC_LT_PLUS = (0<<5)|15
PPC_BC_LE_PLUS = (1<<5)|7
PPC_BC_EQ_PLUS = (2<<5)|15
PPC_BC_GE_PLUS = (0<<5)|7
PPC_BC_GT_PLUS = (1<<5)|15
PPC_BC_NE_PLUS = (2<<5)|7
PPC_BC_UN_PLUS = (3<<5)|15
PPC_BC_NU_PLUS = (3<<5)|7
# PPC branch hint for some branch instructions
PPC_BH_NO = 0
PPC_BH_PLUS = 1
PPC_BH_MINUS = 2
# Operand type for instruction's operands
PPC_OP_INVALID = 0
PPC_OP_REG = 1
PPC_OP_IMM = 2
PPC_OP_MEM = 3
# PPC registers
PPC_REG_INVALID = 0
PPC_REG_CARRY = 1
PPC_REG_CR0 = 2
PPC_REG_CR1 = 3
PPC_REG_CR2 = 4
PPC_REG_CR3 = 5
PPC_REG_CR4 = 6
PPC_REG_CR5 = 7
PPC_REG_CR6 = 8
PPC_REG_CR7 = 9
PPC_REG_CR8 = 10
PPC_REG_CR9 = 11
PPC_REG_CR10 = 12
PPC_REG_CR11 = 13
PPC_REG_CR12 = 14
PPC_REG_CR13 = 15
PPC_REG_CR14 = 16
PPC_REG_CR15 = 17
PPC_REG_CR16 = 18
PPC_REG_CR17 = 19
PPC_REG_CR18 = 20
PPC_REG_CR19 = 21
PPC_REG_CR20 = 22
PPC_REG_CR21 = 23
PPC_REG_CR22 = 24
PPC_REG_CR23 = 25
PPC_REG_CR24 = 26
PPC_REG_CR25 = 27
PPC_REG_CR26 = 28
PPC_REG_CR27 = 29
PPC_REG_CR28 = 30
PPC_REG_CR29 = 31
PPC_REG_CR30 = 32
PPC_REG_CR31 = 33
PPC_REG_CTR = 34
PPC_REG_F0 = 35
PPC_REG_F1 = 36
PPC_REG_F2 = 37
PPC_REG_F3 = 38
PPC_REG_F4 = 39
PPC_REG_F5 = 40
PPC_REG_F6 = 41
PPC_REG_F7 = 42
PPC_REG_F8 = 43
PPC_REG_F9 = 44
PPC_REG_F10 = 45
PPC_REG_F11 = 46
PPC_REG_F12 = 47
PPC_REG_F13 = 48
PPC_REG_F14 = 49
PPC_REG_F15 = 50
PPC_REG_F16 = 51
PPC_REG_F17 = 52
PPC_REG_F18 = 53
PPC_REG_F19 = 54
PPC_REG_F20 = 55
PPC_REG_F21 = 56
PPC_REG_F22 = 57
PPC_REG_F23 = 58
PPC_REG_F24 = 59
PPC_REG_F25 = 60
PPC_REG_F26 = 61
PPC_REG_F27 = 62
PPC_REG_F28 = 63
PPC_REG_F29 = 64
PPC_REG_F30 = 65
PPC_REG_F31 = 66
PPC_REG_LR = 67
PPC_REG_R0 = 68
PPC_REG_R1 = 69
PPC_REG_R2 = 70
PPC_REG_R3 = 71
PPC_REG_R4 = 72
PPC_REG_R5 = 73
PPC_REG_R6 = 74
PPC_REG_R7 = 75
PPC_REG_R8 = 76
PPC_REG_R9 = 77
PPC_REG_R10 = 78
PPC_REG_R11 = 79
PPC_REG_R12 = 80
PPC_REG_R13 = 81
PPC_REG_R14 = 82
PPC_REG_R15 = 83
PPC_REG_R16 = 84
PPC_REG_R17 = 85
PPC_REG_R18 = 86
PPC_REG_R19 = 87
PPC_REG_R20 = 88
PPC_REG_R21 = 89
PPC_REG_R22 = 90
PPC_REG_R23 = 91
PPC_REG_R24 = 92
PPC_REG_R25 = 93
PPC_REG_R26 = 94
PPC_REG_R27 = 95
PPC_REG_R28 = 96
PPC_REG_R29 = 97
PPC_REG_R30 = 98
PPC_REG_R31 = 99
PPC_REG_V0 = 100
PPC_REG_V1 = 101
PPC_REG_V2 = 102
PPC_REG_V3 = 103
PPC_REG_V4 = 104
PPC_REG_V5 = 105
PPC_REG_V6 = 106
PPC_REG_V7 = 107
PPC_REG_V8 = 108
PPC_REG_V9 = 109
PPC_REG_V10 = 110
PPC_REG_V11 = 111
PPC_REG_V12 = 112
PPC_REG_V13 = 113
PPC_REG_V14 = 114
PPC_REG_V15 = 115
PPC_REG_V16 = 116
PPC_REG_V17 = 117
PPC_REG_V18 = 118
PPC_REG_V19 = 119
PPC_REG_V20 = 120
PPC_REG_V21 = 121
PPC_REG_V22 = 122
PPC_REG_V23 = 123
PPC_REG_V24 = 124
PPC_REG_V25 = 125
PPC_REG_V26 = 126
PPC_REG_V27 = 127
PPC_REG_V28 = 128
PPC_REG_V29 = 129
PPC_REG_V30 = 130
PPC_REG_V31 = 131
PPC_REG_VRSAVE = 132
PPC_REG_RM = 133
PPC_REG_CTR8 = 134
PPC_REG_LR8 = 135
PPC_REG_CR1EQ = 136
PPC_REG_MAX = 137
# PPC instruction
PPC_INS_INVALID = 0
PPC_INS_ADD = 1
PPC_INS_ADDC = 2
PPC_INS_ADDE = 3
PPC_INS_ADDI = 4
PPC_INS_ADDIC = 5
PPC_INS_ADDIS = 6
PPC_INS_ADDME = 7
PPC_INS_ADDZE = 8
PPC_INS_AND = 9
PPC_INS_ANDC = 10
PPC_INS_ANDIS = 11
PPC_INS_ANDI = 12
PPC_INS_B = 13
PPC_INS_BA = 14
PPC_INS_BCL = 15
PPC_INS_BCTR = 16
PPC_INS_BCTRL = 17
PPC_INS_BDNZ = 18
PPC_INS_BDNZA = 19
PPC_INS_BDNZL = 20
PPC_INS_BDNZLA = 21
PPC_INS_BDNZLR = 22
PPC_INS_BDNZLRL = 23
PPC_INS_BDZ = 24
PPC_INS_BDZA = 25
PPC_INS_BDZL = 26
PPC_INS_BDZLA = 27
PPC_INS_BDZLR = 28
PPC_INS_BDZLRL = 29
PPC_INS_BL = 30
PPC_INS_BLA = 31
PPC_INS_BLR = 32
PPC_INS_BLRL = 33
PPC_INS_CMPD = 34
PPC_INS_CMPDI = 35
PPC_INS_CMPLD = 36
PPC_INS_CMPLDI = 37
PPC_INS_CMPLW = 38
PPC_INS_CMPLWI = 39
PPC_INS_CMPW = 40
PPC_INS_CMPWI = 41
PPC_INS_CNTLZD = 42
PPC_INS_CNTLZW = 43
PPC_INS_CREQV = 44
PPC_INS_CRXOR = 45
PPC_INS_CRAND = 46
PPC_INS_CRANDC = 47
PPC_INS_CRNAND = 48
PPC_INS_CRNOR = 49
PPC_INS_CROR = 50
PPC_INS_CRORC = 51
PPC_INS_DCBA = 52
PPC_INS_DCBF = 53
PPC_INS_DCBI = 54
PPC_INS_DCBST = 55
PPC_INS_DCBT = 56
PPC_INS_DCBTST = 57
PPC_INS_DCBZ = 58
PPC_INS_DCBZL = 59
PPC_INS_DIVD = 60
PPC_INS_DIVDU = 61
PPC_INS_DIVW = 62
PPC_INS_DIVWU = 63
PPC_INS_DSS = 64
PPC_INS_DSSALL = 65
PPC_INS_DST = 66
PPC_INS_DSTST = 67
PPC_INS_DSTSTT = 68
PPC_INS_DSTT = 69
PPC_INS_EIEIO = 70
PPC_INS_EQV = 71
PPC_INS_EXTSB = 72
PPC_INS_EXTSH = 73
PPC_INS_EXTSW = 74
PPC_INS_FABS = 75
PPC_INS_FADD = 76
PPC_INS_FADDS = 77
PPC_INS_FCFID = 78
PPC_INS_FCFIDS = 79
PPC_INS_FCFIDU = 80
PPC_INS_FCFIDUS = 81
PPC_INS_FCMPU = 82
PPC_INS_FCPSGN = 83
PPC_INS_FCTID = 84
PPC_INS_FCTIDUZ = 85
PPC_INS_FCTIDZ = 86
PPC_INS_FCTIW = 87
PPC_INS_FCTIWUZ = 88
PPC_INS_FCTIWZ = 89
PPC_INS_FDIV = 90
PPC_INS_FDIVS = 91
PPC_INS_FMADD = 92
PPC_INS_FMADDS = 93
PPC_INS_FMSUB = 94
PPC_INS_FMSUBS = 95
PPC_INS_FMUL = 96
PPC_INS_FMULS = 97
PPC_INS_FNABS = 98
PPC_INS_FNEG = 99
PPC_INS_FNMADD = 100
PPC_INS_FNMADDS = 101
PPC_INS_FNMSUB = 102
PPC_INS_FNMSUBS = 103
PPC_INS_FRE = 104
PPC_INS_FRES = 105
PPC_INS_FRIM = 106
PPC_INS_FRIN = 107
PPC_INS_FRIP = 108
PPC_INS_FRIZ = 109
PPC_INS_FRSP = 110
PPC_INS_FRSQRTE = 111
PPC_INS_FRSQRTES = 112
PPC_INS_FSEL = 113
PPC_INS_FSQRT = 114
PPC_INS_FSQRTS = 115
PPC_INS_FSUB = 116
PPC_INS_FSUBS = 117
PPC_INS_ICBI = 118
PPC_INS_ISEL = 119
PPC_INS_ISYNC = 120
PPC_INS_LA = 121
PPC_INS_LBZ = 122
PPC_INS_LBZU = 123
PPC_INS_LBZUX = 124
PPC_INS_LBZX = 125
PPC_INS_LD = 126
PPC_INS_LDARX = 127
PPC_INS_LDBRX = 128
PPC_INS_LDU = 129
PPC_INS_LDUX = 130
PPC_INS_LDX = 131
PPC_INS_LFD = 132
PPC_INS_LFDU = 133
PPC_INS_LFDUX = 134
PPC_INS_LFDX = 135
PPC_INS_LFIWAX = 136
PPC_INS_LFIWZX = 137
PPC_INS_LFS = 138
PPC_INS_LFSU = 139
PPC_INS_LFSUX = 140
PPC_INS_LFSX = 141
PPC_INS_LHA = 142
PPC_INS_LHAU = 143
PPC_INS_LHAUX = 144
PPC_INS_LHAX = 145
PPC_INS_LHBRX = 146
PPC_INS_LHZ = 147
PPC_INS_LHZU = 148
PPC_INS_LHZUX = 149
PPC_INS_LHZX = 150
PPC_INS_LI = 151
PPC_INS_LIS = 152
PPC_INS_LMW = 153
PPC_INS_LVEBX = 154
PPC_INS_LVEHX = 155
PPC_INS_LVEWX = 156
PPC_INS_LVSL = 157
PPC_INS_LVSR = 158
PPC_INS_LVX = 159
PPC_INS_LVXL = 160
PPC_INS_LWA = 161
PPC_INS_LWARX = 162
PPC_INS_LWAUX = 163
PPC_INS_LWAX = 164
PPC_INS_LWBRX = 165
PPC_INS_LWZ = 166
PPC_INS_LWZU = 167
PPC_INS_LWZUX = 168
PPC_INS_LWZX = 169
PPC_INS_MCRF = 170
PPC_INS_MFCR = 171
PPC_INS_MFCTR = 172
PPC_INS_MFFS = 173
PPC_INS_MFLR = 174
PPC_INS_MFMSR = 175
PPC_INS_MFOCRF = 176
PPC_INS_MFSPR = 177
PPC_INS_MFTB = 178
PPC_INS_MFVSCR = 179
PPC_INS_MTCRF = 180
PPC_INS_MTCTR = 181
PPC_INS_MTFSB0 = 182
PPC_INS_MTFSB1 = 183
PPC_INS_MTFSF = 184
PPC_INS_MTLR = 185
PPC_INS_MTMSR = 186
PPC_INS_MTMSRD = 187
PPC_INS_MTOCRF = 188
PPC_INS_MTSPR = 189
PPC_INS_MTVSCR = 190
PPC_INS_MULHD = 191
PPC_INS_MULHDU = 192
PPC_INS_MULHW = 193
PPC_INS_MULHWU = 194
PPC_INS_MULLD = 195
PPC_INS_MULLI = 196
PPC_INS_MULLW = 197
PPC_INS_NAND = 198
PPC_INS_NEG = 199
PPC_INS_NOP = 200
PPC_INS_ORI = 201
PPC_INS_NOR = 202
PPC_INS_OR = 203
PPC_INS_ORC = 204
PPC_INS_ORIS = 205
PPC_INS_POPCNTD = 206
PPC_INS_POPCNTW = 207
PPC_INS_RLDCL = 208
PPC_INS_RLDCR = 209
PPC_INS_RLDIC = 210
PPC_INS_RLDICL = 211
PPC_INS_RLDICR = 212
PPC_INS_RLDIMI = 213
PPC_INS_RLWIMI = 214
PPC_INS_RLWINM = 215
PPC_INS_RLWNM = 216
PPC_INS_SC = 217
PPC_INS_SLBIA = 218
PPC_INS_SLBIE = 219
PPC_INS_SLBMFEE = 220
PPC_INS_SLBMTE = 221
PPC_INS_SLD = 222
PPC_INS_SLW = 223
PPC_INS_SRAD = 224
PPC_INS_SRADI = 225
PPC_INS_SRAW = 226
PPC_INS_SRAWI = 227
PPC_INS_SRD = 228
PPC_INS_SRW = 229
PPC_INS_STB = 230
PPC_INS_STBU = 231
PPC_INS_STBUX = 232
PPC_INS_STBX = 233
PPC_INS_STD = 234
PPC_INS_STDBRX = 235
PPC_INS_STDCX = 236
PPC_INS_STDU = 237
PPC_INS_STDUX = 238
PPC_INS_STDX = 239
PPC_INS_STFD = 240
PPC_INS_STFDU = 241
PPC_INS_STFDUX = 242
PPC_INS_STFDX = 243
PPC_INS_STFIWX = 244
PPC_INS_STFS = 245
PPC_INS_STFSU = 246
PPC_INS_STFSUX = 247
PPC_INS_STFSX = 248
PPC_INS_STH = 249
PPC_INS_STHBRX = 250
PPC_INS_STHU = 251
PPC_INS_STHUX = 252
PPC_INS_STHX = 253
PPC_INS_STMW = 254
PPC_INS_STVEBX = 255
PPC_INS_STVEHX = 256
PPC_INS_STVEWX = 257
PPC_INS_STVX = 258
PPC_INS_STVXL = 259
PPC_INS_STW = 260
PPC_INS_STWBRX = 261
PPC_INS_STWCX = 262
PPC_INS_STWU = 263
PPC_INS_STWUX = 264
PPC_INS_STWX = 265
PPC_INS_SUBF = 266
PPC_INS_SUBFC = 267
PPC_INS_SUBFE = 268
PPC_INS_SUBFIC = 269
PPC_INS_SUBFME = 270
PPC_INS_SUBFZE = 271
PPC_INS_SYNC = 272
PPC_INS_TD = 273
PPC_INS_TDI = 274
PPC_INS_TLBIE = 275
PPC_INS_TLBIEL = 276
PPC_INS_TLBSYNC = 277
PPC_INS_TRAP = 278
PPC_INS_TW = 279
PPC_INS_TWI = 280
PPC_INS_VADDCUW = 281
PPC_INS_VADDFP = 282
PPC_INS_VADDSBS = 283
PPC_INS_VADDSHS = 284
PPC_INS_VADDSWS = 285
PPC_INS_VADDUBM = 286
PPC_INS_VADDUBS = 287
PPC_INS_VADDUHM = 288
PPC_INS_VADDUHS = 289
PPC_INS_VADDUWM = 290
PPC_INS_VADDUWS = 291
PPC_INS_VAND = 292
PPC_INS_VANDC = 293
PPC_INS_VAVGSB = 294
PPC_INS_VAVGSH = 295
PPC_INS_VAVGSW = 296
PPC_INS_VAVGUB = 297
PPC_INS_VAVGUH = 298
PPC_INS_VAVGUW = 299
PPC_INS_VCFSX = 300
PPC_INS_VCFUX = 301
PPC_INS_VCMPBFP = 302
PPC_INS_VCMPEQFP = 303
PPC_INS_VCMPEQUB = 304
PPC_INS_VCMPEQUH = 305
PPC_INS_VCMPEQUW = 306
PPC_INS_VCMPGEFP = 307
PPC_INS_VCMPGTFP = 308
PPC_INS_VCMPGTSB = 309
PPC_INS_VCMPGTSH = 310
PPC_INS_VCMPGTSW = 311
PPC_INS_VCMPGTUB = 312
PPC_INS_VCMPGTUH = 313
PPC_INS_VCMPGTUW = 314
PPC_INS_VCTSXS = 315
PPC_INS_VCTUXS = 316
PPC_INS_VEXPTEFP = 317
PPC_INS_VLOGEFP = 318
PPC_INS_VMADDFP = 319
PPC_INS_VMAXFP = 320
PPC_INS_VMAXSB = 321
PPC_INS_VMAXSH = 322
PPC_INS_VMAXSW = 323
PPC_INS_VMAXUB = 324
PPC_INS_VMAXUH = 325
PPC_INS_VMAXUW = 326
PPC_INS_VMHADDSHS = 327
PPC_INS_VMHRADDSHS = 328
PPC_INS_VMINFP = 329
PPC_INS_VMINSB = 330
PPC_INS_VMINSH = 331
PPC_INS_VMINSW = 332
PPC_INS_VMINUB = 333
PPC_INS_VMINUH = 334
PPC_INS_VMINUW = 335
PPC_INS_VMLADDUHM = 336
PPC_INS_VMRGHB = 337
PPC_INS_VMRGHH = 338
PPC_INS_VMRGHW = 339
PPC_INS_VMRGLB = 340
PPC_INS_VMRGLH = 341
PPC_INS_VMRGLW = 342
PPC_INS_VMSUMMBM = 343
PPC_INS_VMSUMSHM = 344
PPC_INS_VMSUMSHS = 345
PPC_INS_VMSUMUBM = 346
PPC_INS_VMSUMUHM = 347
PPC_INS_VMSUMUHS = 348
PPC_INS_VMULESB = 349
PPC_INS_VMULESH = 350
PPC_INS_VMULEUB = 351
PPC_INS_VMULEUH = 352
PPC_INS_VMULOSB = 353
PPC_INS_VMULOSH = 354
PPC_INS_VMULOUB = 355
PPC_INS_VMULOUH = 356
PPC_INS_VNMSUBFP = 357
PPC_INS_VNOR = 358
PPC_INS_VOR = 359
PPC_INS_VPERM = 360
PPC_INS_VPKPX = 361
PPC_INS_VPKSHSS = 362
PPC_INS_VPKSHUS = 363
PPC_INS_VPKSWSS = 364
PPC_INS_VPKSWUS = 365
PPC_INS_VPKUHUM = 366
PPC_INS_VPKUHUS = 367
PPC_INS_VPKUWUM = 368
PPC_INS_VPKUWUS = 369
PPC_INS_VREFP = 370
PPC_INS_VRFIM = 371
PPC_INS_VRFIN = 372
PPC_INS_VRFIP = 373
PPC_INS_VRFIZ = 374
PPC_INS_VRLB = 375
PPC_INS_VRLH = 376
PPC_INS_VRLW = 377
PPC_INS_VRSQRTEFP = 378
PPC_INS_VSEL = 379
PPC_INS_VSL = 380
PPC_INS_VSLB = 381
PPC_INS_VSLDOI = 382
PPC_INS_VSLH = 383
PPC_INS_VSLO = 384
PPC_INS_VSLW = 385
PPC_INS_VSPLTB = 386
PPC_INS_VSPLTH = 387
PPC_INS_VSPLTISB = 388
PPC_INS_VSPLTISH = 389
PPC_INS_VSPLTISW = 390
PPC_INS_VSPLTW = 391
PPC_INS_VSR = 392
PPC_INS_VSRAB = 393
PPC_INS_VSRAH = 394
PPC_INS_VSRAW = 395
PPC_INS_VSRB = 396
PPC_INS_VSRH = 397
PPC_INS_VSRO = 398
PPC_INS_VSRW = 399
PPC_INS_VSUBCUW = 400
PPC_INS_VSUBFP = 401
PPC_INS_VSUBSBS = 402
PPC_INS_VSUBSHS = 403
PPC_INS_VSUBSWS = 404
PPC_INS_VSUBUBM = 405
PPC_INS_VSUBUBS = 406
PPC_INS_VSUBUHM = 407
PPC_INS_VSUBUHS = 408
PPC_INS_VSUBUWM = 409
PPC_INS_VSUBUWS = 410
PPC_INS_VSUM2SWS = 411
PPC_INS_VSUM4SBS = 412
PPC_INS_VSUM4SHS = 413
PPC_INS_VSUM4UBS = 414
PPC_INS_VSUMSWS = 415
PPC_INS_VUPKHPX = 416
PPC_INS_VUPKHSB = 417
PPC_INS_VUPKHSH = 418
PPC_INS_VUPKLPX = 419
PPC_INS_VUPKLSB = 420
PPC_INS_VUPKLSH = 421
PPC_INS_VXOR = 422
PPC_INS_WAIT = 423
PPC_INS_XOR = 424
PPC_INS_XORI = 425
PPC_INS_XORIS = 426
PPC_INS_BC = 427
PPC_INS_BCA = 428
PPC_INS_BCCTR = 429
PPC_INS_BCCTRL = 430
PPC_INS_BCLA = 431
PPC_INS_BCLR = 432
PPC_INS_BCLRL = 433
PPC_INS_MAX = 434
# Group of PPC instructions
PPC_GRP_INVALID = 0
PPC_GRP_ALTIVEC = 1
PPC_GRP_MODE32 = 2
PPC_GRP_MODE64 = 3
PPC_GRP_JUMP = 4
PPC_GRP_MAX = 5