Merge branch 'next' into opsize

This commit is contained in:
Nguyen Anh Quynh 2014-07-07 11:59:36 +08:00
commit faf368b656
18 changed files with 2812 additions and 1789 deletions

View File

@ -39,6 +39,9 @@ ifeq ($(CAPSTONE_USE_SYS_DYN_MEM),yes)
CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
endif
CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
PREFIX ?= /usr
DESTDIR ?=
ifndef BUILDDIR

View File

@ -21,3 +21,7 @@ More bindings created & maintained by the community are available as followings.
- NodeJS binding (by Jason Oster).
https://github.com/parasyte/node-capstone
- C++ binding (by Peter Hlavaty)
https://github.com/zer0mem/cccapstone

View File

@ -4,13 +4,14 @@
LIB = capstone
FLAGS = '-Wall -Wextra -Wwrite-strings'
all: arm.cmxa arm64.cmxa mips.cmxa x86.cmxa capstone.cmxa test.cmx test_detail.cmx test_x86.cmx test_arm.cmx test_arm64.cmx test_mips.cmx ocaml.o
all: arm.cmxa arm64.cmxa mips.cmxa ppc.cmxa x86.cmxa capstone.cmxa test.cmx test_detail.cmx test_x86.cmx test_arm.cmx test_arm64.cmx test_mips.cmx test_ppc.cmx ocaml.o
ocamlopt -o test -ccopt $(FLAGS) ocaml.o capstone.cmx test.cmx -cclib -l$(LIB)
ocamlopt -o test_detail -ccopt $(FLAGS) capstone.cmx ocaml.o test_detail.cmx -cclib -l$(LIB)
ocamlopt -o test_x86 -ccopt $(FLAGS) capstone.cmx ocaml.o x86.cmx test_x86.cmx -cclib -l$(LIB)
ocamlopt -o test_arm -ccopt $(FLAGS) capstone.cmx ocaml.o arm.cmx test_arm.cmx -cclib -l$(LIB)
ocamlopt -o test_arm64 -ccopt $(FLAGS) capstone.cmx ocaml.o arm64.cmx test_arm64.cmx -cclib -l$(LIB)
ocamlopt -o test_mips -ccopt $(FLAGS) capstone.cmx ocaml.o mips.cmx test_mips.cmx -cclib -l$(LIB)
ocamlopt -o test_ppc -ccopt $(FLAGS) capstone.cmx ocaml.o ppc.cmx test_ppc.cmx -cclib -l$(LIB)
test.cmx: test.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
@ -30,6 +31,9 @@ test_arm64.cmx: test_arm64.ml
test_mips.cmx: test_mips.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
test_ppc.cmx: test_ppc.ml
ocamlopt -ccopt $(FLAGS) -c $< -cclib -l$(LIB)
ocaml.o: ocaml.c
ocamlc -ccopt $(FLAGS) -c $<
@ -93,6 +97,18 @@ mips.cmx: mips.ml mips.cmi
mips.cmxa: mips.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
ppc.mli: ppc.ml
ocamlc -ccopt $(FLAGS) -i $< > $@
ppc.cmi: ppc.mli
ocamlc -ccopt $(FLAGS) -c $<
ppc.cmx: ppc.ml ppc.cmi
ocamlopt -ccopt $(FLAGS) -c $<
ppc.cmxa: ppc.cmx
ocamlopt -ccopt $(FLAGS) -a -o $@ $<
clean:
rm -f *.[oa] *.so *.cm[ixoa] *.cmxa *.mli test test_detail test_x86 test_arm test_arm64 test_mips

View File

@ -71,6 +71,15 @@ type cs_arm = {
operands: arm_op array;
}
(* Operand type for instruction's operands *)
let _ARM_OP_INVALID = 0;;
let _ARM_OP_REG = 1;;
let _ARM_OP_CIMM = 2;;
let _ARM_OP_PIMM = 3;;
let _ARM_OP_IMM = 4;;
let _ARM_OP_FP = 5;;
let _ARM_OP_MEM = 6;;
(* ARM registers *)
let _ARM_REG_INVALID = 0;;
let _ARM_REG_APSR = 1;;
@ -121,77 +130,88 @@ let _ARM_REG_D31 = 45;;
let _ARM_REG_FPINST2 = 46;;
let _ARM_REG_MVFR0 = 47;;
let _ARM_REG_MVFR1 = 48;;
let _ARM_REG_Q0 = 49;;
let _ARM_REG_Q1 = 50;;
let _ARM_REG_Q2 = 51;;
let _ARM_REG_Q3 = 52;;
let _ARM_REG_Q4 = 53;;
let _ARM_REG_Q5 = 54;;
let _ARM_REG_Q6 = 55;;
let _ARM_REG_Q7 = 56;;
let _ARM_REG_Q8 = 57;;
let _ARM_REG_Q9 = 58;;
let _ARM_REG_Q10 = 59;;
let _ARM_REG_Q11 = 60;;
let _ARM_REG_Q12 = 61;;
let _ARM_REG_Q13 = 62;;
let _ARM_REG_Q14 = 63;;
let _ARM_REG_Q15 = 64;;
let _ARM_REG_R0 = 65;;
let _ARM_REG_R1 = 66;;
let _ARM_REG_R2 = 67;;
let _ARM_REG_R3 = 68;;
let _ARM_REG_R4 = 69;;
let _ARM_REG_R5 = 70;;
let _ARM_REG_R6 = 71;;
let _ARM_REG_R7 = 72;;
let _ARM_REG_R8 = 73;;
let _ARM_REG_R9 = 74;;
let _ARM_REG_R10 = 75;;
let _ARM_REG_R11 = 76;;
let _ARM_REG_R12 = 77;;
let _ARM_REG_S0 = 78;;
let _ARM_REG_S1 = 79;;
let _ARM_REG_S2 = 80;;
let _ARM_REG_S3 = 81;;
let _ARM_REG_S4 = 82;;
let _ARM_REG_S5 = 83;;
let _ARM_REG_S6 = 84;;
let _ARM_REG_S7 = 85;;
let _ARM_REG_S8 = 86;;
let _ARM_REG_S9 = 87;;
let _ARM_REG_S10 = 88;;
let _ARM_REG_S11 = 89;;
let _ARM_REG_S12 = 90;;
let _ARM_REG_S13 = 91;;
let _ARM_REG_S14 = 92;;
let _ARM_REG_S15 = 93;;
let _ARM_REG_S16 = 94;;
let _ARM_REG_S17 = 95;;
let _ARM_REG_S18 = 96;;
let _ARM_REG_S19 = 97;;
let _ARM_REG_S20 = 98;;
let _ARM_REG_S21 = 99;;
let _ARM_REG_S22 = 100;;
let _ARM_REG_S23 = 101;;
let _ARM_REG_S24 = 102;;
let _ARM_REG_S25 = 103;;
let _ARM_REG_S26 = 104;;
let _ARM_REG_S27 = 105;;
let _ARM_REG_S28 = 106;;
let _ARM_REG_S29 = 107;;
let _ARM_REG_S30 = 108;;
let _ARM_REG_S31 = 109;;
let _ARM_REG_MVFR2 = 49;;
let _ARM_REG_Q0 = 50;;
let _ARM_REG_Q1 = 51;;
let _ARM_REG_Q2 = 52;;
let _ARM_REG_Q3 = 53;;
let _ARM_REG_Q4 = 54;;
let _ARM_REG_Q5 = 55;;
let _ARM_REG_Q6 = 56;;
let _ARM_REG_Q7 = 57;;
let _ARM_REG_Q8 = 58;;
let _ARM_REG_Q9 = 59;;
let _ARM_REG_Q10 = 60;;
let _ARM_REG_Q11 = 61;;
let _ARM_REG_Q12 = 62;;
let _ARM_REG_Q13 = 63;;
let _ARM_REG_Q14 = 64;;
let _ARM_REG_Q15 = 65;;
let _ARM_REG_R0 = 66;;
let _ARM_REG_R1 = 67;;
let _ARM_REG_R2 = 68;;
let _ARM_REG_R3 = 69;;
let _ARM_REG_R4 = 70;;
let _ARM_REG_R5 = 71;;
let _ARM_REG_R6 = 72;;
let _ARM_REG_R7 = 73;;
let _ARM_REG_R8 = 74;;
let _ARM_REG_R9 = 75;;
let _ARM_REG_R10 = 76;;
let _ARM_REG_R11 = 77;;
let _ARM_REG_R12 = 78;;
let _ARM_REG_S0 = 79;;
let _ARM_REG_S1 = 80;;
let _ARM_REG_S2 = 81;;
let _ARM_REG_S3 = 82;;
let _ARM_REG_S4 = 83;;
let _ARM_REG_S5 = 84;;
let _ARM_REG_S6 = 85;;
let _ARM_REG_S7 = 86;;
let _ARM_REG_S8 = 87;;
let _ARM_REG_S9 = 88;;
let _ARM_REG_S10 = 89;;
let _ARM_REG_S11 = 90;;
let _ARM_REG_S12 = 91;;
let _ARM_REG_S13 = 92;;
let _ARM_REG_S14 = 93;;
let _ARM_REG_S15 = 94;;
let _ARM_REG_S16 = 95;;
let _ARM_REG_S17 = 96;;
let _ARM_REG_S18 = 97;;
let _ARM_REG_S19 = 98;;
let _ARM_REG_S20 = 99;;
let _ARM_REG_S21 = 100;;
let _ARM_REG_S22 = 101;;
let _ARM_REG_S23 = 102;;
let _ARM_REG_S24 = 103;;
let _ARM_REG_S25 = 104;;
let _ARM_REG_S26 = 105;;
let _ARM_REG_S27 = 106;;
let _ARM_REG_S28 = 107;;
let _ARM_REG_S29 = 108;;
let _ARM_REG_S30 = 109;;
let _ARM_REG_S31 = 110;;
let _ARM_REG_MAX = 111;;
(* alias registers *)
let _ARM_REG_R13 = _ARM_REG_SP;;
let _ARM_REG_R14 = _ARM_REG_LR;;
let _ARM_REG_R15 = _ARM_REG_PC;;
let _ARM_REG_SB = _ARM_REG_R9;;
let _ARM_REG_SL = _ARM_REG_R10;;
let _ARM_REG_FP = _ARM_REG_R11;;
let _ARM_REG_IP = _ARM_REG_R12;;
(* ARM instructions *)
let _ARM_INS_INVALID = 0;;
let _ARM_INS_ADC = 1;;
let _ARM_INS_ADD = 2;;
let _ARM_INS_ADR = 3;;
let _ARM_INS_AESD_8 = 4;;
let _ARM_INS_AESE_8 = 5;;
let _ARM_INS_AESIMC_8 = 6;;
let _ARM_INS_AESMC_8 = 7;;
let _ARM_INS_AESD = 4;;
let _ARM_INS_AESE = 5;;
let _ARM_INS_AESIMC = 6;;
let _ARM_INS_AESMC = 7;;
let _ARM_INS_AND = 8;;
let _ARM_INS_BFC = 9;;
let _ARM_INS_BFI = 10;;
@ -309,16 +329,16 @@ let _ARM_INS_SBFX = 121;;
let _ARM_INS_SDIV = 122;;
let _ARM_INS_SEL = 123;;
let _ARM_INS_SETEND = 124;;
let _ARM_INS_SHA1C_32 = 125;;
let _ARM_INS_SHA1H_32 = 126;;
let _ARM_INS_SHA1M_32 = 127;;
let _ARM_INS_SHA1P_32 = 128;;
let _ARM_INS_SHA1SU0_32 = 129;;
let _ARM_INS_SHA1SU1_32 = 130;;
let _ARM_INS_SHA256H_32 = 131;;
let _ARM_INS_SHA256H2_32 = 132;;
let _ARM_INS_SHA256SU0_32 = 133;;
let _ARM_INS_SHA256SU1_32 = 134;;
let _ARM_INS_SHA1C = 125;;
let _ARM_INS_SHA1H = 126;;
let _ARM_INS_SHA1M = 127;;
let _ARM_INS_SHA1P = 128;;
let _ARM_INS_SHA1SU0 = 129;;
let _ARM_INS_SHA1SU1 = 130;;
let _ARM_INS_SHA256H = 131;;
let _ARM_INS_SHA256H2 = 132;;
let _ARM_INS_SHA256SU0 = 133;;
let _ARM_INS_SHA256SU1 = 134;;
let _ARM_INS_SHADD16 = 135;;
let _ARM_INS_SHADD8 = 136;;
let _ARM_INS_SHASX = 137;;
@ -469,175 +489,148 @@ let _ARM_INS_VCLZ = 281;;
let _ARM_INS_VCMP = 282;;
let _ARM_INS_VCMPE = 283;;
let _ARM_INS_VCNT = 284;;
let _ARM_INS_VCVTA_S32_F32 = 285;;
let _ARM_INS_VCVTA_U32_F32 = 286;;
let _ARM_INS_VCVTA_S32_F64 = 287;;
let _ARM_INS_VCVTA_U32_F64 = 288;;
let _ARM_INS_VCVTB = 289;;
let _ARM_INS_VCVT = 290;;
let _ARM_INS_VCVTM_S32_F32 = 291;;
let _ARM_INS_VCVTM_U32_F32 = 292;;
let _ARM_INS_VCVTM_S32_F64 = 293;;
let _ARM_INS_VCVTM_U32_F64 = 294;;
let _ARM_INS_VCVTN_S32_F32 = 295;;
let _ARM_INS_VCVTN_U32_F32 = 296;;
let _ARM_INS_VCVTN_S32_F64 = 297;;
let _ARM_INS_VCVTN_U32_F64 = 298;;
let _ARM_INS_VCVTP_S32_F32 = 299;;
let _ARM_INS_VCVTP_U32_F32 = 300;;
let _ARM_INS_VCVTP_S32_F64 = 301;;
let _ARM_INS_VCVTP_U32_F64 = 302;;
let _ARM_INS_VCVTT = 303;;
let _ARM_INS_VDIV = 304;;
let _ARM_INS_VDUP = 305;;
let _ARM_INS_VEOR = 306;;
let _ARM_INS_VEXT = 307;;
let _ARM_INS_VFMA = 308;;
let _ARM_INS_VFMS = 309;;
let _ARM_INS_VFNMA = 310;;
let _ARM_INS_VFNMS = 311;;
let _ARM_INS_VHADD = 312;;
let _ARM_INS_VHSUB = 313;;
let _ARM_INS_VLD1 = 314;;
let _ARM_INS_VLD2 = 315;;
let _ARM_INS_VLD3 = 316;;
let _ARM_INS_VLD4 = 317;;
let _ARM_INS_VLDMDB = 318;;
let _ARM_INS_VLDMIA = 319;;
let _ARM_INS_VLDR = 320;;
let _ARM_INS_VMAXNM_F64 = 321;;
let _ARM_INS_VMAXNM_F32 = 322;;
let _ARM_INS_VMAX = 323;;
let _ARM_INS_VMINNM_F64 = 324;;
let _ARM_INS_VMINNM_F32 = 325;;
let _ARM_INS_VMIN = 326;;
let _ARM_INS_VMLA = 327;;
let _ARM_INS_VMLAL = 328;;
let _ARM_INS_VMLS = 329;;
let _ARM_INS_VMLSL = 330;;
let _ARM_INS_VMOVL = 331;;
let _ARM_INS_VMOVN = 332;;
let _ARM_INS_VMSR = 333;;
let _ARM_INS_VMUL = 334;;
let _ARM_INS_VMULL_P64 = 335;;
let _ARM_INS_VMULL = 336;;
let _ARM_INS_VMVN = 337;;
let _ARM_INS_VNEG = 338;;
let _ARM_INS_VNMLA = 339;;
let _ARM_INS_VNMLS = 340;;
let _ARM_INS_VNMUL = 341;;
let _ARM_INS_VORN = 342;;
let _ARM_INS_VORR = 343;;
let _ARM_INS_VPADAL = 344;;
let _ARM_INS_VPADDL = 345;;
let _ARM_INS_VPADD = 346;;
let _ARM_INS_VPMAX = 347;;
let _ARM_INS_VPMIN = 348;;
let _ARM_INS_VQABS = 349;;
let _ARM_INS_VQADD = 350;;
let _ARM_INS_VQDMLAL = 351;;
let _ARM_INS_VQDMLSL = 352;;
let _ARM_INS_VQDMULH = 353;;
let _ARM_INS_VQDMULL = 354;;
let _ARM_INS_VQMOVUN = 355;;
let _ARM_INS_VQMOVN = 356;;
let _ARM_INS_VQNEG = 357;;
let _ARM_INS_VQRDMULH = 358;;
let _ARM_INS_VQRSHL = 359;;
let _ARM_INS_VQRSHRN = 360;;
let _ARM_INS_VQRSHRUN = 361;;
let _ARM_INS_VQSHL = 362;;
let _ARM_INS_VQSHLU = 363;;
let _ARM_INS_VQSHRN = 364;;
let _ARM_INS_VQSHRUN = 365;;
let _ARM_INS_VQSUB = 366;;
let _ARM_INS_VRADDHN = 367;;
let _ARM_INS_VRECPE = 368;;
let _ARM_INS_VRECPS = 369;;
let _ARM_INS_VREV16 = 370;;
let _ARM_INS_VREV32 = 371;;
let _ARM_INS_VREV64 = 372;;
let _ARM_INS_VRHADD = 373;;
let _ARM_INS_VRINTA_F64 = 374;;
let _ARM_INS_VRINTA_F32 = 375;;
let _ARM_INS_VRINTM_F64 = 376;;
let _ARM_INS_VRINTM_F32 = 377;;
let _ARM_INS_VRINTN_F64 = 378;;
let _ARM_INS_VRINTN_F32 = 379;;
let _ARM_INS_VRINTP_F64 = 380;;
let _ARM_INS_VRINTP_F32 = 381;;
let _ARM_INS_VRINTR = 382;;
let _ARM_INS_VRINTX = 383;;
let _ARM_INS_VRINTX_F32 = 384;;
let _ARM_INS_VRINTZ = 385;;
let _ARM_INS_VRINTZ_F32 = 386;;
let _ARM_INS_VRSHL = 387;;
let _ARM_INS_VRSHRN = 388;;
let _ARM_INS_VRSHR = 389;;
let _ARM_INS_VRSQRTE = 390;;
let _ARM_INS_VRSQRTS = 391;;
let _ARM_INS_VRSRA = 392;;
let _ARM_INS_VRSUBHN = 393;;
let _ARM_INS_VSELEQ_F64 = 394;;
let _ARM_INS_VSELEQ_F32 = 395;;
let _ARM_INS_VSELGE_F64 = 396;;
let _ARM_INS_VSELGE_F32 = 397;;
let _ARM_INS_VSELGT_F64 = 398;;
let _ARM_INS_VSELGT_F32 = 399;;
let _ARM_INS_VSELVS_F64 = 400;;
let _ARM_INS_VSELVS_F32 = 401;;
let _ARM_INS_VSHLL = 402;;
let _ARM_INS_VSHL = 403;;
let _ARM_INS_VSHRN = 404;;
let _ARM_INS_VSHR = 405;;
let _ARM_INS_VSLI = 406;;
let _ARM_INS_VSQRT = 407;;
let _ARM_INS_VSRA = 408;;
let _ARM_INS_VSRI = 409;;
let _ARM_INS_VST1 = 410;;
let _ARM_INS_VST2 = 411;;
let _ARM_INS_VST3 = 412;;
let _ARM_INS_VST4 = 413;;
let _ARM_INS_VSTMDB = 414;;
let _ARM_INS_VSTMIA = 415;;
let _ARM_INS_VSTR = 416;;
let _ARM_INS_VSUB = 417;;
let _ARM_INS_VSUBHN = 418;;
let _ARM_INS_VSUBL = 419;;
let _ARM_INS_VSUBW = 420;;
let _ARM_INS_VSWP = 421;;
let _ARM_INS_VTBL = 422;;
let _ARM_INS_VTBX = 423;;
let _ARM_INS_VCVTR = 424;;
let _ARM_INS_VTRN = 425;;
let _ARM_INS_VTST = 426;;
let _ARM_INS_VUZP = 427;;
let _ARM_INS_VZIP = 428;;
let _ARM_INS_ADDW = 429;;
let _ARM_INS_ADR_W = 430;;
let _ARM_INS_ASR = 431;;
let _ARM_INS_DCPS1 = 432;;
let _ARM_INS_DCPS2 = 433;;
let _ARM_INS_DCPS3 = 434;;
let _ARM_INS_IT = 435;;
let _ARM_INS_LSL = 436;;
let _ARM_INS_LSR = 437;;
let _ARM_INS_ORN = 438;;
let _ARM_INS_ROR = 439;;
let _ARM_INS_RRX = 440;;
let _ARM_INS_SUBW = 441;;
let _ARM_INS_TBB = 442;;
let _ARM_INS_TBH = 443;;
let _ARM_INS_CBNZ = 444;;
let _ARM_INS_CBZ = 445;;
let _ARM_INS_NOP = 446;;
let _ARM_INS_POP = 447;;
let _ARM_INS_PUSH = 448;;
let _ARM_INS_SEV = 449;;
let _ARM_INS_SEVL = 450;;
let _ARM_INS_WFE = 451;;
let _ARM_INS_WFI = 452;;
let _ARM_INS_YIELD = 453;;
let _ARM_INS_VCVTA = 285;;
let _ARM_INS_VCVTB = 286;;
let _ARM_INS_VCVT = 287;;
let _ARM_INS_VCVTM = 288;;
let _ARM_INS_VCVTN = 289;;
let _ARM_INS_VCVTP = 290;;
let _ARM_INS_VCVTT = 291;;
let _ARM_INS_VDIV = 292;;
let _ARM_INS_VDUP = 293;;
let _ARM_INS_VEOR = 294;;
let _ARM_INS_VEXT = 295;;
let _ARM_INS_VFMA = 296;;
let _ARM_INS_VFMS = 297;;
let _ARM_INS_VFNMA = 298;;
let _ARM_INS_VFNMS = 299;;
let _ARM_INS_VHADD = 300;;
let _ARM_INS_VHSUB = 301;;
let _ARM_INS_VLD1 = 302;;
let _ARM_INS_VLD2 = 303;;
let _ARM_INS_VLD3 = 304;;
let _ARM_INS_VLD4 = 305;;
let _ARM_INS_VLDMDB = 306;;
let _ARM_INS_VLDMIA = 307;;
let _ARM_INS_VLDR = 308;;
let _ARM_INS_VMAXNM = 309;;
let _ARM_INS_VMAX = 310;;
let _ARM_INS_VMINNM = 311;;
let _ARM_INS_VMIN = 312;;
let _ARM_INS_VMLA = 313;;
let _ARM_INS_VMLAL = 314;;
let _ARM_INS_VMLS = 315;;
let _ARM_INS_VMLSL = 316;;
let _ARM_INS_VMOVL = 317;;
let _ARM_INS_VMOVN = 318;;
let _ARM_INS_VMSR = 319;;
let _ARM_INS_VMUL = 320;;
let _ARM_INS_VMULL = 321;;
let _ARM_INS_VMVN = 322;;
let _ARM_INS_VNEG = 323;;
let _ARM_INS_VNMLA = 324;;
let _ARM_INS_VNMLS = 325;;
let _ARM_INS_VNMUL = 326;;
let _ARM_INS_VORN = 327;;
let _ARM_INS_VORR = 328;;
let _ARM_INS_VPADAL = 329;;
let _ARM_INS_VPADDL = 330;;
let _ARM_INS_VPADD = 331;;
let _ARM_INS_VPMAX = 332;;
let _ARM_INS_VPMIN = 333;;
let _ARM_INS_VQABS = 334;;
let _ARM_INS_VQADD = 335;;
let _ARM_INS_VQDMLAL = 336;;
let _ARM_INS_VQDMLSL = 337;;
let _ARM_INS_VQDMULH = 338;;
let _ARM_INS_VQDMULL = 339;;
let _ARM_INS_VQMOVUN = 340;;
let _ARM_INS_VQMOVN = 341;;
let _ARM_INS_VQNEG = 342;;
let _ARM_INS_VQRDMULH = 343;;
let _ARM_INS_VQRSHL = 344;;
let _ARM_INS_VQRSHRN = 345;;
let _ARM_INS_VQRSHRUN = 346;;
let _ARM_INS_VQSHL = 347;;
let _ARM_INS_VQSHLU = 348;;
let _ARM_INS_VQSHRN = 349;;
let _ARM_INS_VQSHRUN = 350;;
let _ARM_INS_VQSUB = 351;;
let _ARM_INS_VRADDHN = 352;;
let _ARM_INS_VRECPE = 353;;
let _ARM_INS_VRECPS = 354;;
let _ARM_INS_VREV16 = 355;;
let _ARM_INS_VREV32 = 356;;
let _ARM_INS_VREV64 = 357;;
let _ARM_INS_VRHADD = 358;;
let _ARM_INS_VRINTA = 359;;
let _ARM_INS_VRINTM = 360;;
let _ARM_INS_VRINTN = 361;;
let _ARM_INS_VRINTP = 362;;
let _ARM_INS_VRINTR = 363;;
let _ARM_INS_VRINTX = 364;;
let _ARM_INS_VRINTZ = 365;;
let _ARM_INS_VRSHL = 366;;
let _ARM_INS_VRSHRN = 367;;
let _ARM_INS_VRSHR = 368;;
let _ARM_INS_VRSQRTE = 369;;
let _ARM_INS_VRSQRTS = 370;;
let _ARM_INS_VRSRA = 371;;
let _ARM_INS_VRSUBHN = 372;;
let _ARM_INS_VSELEQ = 373;;
let _ARM_INS_VSELGE = 374;;
let _ARM_INS_VSELGT = 375;;
let _ARM_INS_VSELVS = 376;;
let _ARM_INS_VSHLL = 377;;
let _ARM_INS_VSHL = 378;;
let _ARM_INS_VSHRN = 379;;
let _ARM_INS_VSHR = 380;;
let _ARM_INS_VSLI = 381;;
let _ARM_INS_VSQRT = 382;;
let _ARM_INS_VSRA = 383;;
let _ARM_INS_VSRI = 384;;
let _ARM_INS_VST1 = 385;;
let _ARM_INS_VST2 = 386;;
let _ARM_INS_VST3 = 387;;
let _ARM_INS_VST4 = 388;;
let _ARM_INS_VSTMDB = 389;;
let _ARM_INS_VSTMIA = 390;;
let _ARM_INS_VSTR = 391;;
let _ARM_INS_VSUB = 392;;
let _ARM_INS_VSUBHN = 393;;
let _ARM_INS_VSUBL = 394;;
let _ARM_INS_VSUBW = 395;;
let _ARM_INS_VSWP = 396;;
let _ARM_INS_VTBL = 397;;
let _ARM_INS_VTBX = 398;;
let _ARM_INS_VCVTR = 399;;
let _ARM_INS_VTRN = 400;;
let _ARM_INS_VTST = 401;;
let _ARM_INS_VUZP = 402;;
let _ARM_INS_VZIP = 403;;
let _ARM_INS_ADDW = 404;;
let _ARM_INS_ASR = 405;;
let _ARM_INS_DCPS1 = 406;;
let _ARM_INS_DCPS2 = 407;;
let _ARM_INS_DCPS3 = 408;;
let _ARM_INS_IT = 409;;
let _ARM_INS_LSL = 410;;
let _ARM_INS_LSR = 411;;
let _ARM_INS_ASRS = 412;;
let _ARM_INS_LSRS = 413;;
let _ARM_INS_ORN = 414;;
let _ARM_INS_ROR = 415;;
let _ARM_INS_RRX = 416;;
let _ARM_INS_SUBS = 417;;
let _ARM_INS_SUBW = 418;;
let _ARM_INS_TBB = 419;;
let _ARM_INS_TBH = 420;;
let _ARM_INS_CBNZ = 421;;
let _ARM_INS_CBZ = 422;;
let _ARM_INS_MOVS = 423;;
let _ARM_INS_POP = 424;;
let _ARM_INS_PUSH = 425;;
let _ARM_INS_MAX = 426;;
(* ARM group of instructions *)
let _ARM_GRP_INVALID = 0;;
@ -669,4 +662,8 @@ let _ARM_GRP_THUMB2 = 25;;
let _ARM_GRP_PREV8 = 26;;
let _ARM_GRP_FPVMLX = 27;;
let _ARM_GRP_MULOPS = 28;;
let _ARM_GRP_CRC = 29;;
let _ARM_GRP_DPVFP = 30;;
let _ARM_GRP_V6M = 31;;
let _ARM_GRP_JUMP = 32;;
let _ARM_GRP_MAX = 33;;

View File

@ -73,6 +73,14 @@ let _ARM64_CC_LE = 14;;
let _ARM64_CC_AL = 15;;
let _ARM64_CC_NV = 16;;
(* Operand type for instruction's operands *)
let _ARM64_OP_INVALID = 0;;
let _ARM64_OP_REG = 1;;
let _ARM64_OP_CIMM = 2;;
let _ARM64_OP_IMM = 3;;
let _ARM64_OP_FP = 4;;
let _ARM64_OP_MEM = 5;;
(* ARM registers *)
let _ARM64_REG_INVALID = 0;;
let _ARM64_REG_NZCV = 1;;
@ -302,6 +310,13 @@ let _ARM64_REG_X27 = 224;;
let _ARM64_REG_X28 = 225;;
let _ARM64_REG_X29 = 226;;
let _ARM64_REG_X30 = 227;;
let _ARM64_REG_MAX = 228;;
(* alias registers *)
let _ARM64_REG_IP1 = _ARM64_REG_X16;;
let _ARM64_REG_IP0 = _ARM64_REG_X17;;
let _ARM64_REG_FP = _ARM64_REG_X29;;
let _ARM64_REG_LR = _ARM64_REG_X30;;
(* ARM64 instructions *)
let _ARM64_INS_INVALID = 0;;
@ -658,8 +673,104 @@ let _ARM64_INS_USUBW2 = 350;;
let _ARM64_INS_USUBW = 351;;
let _ARM64_INS_UXTB = 352;;
let _ARM64_INS_UXTH = 353;;
let _ARM64_INS_SXTW = 354;;
let _ARM64_INS_SYSL = 355;;
let _ARM64_INS_SYS = 356;;
let _ARM64_INS_TBL = 357;;
let _ARM64_INS_TBNZ = 358;;
let _ARM64_INS_TBX = 359;;
let _ARM64_INS_TBZ = 360;;
let _ARM64_INS_TLBI = 361;;
let _ARM64_INS_TRN1 = 362;;
let _ARM64_INS_TRN2 = 363;;
let _ARM64_INS_TST = 364;;
let _ARM64_INS_UABAL2 = 365;;
let _ARM64_INS_UABAL = 366;;
let _ARM64_INS_UABA = 367;;
let _ARM64_INS_UABDL2 = 368;;
let _ARM64_INS_UABDL = 369;;
let _ARM64_INS_UABD = 370;;
let _ARM64_INS_UADALP = 371;;
let _ARM64_INS_UADDL2 = 372;;
let _ARM64_INS_UADDLP = 373;;
let _ARM64_INS_UADDLV = 374;;
let _ARM64_INS_UADDL = 375;;
let _ARM64_INS_UADDW2 = 376;;
let _ARM64_INS_UADDW = 377;;
let _ARM64_INS_UBFIZ = 378;;
let _ARM64_INS_UBFM = 379;;
let _ARM64_INS_UBFX = 380;;
let _ARM64_INS_UCVTF = 381;;
let _ARM64_INS_UDIV = 382;;
let _ARM64_INS_UHADD = 383;;
let _ARM64_INS_UHSUB = 384;;
let _ARM64_INS_UMADDL = 385;;
let _ARM64_INS_UMAXP = 386;;
let _ARM64_INS_UMAXV = 387;;
let _ARM64_INS_UMAX = 388;;
let _ARM64_INS_UMINP = 389;;
let _ARM64_INS_UMINV = 390;;
let _ARM64_INS_UMIN = 391;;
let _ARM64_INS_UMLAL2 = 392;;
let _ARM64_INS_UMLAL = 393;;
let _ARM64_INS_UMLSL2 = 394;;
let _ARM64_INS_UMLSL = 395;;
let _ARM64_INS_UMOV = 396;;
let _ARM64_INS_UMSUBL = 397;;
let _ARM64_INS_UMULH = 398;;
let _ARM64_INS_UMULL2 = 399;;
let _ARM64_INS_UMULL = 400;;
let _ARM64_INS_UQADD = 401;;
let _ARM64_INS_UQRSHL = 402;;
let _ARM64_INS_UQRSHRN = 403;;
let _ARM64_INS_UQRSHRN2 = 404;;
let _ARM64_INS_UQSHL = 405;;
let _ARM64_INS_UQSHRN = 406;;
let _ARM64_INS_UQSHRN2 = 407;;
let _ARM64_INS_UQSUB = 408;;
let _ARM64_INS_UQXTN = 409;;
let _ARM64_INS_UQXTN2 = 410;;
let _ARM64_INS_URECPE = 411;;
let _ARM64_INS_URHADD = 412;;
let _ARM64_INS_URSHL = 413;;
let _ARM64_INS_URSHR = 414;;
let _ARM64_INS_URSQRTE = 415;;
let _ARM64_INS_URSRA = 416;;
let _ARM64_INS_USHLL2 = 417;;
let _ARM64_INS_USHLL = 418;;
let _ARM64_INS_USHL = 419;;
let _ARM64_INS_USHR = 420;;
let _ARM64_INS_USQADD = 421;;
let _ARM64_INS_USRA = 422;;
let _ARM64_INS_USUBL2 = 423;;
let _ARM64_INS_USUBL = 424;;
let _ARM64_INS_USUBW2 = 425;;
let _ARM64_INS_USUBW = 426;;
let _ARM64_INS_UXTB = 427;;
let _ARM64_INS_UXTH = 428;;
let _ARM64_INS_UZP1 = 429;;
let _ARM64_INS_UZP2 = 430;;
let _ARM64_INS_XTN = 431;;
let _ARM64_INS_XTN2 = 432;;
let _ARM64_INS_ZIP1 = 433;;
let _ARM64_INS_ZIP2 = 434;;
let _ARM64_INS_MNEG = 435;;
let _ARM64_INS_UMNEGL = 436;;
let _ARM64_INS_SMNEGL = 437;;
let _ARM64_INS_MOV = 438;;
let _ARM64_INS_NOP = 439;;
let _ARM64_INS_YIELD = 440;;
let _ARM64_INS_WFE = 441;;
let _ARM64_INS_WFI = 442;;
let _ARM64_INS_SEV = 443;;
let _ARM64_INS_SEVL = 444;;
let _ARM64_INS_NGC = 445;;
let _ARM64_INS_MAX = 446;;
(* ARM64 group of instructions *)
let _ARM64_GRP_INVALID = 0;;
let _ARM64_GRP_NEON = 1;;
let _ARM64_GRP_CRYPTO = 1;;
let _ARM64_GRP_FPARMV8 = 2;;
let _ARM64_GRP_NEON = 3;;
let _ARM64_GRP_JUMP = 4;;
let _ARM64_GRP_MAX = 5;;

View File

@ -4,6 +4,7 @@
open Arm
open Arm64
open Mips
open Ppc
open X86
open Printf (* debug *)
@ -11,6 +12,7 @@ type arch =
| CS_ARCH_ARM
| CS_ARCH_ARM64
| CS_ARCH_MIPS
| CS_ARCH_PPC
| CS_ARCH_X86
type mode =
@ -30,6 +32,7 @@ type cs_arch =
| CS_INFO_ARM of cs_arm
| CS_INFO_ARM64 of cs_arm64
| CS_INFO_MIPS of cs_mips
| CS_INFO_PPC of cs_ppc
| CS_INFO_X86 of cs_x86
type cs_insn0 = {

View File

@ -22,73 +22,46 @@ type cs_mips = {
operands: mips_op array;
}
(* MIPS registers - including alias registers *)
(* Operand type for instruction's operands *)
let _MIPS_OP_INVALID = 0;;
let _MIPS_OP_REG = 1;;
let _MIPS_OP_IMM = 2;;
let _MIPS_OP_MEM = 3;;
(* MIPS registers *)
let _MIPS_REG_INVALID = 0;;
let _MIPS_REG_0 = 1;;
let _MIPS_REG_ZERO = _MIPS_REG_0;;
let _MIPS_REG_1 = 2;;
let _MIPS_REG_AT = _MIPS_REG_1;;
let _MIPS_REG_2 = 3;;
let _MIPS_REG_V0 = _MIPS_REG_2;;
let _MIPS_REG_3 = 4;;
let _MIPS_REG_V1 = _MIPS_REG_3;;
let _MIPS_REG_4 = 5;;
let _MIPS_REG_A0 = _MIPS_REG_4;;
let _MIPS_REG_5 = 6;;
let _MIPS_REG_A1 = _MIPS_REG_5;;
let _MIPS_REG_6 = 7;;
let _MIPS_REG_A2 = _MIPS_REG_6;;
let _MIPS_REG_7 = 8;;
let _MIPS_REG_A3 = _MIPS_REG_7;;
let _MIPS_REG_8 = 9;;
let _MIPS_REG_T0 = _MIPS_REG_8;;
let _MIPS_REG_9 = 10;;
let _MIPS_REG_T1 = _MIPS_REG_9;;
let _MIPS_REG_10 = 11;;
let _MIPS_REG_T2 = _MIPS_REG_10;;
let _MIPS_REG_11 = 12;;
let _MIPS_REG_T3 = _MIPS_REG_11;;
let _MIPS_REG_12 = 13;;
let _MIPS_REG_T4 = _MIPS_REG_12;;
let _MIPS_REG_13 = 14;;
let _MIPS_REG_T5 = _MIPS_REG_13;;
let _MIPS_REG_14 = 15;;
let _MIPS_REG_T6 = _MIPS_REG_14;;
let _MIPS_REG_15 = 16;;
let _MIPS_REG_T7 = _MIPS_REG_15;;
let _MIPS_REG_16 = 17;;
let _MIPS_REG_S0 = _MIPS_REG_16;;
let _MIPS_REG_17 = 18;;
let _MIPS_REG_S1 = _MIPS_REG_17;;
let _MIPS_REG_18 = 19;;
let _MIPS_REG_S2 = _MIPS_REG_18;;
let _MIPS_REG_19 = 20;;
let _MIPS_REG_S3 = _MIPS_REG_19;;
let _MIPS_REG_20 = 21;;
let _MIPS_REG_S4 = _MIPS_REG_20;;
let _MIPS_REG_21 = 22;;
let _MIPS_REG_S5 = _MIPS_REG_21;;
let _MIPS_REG_22 = 23;;
let _MIPS_REG_S6 = _MIPS_REG_22;;
let _MIPS_REG_23 = 24;;
let _MIPS_REG_S7 = _MIPS_REG_23;;
let _MIPS_REG_24 = 25;;
let _MIPS_REG_T8 = _MIPS_REG_24;;
let _MIPS_REG_25 = 26;;
let _MIPS_REG_T9 = _MIPS_REG_25;;
let _MIPS_REG_26 = 27;;
let _MIPS_REG_K0 = _MIPS_REG_26;;
let _MIPS_REG_27 = 28;;
let _MIPS_REG_K1 = _MIPS_REG_27;;
let _MIPS_REG_28 = 29;;
let _MIPS_REG_GP = _MIPS_REG_28;;
let _MIPS_REG_29 = 30;;
let _MIPS_REG_SP = _MIPS_REG_29;;
let _MIPS_REG_30 = 31;;
let _MIPS_REG_FP = _MIPS_REG_30;;
let _MIPS_REG_S8 = _MIPS_REG_30;;
let _MIPS_REG_31 = 32;;
let _MIPS_REG_RA = _MIPS_REG_31;;
let _MIPS_REG_DSPCCOND = 33;;
let _MIPS_REG_DSPCARRY = 34;;
let _MIPS_REG_DSPEFI = 35;;
@ -101,17 +74,9 @@ let _MIPS_REG_DSPOUTFLAG23 = 41;;
let _MIPS_REG_DSPPOS = 42;;
let _MIPS_REG_DSPSCOUNT = 43;;
let _MIPS_REG_AC0 = 44;;
let _MIPS_REG_HI0 = _MIPS_REG_AC0;;
let _MIPS_REG_AC1 = 45;;
let _MIPS_REG_HI1 = _MIPS_REG_AC1;;
let _MIPS_REG_AC2 = 46;;
let _MIPS_REG_HI2 = _MIPS_REG_AC2;;
let _MIPS_REG_AC3 = 47;;
let _MIPS_REG_HI3 = _MIPS_REG_AC3;;
let _MIPS_REG_LO0 = _MIPS_REG_HI0;;
let _MIPS_REG_LO1 = _MIPS_REG_HI1;;
let _MIPS_REG_LO2 = _MIPS_REG_HI2;;
let _MIPS_REG_LO3 = _MIPS_REG_HI3;;
let _MIPS_REG_F0 = 48;;
let _MIPS_REG_F1 = 49;;
let _MIPS_REG_F2 = 50;;
@ -184,8 +149,51 @@ let _MIPS_REG_W28 = 116;;
let _MIPS_REG_W29 = 117;;
let _MIPS_REG_W30 = 118;;
let _MIPS_REG_W31 = 119;;
let _MIPS_REG_MAX = 120;;
let _MIPS_REG_HI = 120;;
let _MIPS_REG_LO = 121;;
let _MIPS_REG_PC = 122;;
let _MIPS_REG_MAX = 123;;
let _MIPS_REG_ZERO = _MIPS_REG_0;;
let _MIPS_REG_AT = _MIPS_REG_1;;
let _MIPS_REG_V0 = _MIPS_REG_2;;
let _MIPS_REG_V1 = _MIPS_REG_3;;
let _MIPS_REG_A0 = _MIPS_REG_4;;
let _MIPS_REG_A1 = _MIPS_REG_5;;
let _MIPS_REG_A2 = _MIPS_REG_6;;
let _MIPS_REG_A3 = _MIPS_REG_7;;
let _MIPS_REG_T0 = _MIPS_REG_8;;
let _MIPS_REG_T1 = _MIPS_REG_9;;
let _MIPS_REG_T2 = _MIPS_REG_10;;
let _MIPS_REG_T3 = _MIPS_REG_11;;
let _MIPS_REG_T4 = _MIPS_REG_12;;
let _MIPS_REG_T5 = _MIPS_REG_13;;
let _MIPS_REG_T6 = _MIPS_REG_14;;
let _MIPS_REG_T7 = _MIPS_REG_15;;
let _MIPS_REG_S0 = _MIPS_REG_16;;
let _MIPS_REG_S1 = _MIPS_REG_17;;
let _MIPS_REG_S2 = _MIPS_REG_18;;
let _MIPS_REG_S3 = _MIPS_REG_19;;
let _MIPS_REG_S4 = _MIPS_REG_20;;
let _MIPS_REG_S5 = _MIPS_REG_21;;
let _MIPS_REG_S6 = _MIPS_REG_22;;
let _MIPS_REG_S7 = _MIPS_REG_23;;
let _MIPS_REG_T8 = _MIPS_REG_24;;
let _MIPS_REG_T9 = _MIPS_REG_25;;
let _MIPS_REG_K0 = _MIPS_REG_26;;
let _MIPS_REG_K1 = _MIPS_REG_27;;
let _MIPS_REG_GP = _MIPS_REG_28;;
let _MIPS_REG_SP = _MIPS_REG_29;;
let _MIPS_REG_FP = _MIPS_REG_30;;
let _MIPS_REG_S8 = _MIPS_REG_30;;
let _MIPS_REG_RA = _MIPS_REG_31;;
let _MIPS_REG_HI0 = _MIPS_REG_AC0;;
let _MIPS_REG_HI1 = _MIPS_REG_AC1;;
let _MIPS_REG_HI2 = _MIPS_REG_AC2;;
let _MIPS_REG_HI3 = _MIPS_REG_AC3;;
let _MIPS_REG_LO0 = _MIPS_REG_HI0;;
let _MIPS_REG_LO1 = _MIPS_REG_HI1;;
let _MIPS_REG_LO2 = _MIPS_REG_HI2;;
let _MIPS_REG_LO3 = _MIPS_REG_HI3;;
(* MIPS instructions *)
let _MIPS_INS_INVALID = 0;;
@ -297,260 +305,260 @@ let _MIPS_INS_DINSM = 105;;
let _MIPS_INS_DINSU = 106;;
let _MIPS_INS_DIV_S = 107;;
let _MIPS_INS_DIV_U = 108;;
let _MIPS_INS_DMFC0 = 109;;
let _MIPS_INS_DMFC1 = 110;;
let _MIPS_INS_DMFC2 = 111;;
let _MIPS_INS_DMTC0 = 112;;
let _MIPS_INS_DMTC1 = 113;;
let _MIPS_INS_DMTC2 = 114;;
let _MIPS_INS_DMULT = 115;;
let _MIPS_INS_DMULTU = 116;;
let _MIPS_INS_DOTP_S = 117;;
let _MIPS_INS_DOTP_U = 118;;
let _MIPS_INS_DPADD_S = 119;;
let _MIPS_INS_DPADD_U = 120;;
let _MIPS_INS_DPAQX_SA = 121;;
let _MIPS_INS_DPAQX_S = 122;;
let _MIPS_INS_DPAQ_SA = 123;;
let _MIPS_INS_DPAQ_S = 124;;
let _MIPS_INS_DPAU = 125;;
let _MIPS_INS_DPAX = 126;;
let _MIPS_INS_DPA = 127;;
let _MIPS_INS_DPSQX_SA = 128;;
let _MIPS_INS_DPSQX_S = 129;;
let _MIPS_INS_DPSQ_SA = 130;;
let _MIPS_INS_DPSQ_S = 131;;
let _MIPS_INS_DPSUB_S = 132;;
let _MIPS_INS_DPSUB_U = 133;;
let _MIPS_INS_DPSU = 134;;
let _MIPS_INS_DPSX = 135;;
let _MIPS_INS_DPS = 136;;
let _MIPS_INS_DROTR = 137;;
let _MIPS_INS_DROTR32 = 138;;
let _MIPS_INS_DROTRV = 139;;
let _MIPS_INS_DSBH = 140;;
let _MIPS_INS_DDIV = 141;;
let _MIPS_INS_DSHD = 142;;
let _MIPS_INS_DSLL = 143;;
let _MIPS_INS_DSLL32 = 144;;
let _MIPS_INS_DSLLV = 145;;
let _MIPS_INS_DSRA = 146;;
let _MIPS_INS_DSRA32 = 147;;
let _MIPS_INS_DSRAV = 148;;
let _MIPS_INS_DSRL = 149;;
let _MIPS_INS_DSRL32 = 150;;
let _MIPS_INS_DSRLV = 151;;
let _MIPS_INS_DSUBU = 152;;
let _MIPS_INS_DDIVU = 153;;
let _MIPS_INS_DIV = 154;;
let _MIPS_INS_DIVU = 155;;
let _MIPS_INS_EI = 156;;
let _MIPS_INS_ERET = 157;;
let _MIPS_INS_EXT = 158;;
let _MIPS_INS_EXTP = 159;;
let _MIPS_INS_EXTPDP = 160;;
let _MIPS_INS_EXTPDPV = 161;;
let _MIPS_INS_EXTPV = 162;;
let _MIPS_INS_EXTRV_RS = 163;;
let _MIPS_INS_EXTRV_R = 164;;
let _MIPS_INS_EXTRV_S = 165;;
let _MIPS_INS_EXTRV = 166;;
let _MIPS_INS_EXTR_RS = 167;;
let _MIPS_INS_EXTR_R = 168;;
let _MIPS_INS_EXTR_S = 169;;
let _MIPS_INS_EXTR = 170;;
let _MIPS_INS_ABS = 171;;
let _MIPS_INS_FADD = 172;;
let _MIPS_INS_FCAF = 173;;
let _MIPS_INS_FCEQ = 174;;
let _MIPS_INS_FCLASS = 175;;
let _MIPS_INS_FCLE = 176;;
let _MIPS_INS_FCLT = 177;;
let _MIPS_INS_FCNE = 178;;
let _MIPS_INS_FCOR = 179;;
let _MIPS_INS_FCUEQ = 180;;
let _MIPS_INS_FCULE = 181;;
let _MIPS_INS_FCULT = 182;;
let _MIPS_INS_FCUNE = 183;;
let _MIPS_INS_FCUN = 184;;
let _MIPS_INS_FDIV = 185;;
let _MIPS_INS_FEXDO = 186;;
let _MIPS_INS_FEXP2 = 187;;
let _MIPS_INS_FEXUPL = 188;;
let _MIPS_INS_FEXUPR = 189;;
let _MIPS_INS_FFINT_S = 190;;
let _MIPS_INS_FFINT_U = 191;;
let _MIPS_INS_FFQL = 192;;
let _MIPS_INS_FFQR = 193;;
let _MIPS_INS_FILL = 194;;
let _MIPS_INS_FLOG2 = 195;;
let _MIPS_INS_FLOOR = 196;;
let _MIPS_INS_FMADD = 197;;
let _MIPS_INS_FMAX_A = 198;;
let _MIPS_INS_FMAX = 199;;
let _MIPS_INS_FMIN_A = 200;;
let _MIPS_INS_FMIN = 201;;
let _MIPS_INS_MOV = 202;;
let _MIPS_INS_FMSUB = 203;;
let _MIPS_INS_FMUL = 204;;
let _MIPS_INS_MUL = 205;;
let _MIPS_INS_NEG = 206;;
let _MIPS_INS_FRCP = 207;;
let _MIPS_INS_FRINT = 208;;
let _MIPS_INS_FRSQRT = 209;;
let _MIPS_INS_FSAF = 210;;
let _MIPS_INS_FSEQ = 211;;
let _MIPS_INS_FSLE = 212;;
let _MIPS_INS_FSLT = 213;;
let _MIPS_INS_FSNE = 214;;
let _MIPS_INS_FSOR = 215;;
let _MIPS_INS_FSQRT = 216;;
let _MIPS_INS_SQRT = 217;;
let _MIPS_INS_FSUB = 218;;
let _MIPS_INS_SUB = 219;;
let _MIPS_INS_FSUEQ = 220;;
let _MIPS_INS_FSULE = 221;;
let _MIPS_INS_FSULT = 222;;
let _MIPS_INS_FSUNE = 223;;
let _MIPS_INS_FSUN = 224;;
let _MIPS_INS_FTINT_S = 225;;
let _MIPS_INS_FTINT_U = 226;;
let _MIPS_INS_FTQ = 227;;
let _MIPS_INS_FTRUNC_S = 228;;
let _MIPS_INS_FTRUNC_U = 229;;
let _MIPS_INS_HADD_S = 230;;
let _MIPS_INS_HADD_U = 231;;
let _MIPS_INS_HSUB_S = 232;;
let _MIPS_INS_HSUB_U = 233;;
let _MIPS_INS_ILVEV = 234;;
let _MIPS_INS_ILVL = 235;;
let _MIPS_INS_ILVOD = 236;;
let _MIPS_INS_ILVR = 237;;
let _MIPS_INS_INS = 238;;
let _MIPS_INS_INSERT = 239;;
let _MIPS_INS_INSV = 240;;
let _MIPS_INS_INSVE = 241;;
let _MIPS_INS_J = 242;;
let _MIPS_INS_JAL = 243;;
let _MIPS_INS_JALR = 244;;
let _MIPS_INS_JR = 245;;
let _MIPS_INS_JRC = 246;;
let _MIPS_INS_JALRC = 247;;
let _MIPS_INS_LB = 248;;
let _MIPS_INS_LBUX = 249;;
let _MIPS_INS_LBU = 250;;
let _MIPS_INS_LD = 251;;
let _MIPS_INS_LDC1 = 252;;
let _MIPS_INS_LDC2 = 253;;
let _MIPS_INS_LDI = 254;;
let _MIPS_INS_LDL = 255;;
let _MIPS_INS_LDR = 256;;
let _MIPS_INS_LDXC1 = 257;;
let _MIPS_INS_LH = 258;;
let _MIPS_INS_LHX = 259;;
let _MIPS_INS_LHU = 260;;
let _MIPS_INS_LL = 261;;
let _MIPS_INS_LLD = 262;;
let _MIPS_INS_LSA = 263;;
let _MIPS_INS_LUXC1 = 264;;
let _MIPS_INS_LUI = 265;;
let _MIPS_INS_LW = 266;;
let _MIPS_INS_LWC1 = 267;;
let _MIPS_INS_LWC2 = 268;;
let _MIPS_INS_LWL = 269;;
let _MIPS_INS_LWR = 270;;
let _MIPS_INS_LWX = 271;;
let _MIPS_INS_LWXC1 = 272;;
let _MIPS_INS_LWU = 273;;
let _MIPS_INS_LI = 274;;
let _MIPS_INS_MADD = 275;;
let _MIPS_INS_MADDR_Q = 276;;
let _MIPS_INS_MADDU = 277;;
let _MIPS_INS_MADDV = 278;;
let _MIPS_INS_MADD_Q = 279;;
let _MIPS_INS_MAQ_SA = 280;;
let _MIPS_INS_MAQ_S = 281;;
let _MIPS_INS_MAXI_S = 282;;
let _MIPS_INS_MAXI_U = 283;;
let _MIPS_INS_MAX_A = 284;;
let _MIPS_INS_MAX_S = 285;;
let _MIPS_INS_MAX_U = 286;;
let _MIPS_INS_MFC0 = 287;;
let _MIPS_INS_MFC1 = 288;;
let _MIPS_INS_MFC2 = 289;;
let _MIPS_INS_MFHC1 = 290;;
let _MIPS_INS_MFHI = 291;;
let _MIPS_INS_MFLO = 292;;
let _MIPS_INS_MINI_S = 293;;
let _MIPS_INS_MINI_U = 294;;
let _MIPS_INS_MIN_A = 295;;
let _MIPS_INS_MIN_S = 296;;
let _MIPS_INS_MIN_U = 297;;
let _MIPS_INS_MODSUB = 298;;
let _MIPS_INS_MOD_S = 299;;
let _MIPS_INS_MOD_U = 300;;
let _MIPS_INS_MOVE = 301;;
let _MIPS_INS_MOVF = 302;;
let _MIPS_INS_MOVN = 303;;
let _MIPS_INS_MOVT = 304;;
let _MIPS_INS_MOVZ = 305;;
let _MIPS_INS_MSUB = 306;;
let _MIPS_INS_MSUBR_Q = 307;;
let _MIPS_INS_MSUBU = 308;;
let _MIPS_INS_MSUBV = 309;;
let _MIPS_INS_MSUB_Q = 310;;
let _MIPS_INS_MTC0 = 311;;
let _MIPS_INS_MTC1 = 312;;
let _MIPS_INS_MTC2 = 313;;
let _MIPS_INS_MTHC1 = 314;;
let _MIPS_INS_MTHI = 315;;
let _MIPS_INS_MTHLIP = 316;;
let _MIPS_INS_MTLO = 317;;
let _MIPS_INS_MULEQ_S = 318;;
let _MIPS_INS_MULEU_S = 319;;
let _MIPS_INS_MULQ_RS = 320;;
let _MIPS_INS_MULQ_S = 321;;
let _MIPS_INS_MULR_Q = 322;;
let _MIPS_INS_MULSAQ_S = 323;;
let _MIPS_INS_MULSA = 324;;
let _MIPS_INS_MULT = 325;;
let _MIPS_INS_MULTU = 326;;
let _MIPS_INS_MULV = 327;;
let _MIPS_INS_MUL_Q = 328;;
let _MIPS_INS_MUL_S = 329;;
let _MIPS_INS_NLOC = 330;;
let _MIPS_INS_NLZC = 331;;
let _MIPS_INS_NMADD = 332;;
let _MIPS_INS_NMSUB = 333;;
let _MIPS_INS_NOR = 334;;
let _MIPS_INS_NORI = 335;;
let _MIPS_INS_NOT = 336;;
let _MIPS_INS_OR = 337;;
let _MIPS_INS_ORI = 338;;
let _MIPS_INS_PACKRL = 339;;
let _MIPS_INS_PCKEV = 340;;
let _MIPS_INS_PCKOD = 341;;
let _MIPS_INS_PCNT = 342;;
let _MIPS_INS_PICK = 343;;
let _MIPS_INS_PRECEQU = 344;;
let _MIPS_INS_PRECEQ = 345;;
let _MIPS_INS_PRECEU = 346;;
let _MIPS_INS_PRECRQU_S = 347;;
let _MIPS_INS_PRECRQ = 348;;
let _MIPS_INS_PRECRQ_RS = 349;;
let _MIPS_INS_PRECR = 350;;
let _MIPS_INS_PRECR_SRA = 351;;
let _MIPS_INS_PRECR_SRA_R = 352;;
let _MIPS_INS_PREPEND = 353;;
let _MIPS_INS_RADDU = 354;;
let _MIPS_INS_RDDSP = 355;;
let _MIPS_INS_RDHWR = 356;;
let _MIPS_INS_REPLV = 357;;
let _MIPS_INS_REPL = 358;;
let _MIPS_INS_ROTR = 359;;
let _MIPS_INS_ROTRV = 360;;
let _MIPS_INS_ROUND = 361;;
let _MIPS_INS_RESTORE = 362;;
let _MIPS_INS_DLSA = 109;;
let _MIPS_INS_DMFC0 = 110;;
let _MIPS_INS_DMFC1 = 111;;
let _MIPS_INS_DMFC2 = 112;;
let _MIPS_INS_DMTC0 = 113;;
let _MIPS_INS_DMTC1 = 114;;
let _MIPS_INS_DMTC2 = 115;;
let _MIPS_INS_DMULT = 116;;
let _MIPS_INS_DMULTU = 117;;
let _MIPS_INS_DOTP_S = 118;;
let _MIPS_INS_DOTP_U = 119;;
let _MIPS_INS_DPADD_S = 120;;
let _MIPS_INS_DPADD_U = 121;;
let _MIPS_INS_DPAQX_SA = 122;;
let _MIPS_INS_DPAQX_S = 123;;
let _MIPS_INS_DPAQ_SA = 124;;
let _MIPS_INS_DPAQ_S = 125;;
let _MIPS_INS_DPAU = 126;;
let _MIPS_INS_DPAX = 127;;
let _MIPS_INS_DPA = 128;;
let _MIPS_INS_DPSQX_SA = 129;;
let _MIPS_INS_DPSQX_S = 130;;
let _MIPS_INS_DPSQ_SA = 131;;
let _MIPS_INS_DPSQ_S = 132;;
let _MIPS_INS_DPSUB_S = 133;;
let _MIPS_INS_DPSUB_U = 134;;
let _MIPS_INS_DPSU = 135;;
let _MIPS_INS_DPSX = 136;;
let _MIPS_INS_DPS = 137;;
let _MIPS_INS_DROTR = 138;;
let _MIPS_INS_DROTR32 = 139;;
let _MIPS_INS_DROTRV = 140;;
let _MIPS_INS_DSBH = 141;;
let _MIPS_INS_DDIV = 142;;
let _MIPS_INS_DSHD = 143;;
let _MIPS_INS_DSLL = 144;;
let _MIPS_INS_DSLL32 = 145;;
let _MIPS_INS_DSLLV = 146;;
let _MIPS_INS_DSRA = 147;;
let _MIPS_INS_DSRA32 = 148;;
let _MIPS_INS_DSRAV = 149;;
let _MIPS_INS_DSRL = 150;;
let _MIPS_INS_DSRL32 = 151;;
let _MIPS_INS_DSRLV = 152;;
let _MIPS_INS_DSUBU = 153;;
let _MIPS_INS_DDIVU = 154;;
let _MIPS_INS_DIV = 155;;
let _MIPS_INS_DIVU = 156;;
let _MIPS_INS_EI = 157;;
let _MIPS_INS_ERET = 158;;
let _MIPS_INS_EXT = 159;;
let _MIPS_INS_EXTP = 160;;
let _MIPS_INS_EXTPDP = 161;;
let _MIPS_INS_EXTPDPV = 162;;
let _MIPS_INS_EXTPV = 163;;
let _MIPS_INS_EXTRV_RS = 164;;
let _MIPS_INS_EXTRV_R = 165;;
let _MIPS_INS_EXTRV_S = 166;;
let _MIPS_INS_EXTRV = 167;;
let _MIPS_INS_EXTR_RS = 168;;
let _MIPS_INS_EXTR_R = 169;;
let _MIPS_INS_EXTR_S = 170;;
let _MIPS_INS_EXTR = 171;;
let _MIPS_INS_ABS = 172;;
let _MIPS_INS_FADD = 173;;
let _MIPS_INS_FCAF = 174;;
let _MIPS_INS_FCEQ = 175;;
let _MIPS_INS_FCLASS = 176;;
let _MIPS_INS_FCLE = 177;;
let _MIPS_INS_FCLT = 178;;
let _MIPS_INS_FCNE = 179;;
let _MIPS_INS_FCOR = 180;;
let _MIPS_INS_FCUEQ = 181;;
let _MIPS_INS_FCULE = 182;;
let _MIPS_INS_FCULT = 183;;
let _MIPS_INS_FCUNE = 184;;
let _MIPS_INS_FCUN = 185;;
let _MIPS_INS_FDIV = 186;;
let _MIPS_INS_FEXDO = 187;;
let _MIPS_INS_FEXP2 = 188;;
let _MIPS_INS_FEXUPL = 189;;
let _MIPS_INS_FEXUPR = 190;;
let _MIPS_INS_FFINT_S = 191;;
let _MIPS_INS_FFINT_U = 192;;
let _MIPS_INS_FFQL = 193;;
let _MIPS_INS_FFQR = 194;;
let _MIPS_INS_FILL = 195;;
let _MIPS_INS_FLOG2 = 196;;
let _MIPS_INS_FLOOR = 197;;
let _MIPS_INS_FMADD = 198;;
let _MIPS_INS_FMAX_A = 199;;
let _MIPS_INS_FMAX = 200;;
let _MIPS_INS_FMIN_A = 201;;
let _MIPS_INS_FMIN = 202;;
let _MIPS_INS_MOV = 203;;
let _MIPS_INS_FMSUB = 204;;
let _MIPS_INS_FMUL = 205;;
let _MIPS_INS_MUL = 206;;
let _MIPS_INS_NEG = 207;;
let _MIPS_INS_FRCP = 208;;
let _MIPS_INS_FRINT = 209;;
let _MIPS_INS_FRSQRT = 210;;
let _MIPS_INS_FSAF = 211;;
let _MIPS_INS_FSEQ = 212;;
let _MIPS_INS_FSLE = 213;;
let _MIPS_INS_FSLT = 214;;
let _MIPS_INS_FSNE = 215;;
let _MIPS_INS_FSOR = 216;;
let _MIPS_INS_FSQRT = 217;;
let _MIPS_INS_SQRT = 218;;
let _MIPS_INS_FSUB = 219;;
let _MIPS_INS_SUB = 220;;
let _MIPS_INS_FSUEQ = 221;;
let _MIPS_INS_FSULE = 222;;
let _MIPS_INS_FSULT = 223;;
let _MIPS_INS_FSUNE = 224;;
let _MIPS_INS_FSUN = 225;;
let _MIPS_INS_FTINT_S = 226;;
let _MIPS_INS_FTINT_U = 227;;
let _MIPS_INS_FTQ = 228;;
let _MIPS_INS_FTRUNC_S = 229;;
let _MIPS_INS_FTRUNC_U = 230;;
let _MIPS_INS_HADD_S = 231;;
let _MIPS_INS_HADD_U = 232;;
let _MIPS_INS_HSUB_S = 233;;
let _MIPS_INS_HSUB_U = 234;;
let _MIPS_INS_ILVEV = 235;;
let _MIPS_INS_ILVL = 236;;
let _MIPS_INS_ILVOD = 237;;
let _MIPS_INS_ILVR = 238;;
let _MIPS_INS_INS = 239;;
let _MIPS_INS_INSERT = 240;;
let _MIPS_INS_INSV = 241;;
let _MIPS_INS_INSVE = 242;;
let _MIPS_INS_J = 243;;
let _MIPS_INS_JAL = 244;;
let _MIPS_INS_JALR = 245;;
let _MIPS_INS_JR = 246;;
let _MIPS_INS_JRC = 247;;
let _MIPS_INS_JALRC = 248;;
let _MIPS_INS_LB = 249;;
let _MIPS_INS_LBUX = 250;;
let _MIPS_INS_LBU = 251;;
let _MIPS_INS_LD = 252;;
let _MIPS_INS_LDC1 = 253;;
let _MIPS_INS_LDC2 = 254;;
let _MIPS_INS_LDI = 255;;
let _MIPS_INS_LDL = 256;;
let _MIPS_INS_LDR = 257;;
let _MIPS_INS_LDXC1 = 258;;
let _MIPS_INS_LH = 259;;
let _MIPS_INS_LHX = 260;;
let _MIPS_INS_LHU = 261;;
let _MIPS_INS_LL = 262;;
let _MIPS_INS_LLD = 263;;
let _MIPS_INS_LSA = 264;;
let _MIPS_INS_LUXC1 = 265;;
let _MIPS_INS_LUI = 266;;
let _MIPS_INS_LW = 267;;
let _MIPS_INS_LWC1 = 268;;
let _MIPS_INS_LWC2 = 269;;
let _MIPS_INS_LWL = 270;;
let _MIPS_INS_LWR = 271;;
let _MIPS_INS_LWU = 272;;
let _MIPS_INS_LWX = 273;;
let _MIPS_INS_LWXC1 = 274;;
let _MIPS_INS_LI = 275;;
let _MIPS_INS_MADD = 276;;
let _MIPS_INS_MADDR_Q = 277;;
let _MIPS_INS_MADDU = 278;;
let _MIPS_INS_MADDV = 279;;
let _MIPS_INS_MADD_Q = 280;;
let _MIPS_INS_MAQ_SA = 281;;
let _MIPS_INS_MAQ_S = 282;;
let _MIPS_INS_MAXI_S = 283;;
let _MIPS_INS_MAXI_U = 284;;
let _MIPS_INS_MAX_A = 285;;
let _MIPS_INS_MAX_S = 286;;
let _MIPS_INS_MAX_U = 287;;
let _MIPS_INS_MFC0 = 288;;
let _MIPS_INS_MFC1 = 289;;
let _MIPS_INS_MFC2 = 290;;
let _MIPS_INS_MFHC1 = 291;;
let _MIPS_INS_MFHI = 292;;
let _MIPS_INS_MFLO = 293;;
let _MIPS_INS_MINI_S = 294;;
let _MIPS_INS_MINI_U = 295;;
let _MIPS_INS_MIN_A = 296;;
let _MIPS_INS_MIN_S = 297;;
let _MIPS_INS_MIN_U = 298;;
let _MIPS_INS_MODSUB = 299;;
let _MIPS_INS_MOD_S = 300;;
let _MIPS_INS_MOD_U = 301;;
let _MIPS_INS_MOVE = 302;;
let _MIPS_INS_MOVF = 303;;
let _MIPS_INS_MOVN = 304;;
let _MIPS_INS_MOVT = 305;;
let _MIPS_INS_MOVZ = 306;;
let _MIPS_INS_MSUB = 307;;
let _MIPS_INS_MSUBR_Q = 308;;
let _MIPS_INS_MSUBU = 309;;
let _MIPS_INS_MSUBV = 310;;
let _MIPS_INS_MSUB_Q = 311;;
let _MIPS_INS_MTC0 = 312;;
let _MIPS_INS_MTC1 = 313;;
let _MIPS_INS_MTC2 = 314;;
let _MIPS_INS_MTHC1 = 315;;
let _MIPS_INS_MTHI = 316;;
let _MIPS_INS_MTHLIP = 317;;
let _MIPS_INS_MTLO = 318;;
let _MIPS_INS_MULEQ_S = 319;;
let _MIPS_INS_MULEU_S = 320;;
let _MIPS_INS_MULQ_RS = 321;;
let _MIPS_INS_MULQ_S = 322;;
let _MIPS_INS_MULR_Q = 323;;
let _MIPS_INS_MULSAQ_S = 324;;
let _MIPS_INS_MULSA = 325;;
let _MIPS_INS_MULT = 326;;
let _MIPS_INS_MULTU = 327;;
let _MIPS_INS_MULV = 328;;
let _MIPS_INS_MUL_Q = 329;;
let _MIPS_INS_MUL_S = 330;;
let _MIPS_INS_NLOC = 331;;
let _MIPS_INS_NLZC = 332;;
let _MIPS_INS_NMADD = 333;;
let _MIPS_INS_NMSUB = 334;;
let _MIPS_INS_NOR = 335;;
let _MIPS_INS_NORI = 336;;
let _MIPS_INS_NOT = 337;;
let _MIPS_INS_OR = 338;;
let _MIPS_INS_ORI = 339;;
let _MIPS_INS_PACKRL = 340;;
let _MIPS_INS_PCKEV = 341;;
let _MIPS_INS_PCKOD = 342;;
let _MIPS_INS_PCNT = 343;;
let _MIPS_INS_PICK = 344;;
let _MIPS_INS_PRECEQU = 345;;
let _MIPS_INS_PRECEQ = 346;;
let _MIPS_INS_PRECEU = 347;;
let _MIPS_INS_PRECRQU_S = 348;;
let _MIPS_INS_PRECRQ = 349;;
let _MIPS_INS_PRECRQ_RS = 350;;
let _MIPS_INS_PRECR = 351;;
let _MIPS_INS_PRECR_SRA = 352;;
let _MIPS_INS_PRECR_SRA_R = 353;;
let _MIPS_INS_PREPEND = 354;;
let _MIPS_INS_RADDU = 355;;
let _MIPS_INS_RDDSP = 356;;
let _MIPS_INS_RDHWR = 357;;
let _MIPS_INS_REPLV = 358;;
let _MIPS_INS_REPL = 359;;
let _MIPS_INS_ROTR = 360;;
let _MIPS_INS_ROTRV = 361;;
let _MIPS_INS_ROUND = 362;;
let _MIPS_INS_SAT_S = 363;;
let _MIPS_INS_SAT_U = 364;;
let _MIPS_INS_SB = 365;;
@ -623,29 +631,30 @@ let _MIPS_INS_SWR = 431;;
let _MIPS_INS_SWXC1 = 432;;
let _MIPS_INS_SYNC = 433;;
let _MIPS_INS_SYSCALL = 434;;
let _MIPS_INS_SAVE = 435;;
let _MIPS_INS_TEQ = 436;;
let _MIPS_INS_TEQI = 437;;
let _MIPS_INS_TGE = 438;;
let _MIPS_INS_TGEI = 439;;
let _MIPS_INS_TGEIU = 440;;
let _MIPS_INS_TGEU = 441;;
let _MIPS_INS_TLT = 442;;
let _MIPS_INS_TLTI = 443;;
let _MIPS_INS_TEQ = 435;;
let _MIPS_INS_TEQI = 436;;
let _MIPS_INS_TGE = 437;;
let _MIPS_INS_TGEI = 438;;
let _MIPS_INS_TGEIU = 439;;
let _MIPS_INS_TGEU = 440;;
let _MIPS_INS_TLT = 441;;
let _MIPS_INS_TLTI = 442;;
let _MIPS_INS_TLTIU = 443;;
let _MIPS_INS_TLTU = 444;;
let _MIPS_INS_TNE = 445;;
let _MIPS_INS_TNEI = 446;;
let _MIPS_INS_TRUNC = 447;;
let _MIPS_INS_TLTIU = 448;;
let _MIPS_INS_VSHF = 449;;
let _MIPS_INS_WAIT = 450;;
let _MIPS_INS_WRDSP = 451;;
let _MIPS_INS_WSBH = 452;;
let _MIPS_INS_XOR = 453;;
let _MIPS_INS_XORI = 454;;
let _MIPS_INS_NOP = 455;;
let _MIPS_INS_MAX = 456;;
let _MIPS_INS_VSHF = 448;;
let _MIPS_INS_WAIT = 449;;
let _MIPS_INS_WRDSP = 450;;
let _MIPS_INS_WSBH = 451;;
let _MIPS_INS_XOR = 452;;
let _MIPS_INS_XORI = 453;;
(* some alias instructions *)
let _MIPS_INS_NOP = 454;;
let _MIPS_INS_NEGU = 455;;
let _MIPS_INS_MAX = 456;;
(* MIPS group of instructions *)
let _MIPS_GRP_INVALID = 0;;
@ -665,6 +674,8 @@ let _MIPS_GRP_MIPS16MODE = 13;;
let _MIPS_GRP_FP64BIT = 14;;
let _MIPS_GRP_NONANSFPMATH = 15;;
let _MIPS_GRP_NOTFP64BIT = 16;;
let _MIPS_GRP_RELOCSTATIC = 17;;
let _MIPS_GRP_MAX = 18;;
let _MIPS_GRP_NOTINMICROMIPS = 17;;
let _MIPS_GRP_NOTNACL = 18;;
let _MIPS_GRP_JUMP = 19;;
let _MIPS_GRP_MAX = 20;;

View File

@ -12,22 +12,6 @@
#define ARR_SIZE(a) (sizeof(a)/sizeof(a[0]))
// count the number of positive members in @oplist
#define ARCH_LIST_COUNT(_arch, _optype) \
static unsigned int _arch ## _list_count(_optype *list, unsigned int max) \
{ \
unsigned int i; \
for(i = 0; i < max; i++) \
if (list[i].type == 0) \
return i; \
return max; \
}
ARCH_LIST_COUNT(arm, cs_arm_op)
ARCH_LIST_COUNT(arm64, cs_arm64_op)
ARCH_LIST_COUNT(mips, cs_mips_op)
ARCH_LIST_COUNT(x86, cs_x86_op)
// count the number of positive members in @list
static unsigned int list_count(uint8_t *list, unsigned int max)
@ -125,8 +109,10 @@ CAMLprim value _cs_disasm(cs_arch arch, csh handle, const uint8_t * code, size_t
Store_field(op_info_val, 0, Val_int(insn[j-1].detail->arm.cc));
Store_field(op_info_val, 1, Val_bool(insn[j-1].detail->arm.update_flags));
Store_field(op_info_val, 2, Val_bool(insn[j-1].detail->arm.writeback));
Store_field(op_info_val, 3, Val_int(insn[j-1].detail->arm.op_count));
lcount = arm_list_count(insn[j - 1].detail->arm.operands, ARR_SIZE(insn[j - 1].detail->arm.operands));
lcount = insn[j-1].detail->arm.op_count;
Store_field(op_info_val, 3, Val_int(lcount));
if (lcount > 0) {
array = caml_alloc(lcount, 0);
for (i = 0; i < lcount; i++) {
@ -188,9 +174,10 @@ CAMLprim value _cs_disasm(cs_arch arch, csh handle, const uint8_t * code, size_t
Store_field(op_info_val, 0, Val_int(insn[j-1].detail->arm64.cc));
Store_field(op_info_val, 1, Val_bool(insn[j-1].detail->arm64.update_flags));
Store_field(op_info_val, 2, Val_bool(insn[j-1].detail->arm64.writeback));
Store_field(op_info_val, 3, Val_int(insn[j-1].detail->arm64.op_count));
lcount = insn[j-1].detail->arm64.op_count;
Store_field(op_info_val, 3, Val_int(lcount));
lcount = arm64_list_count(insn[j - 1].detail->arm64.operands, ARR_SIZE(insn[j - 1].detail->arm64.operands));
if (lcount > 0) {
array = caml_alloc(lcount, 0);
for (i = 0; i < lcount; i++) {
@ -246,9 +233,11 @@ CAMLprim value _cs_disasm(cs_arch arch, csh handle, const uint8_t * code, size_t
arch_info = caml_alloc(1, 2);
op_info_val = caml_alloc(2, 0);
Store_field(op_info_val, 0, Val_int(insn[j-1].detail->mips.op_count));
lcount = mips_list_count(insn[j - 1].detail->mips.operands, ARR_SIZE(insn[j - 1].detail->mips.operands));
lcount = insn[j-1].detail->mips.op_count;
Store_field(op_info_val, 0, Val_int(lcount));
if (lcount > 0) {
array = caml_alloc(lcount, 0);
for (i = 0; i < lcount; i++) {
@ -285,9 +274,60 @@ CAMLprim value _cs_disasm(cs_arch arch, csh handle, const uint8_t * code, size_t
Store_field(rec_insn, 12, arch_info);
break;
case CS_ARCH_PPC:
arch_info = caml_alloc(1, 3);
op_info_val = caml_alloc(5, 0);
Store_field(op_info_val, 0, Val_int(insn[j-1].detail->ppc.bc));
Store_field(op_info_val, 1, Val_int(insn[j-1].detail->ppc.bh));
Store_field(op_info_val, 2, Val_bool(insn[j-1].detail->ppc.update_cr0));
lcount = insn[j-1].detail->ppc.op_count;
Store_field(op_info_val, 3, Val_int(lcount));
if (lcount > 0) {
array = caml_alloc(lcount, 0);
for (i = 0; i < lcount; i++) {
tmp2 = caml_alloc(1, 0);
switch(insn[j-1].detail->ppc.operands[i].type) {
case PPC_OP_REG:
tmp = caml_alloc(1, 1);
Store_field(tmp, 0, Val_int(insn[j-1].detail->ppc.operands[i].reg));
break;
case PPC_OP_IMM:
tmp = caml_alloc(1, 2);
Store_field(tmp, 0, Val_int(insn[j-1].detail->ppc.operands[i].imm));
break;
case PPC_OP_MEM:
tmp = caml_alloc(1, 3);
tmp3 = caml_alloc(2, 0);
Store_field(tmp3, 0, Val_int(insn[j-1].detail->ppc.operands[i].mem.base));
Store_field(tmp3, 1, Val_int(insn[j-1].detail->ppc.operands[i].mem.disp));
Store_field(tmp, 0, tmp3);
break;
default: break;
}
Store_field(tmp2, 0, tmp);
Store_field(array, i, tmp2);
}
} else // empty array
array = Atom(0);
Store_field(op_info_val, 4, array);
// finally, insert this into arch_info
Store_field(arch_info, 0, op_info_val);
Store_field(rec_insn, 12, arch_info);
break;
case CS_ARCH_X86:
arch_info = caml_alloc(1, 3);
arch_info = caml_alloc(1, 4);
op_info_val = caml_alloc(15, 0);
@ -334,8 +374,10 @@ CAMLprim value _cs_disasm(cs_arch arch, csh handle, const uint8_t * code, size_t
Store_field(op_info_val, 12, Val_int(insn[j-1].detail->x86.sib_base));
Store_field(op_info_val, 13, Val_int(insn[j-1].detail->x86.op_count));
lcount = x86_list_count(insn[j - 1].detail->x86.operands, ARR_SIZE(insn[j - 1].detail->x86.operands));
lcount = insn[j-1].detail->x86.op_count;
Store_field(op_info_val, 13, Val_int(lcount));
if (lcount > 0) {
array = caml_alloc(lcount, 0);
for (i = 0; i < lcount; i++) {
@ -413,6 +455,9 @@ CAMLprim value ocaml_cs_disasm_quick(value _arch, value _mode, value _code, valu
arch = CS_ARCH_MIPS;
break;
case 3:
arch = CS_ARCH_PPC;
break;
case 4:
arch = CS_ARCH_X86;
break;
default:
@ -518,6 +563,9 @@ CAMLprim value ocaml_cs_open(value _arch, value _mode)
arch = CS_ARCH_MIPS;
break;
case 3:
arch = CS_ARCH_PPC;
break;
case 4:
arch = CS_ARCH_X86;
break;
default:

654
bindings/ocaml/ppc.ml Normal file
View File

@ -0,0 +1,654 @@
(* Capstone Disassembler Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
type ppc_op_mem = {
base: int;
displ: int;
}
type ppc_op =
| PPC_OP_INVALID of int
| PPC_OP_REG of int
| PPC_OP_IMM of int
| PPC_OP_MEM of ppc_op_mem
type cs_ppc = {
bc: int;
bh: int;
update_cr0: bool;
op_count: int;
operands: ppc_op array;
}
(* PPC branch codes for some branch instructions *)
let _PPC_BC_LT = (0 lsl 5) lor 12;;
let _PPC_BC_LE = (1 lsl 5) lor 4;;
let _PPC_BC_EQ = (2 lsl 5) lor 12;;
let _PPC_BC_GE = (0 lsl 5) lor 4;;
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_LT_MINUS = (0 lsl 5) lor 14;;
let _PPC_BC_LE_MINUS = (1 lsl 5) lor 6;;
let _PPC_BC_EQ_MINUS = (2 lsl 5) lor 14;;
let _PPC_BC_GE_MINUS = (0 lsl 5) lor 6;;
let _PPC_BC_GT_MINUS = (1 lsl 5) lor 14;;
let _PPC_BC_NE_MINUS = (2 lsl 5) lor 6;;
let _PPC_BC_UN_MINUS = (3 lsl 5) lor 14;;
let _PPC_BC_NU_MINUS = (3 lsl 5) lor 6;;
let _PPC_BC_LT_PLUS = (0 lsl 5) lor 15;;
let _PPC_BC_LE_PLUS = (1 lsl 5) lor 7;;
let _PPC_BC_EQ_PLUS = (2 lsl 5) lor 15;;
let _PPC_BC_GE_PLUS = (0 lsl 5) lor 7;;
let _PPC_BC_GT_PLUS = (1 lsl 5) lor 15;;
let _PPC_BC_NE_PLUS = (2 lsl 5) lor 7;;
let _PPC_BC_UN_PLUS = (3 lsl 5) lor 15;;
let _PPC_BC_NU_PLUS = (3 lsl 5) lor 7;;
(* PPC branch hint for some branch instructions *)
let _PPC_BH_NO = 0;;
let _PPC_BH_PLUS = 1;;
let _PPC_BH_MINUS = 2;;
(* Operand type for instruction's operands *)
let _PPC_OP_INVALID = 0;;
let _PPC_OP_REG = 1;;
let _PPC_OP_IMM = 2;;
let _PPC_OP_MEM = 3;;
(* PPC registers *)
let _PPC_REG_INVALID = 0;;
let _PPC_REG_CARRY = 1;;
let _PPC_REG_CR0 = 2;;
let _PPC_REG_CR1 = 3;;
let _PPC_REG_CR2 = 4;;
let _PPC_REG_CR3 = 5;;
let _PPC_REG_CR4 = 6;;
let _PPC_REG_CR5 = 7;;
let _PPC_REG_CR6 = 8;;
let _PPC_REG_CR7 = 9;;
let _PPC_REG_CR8 = 10;;
let _PPC_REG_CR9 = 11;;
let _PPC_REG_CR10 = 12;;
let _PPC_REG_CR11 = 13;;
let _PPC_REG_CR12 = 14;;
let _PPC_REG_CR13 = 15;;
let _PPC_REG_CR14 = 16;;
let _PPC_REG_CR15 = 17;;
let _PPC_REG_CR16 = 18;;
let _PPC_REG_CR17 = 19;;
let _PPC_REG_CR18 = 20;;
let _PPC_REG_CR19 = 21;;
let _PPC_REG_CR20 = 22;;
let _PPC_REG_CR21 = 23;;
let _PPC_REG_CR22 = 24;;
let _PPC_REG_CR23 = 25;;
let _PPC_REG_CR24 = 26;;
let _PPC_REG_CR25 = 27;;
let _PPC_REG_CR26 = 28;;
let _PPC_REG_CR27 = 29;;
let _PPC_REG_CR28 = 30;;
let _PPC_REG_CR29 = 31;;
let _PPC_REG_CR30 = 32;;
let _PPC_REG_CR31 = 33;;
let _PPC_REG_CTR = 34;;
let _PPC_REG_F0 = 35;;
let _PPC_REG_F1 = 36;;
let _PPC_REG_F2 = 37;;
let _PPC_REG_F3 = 38;;
let _PPC_REG_F4 = 39;;
let _PPC_REG_F5 = 40;;
let _PPC_REG_F6 = 41;;
let _PPC_REG_F7 = 42;;
let _PPC_REG_F8 = 43;;
let _PPC_REG_F9 = 44;;
let _PPC_REG_F10 = 45;;
let _PPC_REG_F11 = 46;;
let _PPC_REG_F12 = 47;;
let _PPC_REG_F13 = 48;;
let _PPC_REG_F14 = 49;;
let _PPC_REG_F15 = 50;;
let _PPC_REG_F16 = 51;;
let _PPC_REG_F17 = 52;;
let _PPC_REG_F18 = 53;;
let _PPC_REG_F19 = 54;;
let _PPC_REG_F20 = 55;;
let _PPC_REG_F21 = 56;;
let _PPC_REG_F22 = 57;;
let _PPC_REG_F23 = 58;;
let _PPC_REG_F24 = 59;;
let _PPC_REG_F25 = 60;;
let _PPC_REG_F26 = 61;;
let _PPC_REG_F27 = 62;;
let _PPC_REG_F28 = 63;;
let _PPC_REG_F29 = 64;;
let _PPC_REG_F30 = 65;;
let _PPC_REG_F31 = 66;;
let _PPC_REG_LR = 67;;
let _PPC_REG_R0 = 68;;
let _PPC_REG_R1 = 69;;
let _PPC_REG_R2 = 70;;
let _PPC_REG_R3 = 71;;
let _PPC_REG_R4 = 72;;
let _PPC_REG_R5 = 73;;
let _PPC_REG_R6 = 74;;
let _PPC_REG_R7 = 75;;
let _PPC_REG_R8 = 76;;
let _PPC_REG_R9 = 77;;
let _PPC_REG_R10 = 78;;
let _PPC_REG_R11 = 79;;
let _PPC_REG_R12 = 80;;
let _PPC_REG_R13 = 81;;
let _PPC_REG_R14 = 82;;
let _PPC_REG_R15 = 83;;
let _PPC_REG_R16 = 84;;
let _PPC_REG_R17 = 85;;
let _PPC_REG_R18 = 86;;
let _PPC_REG_R19 = 87;;
let _PPC_REG_R20 = 88;;
let _PPC_REG_R21 = 89;;
let _PPC_REG_R22 = 90;;
let _PPC_REG_R23 = 91;;
let _PPC_REG_R24 = 92;;
let _PPC_REG_R25 = 93;;
let _PPC_REG_R26 = 94;;
let _PPC_REG_R27 = 95;;
let _PPC_REG_R28 = 96;;
let _PPC_REG_R29 = 97;;
let _PPC_REG_R30 = 98;;
let _PPC_REG_R31 = 99;;
let _PPC_REG_V0 = 100;;
let _PPC_REG_V1 = 101;;
let _PPC_REG_V2 = 102;;
let _PPC_REG_V3 = 103;;
let _PPC_REG_V4 = 104;;
let _PPC_REG_V5 = 105;;
let _PPC_REG_V6 = 106;;
let _PPC_REG_V7 = 107;;
let _PPC_REG_V8 = 108;;
let _PPC_REG_V9 = 109;;
let _PPC_REG_V10 = 110;;
let _PPC_REG_V11 = 111;;
let _PPC_REG_V12 = 112;;
let _PPC_REG_V13 = 113;;
let _PPC_REG_V14 = 114;;
let _PPC_REG_V15 = 115;;
let _PPC_REG_V16 = 116;;
let _PPC_REG_V17 = 117;;
let _PPC_REG_V18 = 118;;
let _PPC_REG_V19 = 119;;
let _PPC_REG_V20 = 120;;
let _PPC_REG_V21 = 121;;
let _PPC_REG_V22 = 122;;
let _PPC_REG_V23 = 123;;
let _PPC_REG_V24 = 124;;
let _PPC_REG_V25 = 125;;
let _PPC_REG_V26 = 126;;
let _PPC_REG_V27 = 127;;
let _PPC_REG_V28 = 128;;
let _PPC_REG_V29 = 129;;
let _PPC_REG_V30 = 130;;
let _PPC_REG_V31 = 131;;
let _PPC_REG_VRSAVE = 132;;
let _PPC_REG_RM = 133;;
let _PPC_REG_CTR8 = 134;;
let _PPC_REG_LR8 = 135;;
let _PPC_REG_CR1EQ = 136;;
let _PPC_REG_MAX = 137;;
(* PPC instruction *)
let _PPC_INS_INVALID = 0;;
let _PPC_INS_ADD = 1;;
let _PPC_INS_ADDC = 2;;
let _PPC_INS_ADDE = 3;;
let _PPC_INS_ADDI = 4;;
let _PPC_INS_ADDIC = 5;;
let _PPC_INS_ADDIS = 6;;
let _PPC_INS_ADDME = 7;;
let _PPC_INS_ADDZE = 8;;
let _PPC_INS_AND = 9;;
let _PPC_INS_ANDC = 10;;
let _PPC_INS_ANDIS = 11;;
let _PPC_INS_ANDI = 12;;
let _PPC_INS_B = 13;;
let _PPC_INS_BA = 14;;
let _PPC_INS_BCL = 15;;
let _PPC_INS_BCTR = 16;;
let _PPC_INS_BCTRL = 17;;
let _PPC_INS_BDNZ = 18;;
let _PPC_INS_BDNZA = 19;;
let _PPC_INS_BDNZL = 20;;
let _PPC_INS_BDNZLA = 21;;
let _PPC_INS_BDNZLR = 22;;
let _PPC_INS_BDNZLRL = 23;;
let _PPC_INS_BDZ = 24;;
let _PPC_INS_BDZA = 25;;
let _PPC_INS_BDZL = 26;;
let _PPC_INS_BDZLA = 27;;
let _PPC_INS_BDZLR = 28;;
let _PPC_INS_BDZLRL = 29;;
let _PPC_INS_BL = 30;;
let _PPC_INS_BLA = 31;;
let _PPC_INS_BLR = 32;;
let _PPC_INS_BLRL = 33;;
let _PPC_INS_CMPD = 34;;
let _PPC_INS_CMPDI = 35;;
let _PPC_INS_CMPLD = 36;;
let _PPC_INS_CMPLDI = 37;;
let _PPC_INS_CMPLW = 38;;
let _PPC_INS_CMPLWI = 39;;
let _PPC_INS_CMPW = 40;;
let _PPC_INS_CMPWI = 41;;
let _PPC_INS_CNTLZD = 42;;
let _PPC_INS_CNTLZW = 43;;
let _PPC_INS_CREQV = 44;;
let _PPC_INS_CRXOR = 45;;
let _PPC_INS_CRAND = 46;;
let _PPC_INS_CRANDC = 47;;
let _PPC_INS_CRNAND = 48;;
let _PPC_INS_CRNOR = 49;;
let _PPC_INS_CROR = 50;;
let _PPC_INS_CRORC = 51;;
let _PPC_INS_DCBA = 52;;
let _PPC_INS_DCBF = 53;;
let _PPC_INS_DCBI = 54;;
let _PPC_INS_DCBST = 55;;
let _PPC_INS_DCBT = 56;;
let _PPC_INS_DCBTST = 57;;
let _PPC_INS_DCBZ = 58;;
let _PPC_INS_DCBZL = 59;;
let _PPC_INS_DIVD = 60;;
let _PPC_INS_DIVDU = 61;;
let _PPC_INS_DIVW = 62;;
let _PPC_INS_DIVWU = 63;;
let _PPC_INS_DSS = 64;;
let _PPC_INS_DSSALL = 65;;
let _PPC_INS_DST = 66;;
let _PPC_INS_DSTST = 67;;
let _PPC_INS_DSTSTT = 68;;
let _PPC_INS_DSTT = 69;;
let _PPC_INS_EIEIO = 70;;
let _PPC_INS_EQV = 71;;
let _PPC_INS_EXTSB = 72;;
let _PPC_INS_EXTSH = 73;;
let _PPC_INS_EXTSW = 74;;
let _PPC_INS_FABS = 75;;
let _PPC_INS_FADD = 76;;
let _PPC_INS_FADDS = 77;;
let _PPC_INS_FCFID = 78;;
let _PPC_INS_FCFIDS = 79;;
let _PPC_INS_FCFIDU = 80;;
let _PPC_INS_FCFIDUS = 81;;
let _PPC_INS_FCMPU = 82;;
let _PPC_INS_FCPSGN = 83;;
let _PPC_INS_FCTID = 84;;
let _PPC_INS_FCTIDUZ = 85;;
let _PPC_INS_FCTIDZ = 86;;
let _PPC_INS_FCTIW = 87;;
let _PPC_INS_FCTIWUZ = 88;;
let _PPC_INS_FCTIWZ = 89;;
let _PPC_INS_FDIV = 90;;
let _PPC_INS_FDIVS = 91;;
let _PPC_INS_FMADD = 92;;
let _PPC_INS_FMADDS = 93;;
let _PPC_INS_FMR = 94;;
let _PPC_INS_FMSUB = 95;;
let _PPC_INS_FMSUBS = 96;;
let _PPC_INS_FMUL = 97;;
let _PPC_INS_FMULS = 98;;
let _PPC_INS_FNABS = 99;;
let _PPC_INS_FNEG = 100;;
let _PPC_INS_FNMADD = 101;;
let _PPC_INS_FNMADDS = 102;;
let _PPC_INS_FNMSUB = 103;;
let _PPC_INS_FNMSUBS = 104;;
let _PPC_INS_FRE = 105;;
let _PPC_INS_FRES = 106;;
let _PPC_INS_FRIM = 107;;
let _PPC_INS_FRIN = 108;;
let _PPC_INS_FRIP = 109;;
let _PPC_INS_FRIZ = 110;;
let _PPC_INS_FRSP = 111;;
let _PPC_INS_FRSQRTE = 112;;
let _PPC_INS_FRSQRTES = 113;;
let _PPC_INS_FSEL = 114;;
let _PPC_INS_FSQRT = 115;;
let _PPC_INS_FSQRTS = 116;;
let _PPC_INS_FSUB = 117;;
let _PPC_INS_FSUBS = 118;;
let _PPC_INS_ICBI = 119;;
let _PPC_INS_ISEL = 120;;
let _PPC_INS_ISYNC = 121;;
let _PPC_INS_LA = 122;;
let _PPC_INS_LBZ = 123;;
let _PPC_INS_LBZU = 124;;
let _PPC_INS_LBZUX = 125;;
let _PPC_INS_LBZX = 126;;
let _PPC_INS_LD = 127;;
let _PPC_INS_LDARX = 128;;
let _PPC_INS_LDBRX = 129;;
let _PPC_INS_LDU = 130;;
let _PPC_INS_LDUX = 131;;
let _PPC_INS_LDX = 132;;
let _PPC_INS_LFD = 133;;
let _PPC_INS_LFDU = 134;;
let _PPC_INS_LFDUX = 135;;
let _PPC_INS_LFDX = 136;;
let _PPC_INS_LFIWAX = 137;;
let _PPC_INS_LFIWZX = 138;;
let _PPC_INS_LFS = 139;;
let _PPC_INS_LFSU = 140;;
let _PPC_INS_LFSUX = 141;;
let _PPC_INS_LFSX = 142;;
let _PPC_INS_LHA = 143;;
let _PPC_INS_LHAU = 144;;
let _PPC_INS_LHAUX = 145;;
let _PPC_INS_LHAX = 146;;
let _PPC_INS_LHBRX = 147;;
let _PPC_INS_LHZ = 148;;
let _PPC_INS_LHZU = 149;;
let _PPC_INS_LHZUX = 150;;
let _PPC_INS_LHZX = 151;;
let _PPC_INS_LI = 152;;
let _PPC_INS_LIS = 153;;
let _PPC_INS_LMW = 154;;
let _PPC_INS_LVEBX = 155;;
let _PPC_INS_LVEHX = 156;;
let _PPC_INS_LVEWX = 157;;
let _PPC_INS_LVSL = 158;;
let _PPC_INS_LVSR = 159;;
let _PPC_INS_LVX = 160;;
let _PPC_INS_LVXL = 161;;
let _PPC_INS_LWA = 162;;
let _PPC_INS_LWARX = 163;;
let _PPC_INS_LWAUX = 164;;
let _PPC_INS_LWAX = 165;;
let _PPC_INS_LWBRX = 166;;
let _PPC_INS_LWZ = 167;;
let _PPC_INS_LWZU = 168;;
let _PPC_INS_LWZUX = 169;;
let _PPC_INS_LWZX = 170;;
let _PPC_INS_MCRF = 171;;
let _PPC_INS_MFCR = 172;;
let _PPC_INS_MFCTR = 173;;
let _PPC_INS_MFFS = 174;;
let _PPC_INS_MFLR = 175;;
let _PPC_INS_MFMSR = 176;;
let _PPC_INS_MFOCRF = 177;;
let _PPC_INS_MFSPR = 178;;
let _PPC_INS_MFTB = 179;;
let _PPC_INS_MFVSCR = 180;;
let _PPC_INS_MSYNC = 181;;
let _PPC_INS_MTCRF = 182;;
let _PPC_INS_MTCTR = 183;;
let _PPC_INS_MTFSB0 = 184;;
let _PPC_INS_MTFSB1 = 185;;
let _PPC_INS_MTFSF = 186;;
let _PPC_INS_MTLR = 187;;
let _PPC_INS_MTMSR = 188;;
let _PPC_INS_MTMSRD = 189;;
let _PPC_INS_MTOCRF = 190;;
let _PPC_INS_MTSPR = 191;;
let _PPC_INS_MTVSCR = 192;;
let _PPC_INS_MULHD = 193;;
let _PPC_INS_MULHDU = 194;;
let _PPC_INS_MULHW = 195;;
let _PPC_INS_MULHWU = 196;;
let _PPC_INS_MULLD = 197;;
let _PPC_INS_MULLI = 198;;
let _PPC_INS_MULLW = 199;;
let _PPC_INS_NAND = 200;;
let _PPC_INS_NEG = 201;;
let _PPC_INS_NOP = 202;;
let _PPC_INS_ORI = 203;;
let _PPC_INS_NOR = 204;;
let _PPC_INS_OR = 205;;
let _PPC_INS_ORC = 206;;
let _PPC_INS_ORIS = 207;;
let _PPC_INS_POPCNTD = 208;;
let _PPC_INS_POPCNTW = 209;;
let _PPC_INS_RLDCL = 210;;
let _PPC_INS_RLDCR = 211;;
let _PPC_INS_RLDIC = 212;;
let _PPC_INS_RLDICL = 213;;
let _PPC_INS_RLDICR = 214;;
let _PPC_INS_RLDIMI = 215;;
let _PPC_INS_RLWIMI = 216;;
let _PPC_INS_RLWINM = 217;;
let _PPC_INS_RLWNM = 218;;
let _PPC_INS_SC = 219;;
let _PPC_INS_SLBIA = 220;;
let _PPC_INS_SLBIE = 221;;
let _PPC_INS_SLBMFEE = 222;;
let _PPC_INS_SLBMTE = 223;;
let _PPC_INS_SLD = 224;;
let _PPC_INS_SLW = 225;;
let _PPC_INS_SRAD = 226;;
let _PPC_INS_SRADI = 227;;
let _PPC_INS_SRAW = 228;;
let _PPC_INS_SRAWI = 229;;
let _PPC_INS_SRD = 230;;
let _PPC_INS_SRW = 231;;
let _PPC_INS_STB = 232;;
let _PPC_INS_STBU = 233;;
let _PPC_INS_STBUX = 234;;
let _PPC_INS_STBX = 235;;
let _PPC_INS_STD = 236;;
let _PPC_INS_STDBRX = 237;;
let _PPC_INS_STDCX = 238;;
let _PPC_INS_STDU = 239;;
let _PPC_INS_STDUX = 240;;
let _PPC_INS_STDX = 241;;
let _PPC_INS_STFD = 242;;
let _PPC_INS_STFDU = 243;;
let _PPC_INS_STFDUX = 244;;
let _PPC_INS_STFDX = 245;;
let _PPC_INS_STFIWX = 246;;
let _PPC_INS_STFS = 247;;
let _PPC_INS_STFSU = 248;;
let _PPC_INS_STFSUX = 249;;
let _PPC_INS_STFSX = 250;;
let _PPC_INS_STH = 251;;
let _PPC_INS_STHBRX = 252;;
let _PPC_INS_STHU = 253;;
let _PPC_INS_STHUX = 254;;
let _PPC_INS_STHX = 255;;
let _PPC_INS_STMW = 256;;
let _PPC_INS_STVEBX = 257;;
let _PPC_INS_STVEHX = 258;;
let _PPC_INS_STVEWX = 259;;
let _PPC_INS_STVX = 260;;
let _PPC_INS_STVXL = 261;;
let _PPC_INS_STW = 262;;
let _PPC_INS_STWBRX = 263;;
let _PPC_INS_STWCX = 264;;
let _PPC_INS_STWU = 265;;
let _PPC_INS_STWUX = 266;;
let _PPC_INS_STWX = 267;;
let _PPC_INS_SUBF = 268;;
let _PPC_INS_SUBFC = 269;;
let _PPC_INS_SUBFE = 270;;
let _PPC_INS_SUBFIC = 271;;
let _PPC_INS_SUBFME = 272;;
let _PPC_INS_SUBFZE = 273;;
let _PPC_INS_SYNC = 274;;
let _PPC_INS_TD = 275;;
let _PPC_INS_TDI = 276;;
let _PPC_INS_TLBIE = 277;;
let _PPC_INS_TLBIEL = 278;;
let _PPC_INS_TLBSYNC = 279;;
let _PPC_INS_TRAP = 280;;
let _PPC_INS_TW = 281;;
let _PPC_INS_TWI = 282;;
let _PPC_INS_VADDCUW = 283;;
let _PPC_INS_VADDFP = 284;;
let _PPC_INS_VADDSBS = 285;;
let _PPC_INS_VADDSHS = 286;;
let _PPC_INS_VADDSWS = 287;;
let _PPC_INS_VADDUBM = 288;;
let _PPC_INS_VADDUBS = 289;;
let _PPC_INS_VADDUHM = 290;;
let _PPC_INS_VADDUHS = 291;;
let _PPC_INS_VADDUWM = 292;;
let _PPC_INS_VADDUWS = 293;;
let _PPC_INS_VAND = 294;;
let _PPC_INS_VANDC = 295;;
let _PPC_INS_VAVGSB = 296;;
let _PPC_INS_VAVGSH = 297;;
let _PPC_INS_VAVGSW = 298;;
let _PPC_INS_VAVGUB = 299;;
let _PPC_INS_VAVGUH = 300;;
let _PPC_INS_VAVGUW = 301;;
let _PPC_INS_VCFSX = 302;;
let _PPC_INS_VCFUX = 303;;
let _PPC_INS_VCMPBFP = 304;;
let _PPC_INS_VCMPEQFP = 305;;
let _PPC_INS_VCMPEQUB = 306;;
let _PPC_INS_VCMPEQUH = 307;;
let _PPC_INS_VCMPEQUW = 308;;
let _PPC_INS_VCMPGEFP = 309;;
let _PPC_INS_VCMPGTFP = 310;;
let _PPC_INS_VCMPGTSB = 311;;
let _PPC_INS_VCMPGTSH = 312;;
let _PPC_INS_VCMPGTSW = 313;;
let _PPC_INS_VCMPGTUB = 314;;
let _PPC_INS_VCMPGTUH = 315;;
let _PPC_INS_VCMPGTUW = 316;;
let _PPC_INS_VCTSXS = 317;;
let _PPC_INS_VCTUXS = 318;;
let _PPC_INS_VEXPTEFP = 319;;
let _PPC_INS_VLOGEFP = 320;;
let _PPC_INS_VMADDFP = 321;;
let _PPC_INS_VMAXFP = 322;;
let _PPC_INS_VMAXSB = 323;;
let _PPC_INS_VMAXSH = 324;;
let _PPC_INS_VMAXSW = 325;;
let _PPC_INS_VMAXUB = 326;;
let _PPC_INS_VMAXUH = 327;;
let _PPC_INS_VMAXUW = 328;;
let _PPC_INS_VMHADDSHS = 329;;
let _PPC_INS_VMHRADDSHS = 330;;
let _PPC_INS_VMINFP = 331;;
let _PPC_INS_VMINSB = 332;;
let _PPC_INS_VMINSH = 333;;
let _PPC_INS_VMINSW = 334;;
let _PPC_INS_VMINUB = 335;;
let _PPC_INS_VMINUH = 336;;
let _PPC_INS_VMINUW = 337;;
let _PPC_INS_VMLADDUHM = 338;;
let _PPC_INS_VMRGHB = 339;;
let _PPC_INS_VMRGHH = 340;;
let _PPC_INS_VMRGHW = 341;;
let _PPC_INS_VMRGLB = 342;;
let _PPC_INS_VMRGLH = 343;;
let _PPC_INS_VMRGLW = 344;;
let _PPC_INS_VMSUMMBM = 345;;
let _PPC_INS_VMSUMSHM = 346;;
let _PPC_INS_VMSUMSHS = 347;;
let _PPC_INS_VMSUMUBM = 348;;
let _PPC_INS_VMSUMUHM = 349;;
let _PPC_INS_VMSUMUHS = 350;;
let _PPC_INS_VMULESB = 351;;
let _PPC_INS_VMULESH = 352;;
let _PPC_INS_VMULEUB = 353;;
let _PPC_INS_VMULEUH = 354;;
let _PPC_INS_VMULOSB = 355;;
let _PPC_INS_VMULOSH = 356;;
let _PPC_INS_VMULOUB = 357;;
let _PPC_INS_VMULOUH = 358;;
let _PPC_INS_VNMSUBFP = 359;;
let _PPC_INS_VNOR = 360;;
let _PPC_INS_VOR = 361;;
let _PPC_INS_VPERM = 362;;
let _PPC_INS_VPKPX = 363;;
let _PPC_INS_VPKSHSS = 364;;
let _PPC_INS_VPKSHUS = 365;;
let _PPC_INS_VPKSWSS = 366;;
let _PPC_INS_VPKSWUS = 367;;
let _PPC_INS_VPKUHUM = 368;;
let _PPC_INS_VPKUHUS = 369;;
let _PPC_INS_VPKUWUM = 370;;
let _PPC_INS_VPKUWUS = 371;;
let _PPC_INS_VREFP = 372;;
let _PPC_INS_VRFIM = 373;;
let _PPC_INS_VRFIN = 374;;
let _PPC_INS_VRFIP = 375;;
let _PPC_INS_VRFIZ = 376;;
let _PPC_INS_VRLB = 377;;
let _PPC_INS_VRLH = 378;;
let _PPC_INS_VRLW = 379;;
let _PPC_INS_VRSQRTEFP = 380;;
let _PPC_INS_VSEL = 381;;
let _PPC_INS_VSL = 382;;
let _PPC_INS_VSLB = 383;;
let _PPC_INS_VSLDOI = 384;;
let _PPC_INS_VSLH = 385;;
let _PPC_INS_VSLO = 386;;
let _PPC_INS_VSLW = 387;;
let _PPC_INS_VSPLTB = 388;;
let _PPC_INS_VSPLTH = 389;;
let _PPC_INS_VSPLTISB = 390;;
let _PPC_INS_VSPLTISH = 391;;
let _PPC_INS_VSPLTISW = 392;;
let _PPC_INS_VSPLTW = 393;;
let _PPC_INS_VSR = 394;;
let _PPC_INS_VSRAB = 395;;
let _PPC_INS_VSRAH = 396;;
let _PPC_INS_VSRAW = 397;;
let _PPC_INS_VSRB = 398;;
let _PPC_INS_VSRH = 399;;
let _PPC_INS_VSRO = 400;;
let _PPC_INS_VSRW = 401;;
let _PPC_INS_VSUBCUW = 402;;
let _PPC_INS_VSUBFP = 403;;
let _PPC_INS_VSUBSBS = 404;;
let _PPC_INS_VSUBSHS = 405;;
let _PPC_INS_VSUBSWS = 406;;
let _PPC_INS_VSUBUBM = 407;;
let _PPC_INS_VSUBUBS = 408;;
let _PPC_INS_VSUBUHM = 409;;
let _PPC_INS_VSUBUHS = 410;;
let _PPC_INS_VSUBUWM = 411;;
let _PPC_INS_VSUBUWS = 412;;
let _PPC_INS_VSUM2SWS = 413;;
let _PPC_INS_VSUM4SBS = 414;;
let _PPC_INS_VSUM4SHS = 415;;
let _PPC_INS_VSUM4UBS = 416;;
let _PPC_INS_VSUMSWS = 417;;
let _PPC_INS_VUPKHPX = 418;;
let _PPC_INS_VUPKHSB = 419;;
let _PPC_INS_VUPKHSH = 420;;
let _PPC_INS_VUPKLPX = 421;;
let _PPC_INS_VUPKLSB = 422;;
let _PPC_INS_VUPKLSH = 423;;
let _PPC_INS_VXOR = 424;;
let _PPC_INS_WAIT = 425;;
let _PPC_INS_XOR = 426;;
let _PPC_INS_XORI = 427;;
let _PPC_INS_XORIS = 428;;
let _PPC_INS_BC = 429;;
let _PPC_INS_BCA = 430;;
let _PPC_INS_BCCTR = 431;;
let _PPC_INS_BCCTRL = 432;;
let _PPC_INS_BCLA = 433;;
let _PPC_INS_BCLR = 434;;
let _PPC_INS_BCLRL = 435;;
let _PPC_INS_MAX = 436;;
(* Group of PPC instructions *)
let _PPC_GRP_INVALID = 0;;
let _PPC_GRP_ALTIVEC = 1;;
let _PPC_GRP_MODE32 = 2;;
let _PPC_GRP_MODE64 = 3;;
let _PPC_GRP_BOOKE = 4;;
let _PPC_GRP_NOTBOOKE = 5;;
let _PPC_GRP_JUMP = 6;;
let _PPC_GRP_MAX = 7;;

View File

@ -59,6 +59,7 @@ let print_detail csh arch =
| CS_INFO_ARM64 _ -> ();
| CS_INFO_X86 _ -> ();
| CS_INFO_MIPS _ -> ();
| CS_INFO_PPC _ -> ();
| CS_INFO_ARM arm ->
if arm.cc != _ARM_CC_AL && arm.cc != _ARM_CC_INVALID then
printf "\tCode condition: %u\n" arm.cc;

View File

@ -50,6 +50,7 @@ let print_detail csh arch =
match arch with
| CS_INFO_ARM _ -> ();
| CS_INFO_MIPS _ -> ();
| CS_INFO_PPC _ -> ();
| CS_INFO_X86 _ -> ();
| CS_INFO_ARM64 arm64 ->
if arm64.cc != _ARM64_CC_AL && arm64.cc != _ARM64_CC_INVALID then

View File

@ -15,6 +15,7 @@ let _THUMB_CODE2 = "\x4f\xf0\x00\x01\xbd\xe8\x00\x88";;
let _MIPS_CODE = "\x0C\x10\x00\x97\x00\x00\x00\x00\x24\x02\x00\x0c\x8f\xa2\x00\x00\x34\x21\x34\x56";;
let _MIPS_CODE2 = "\x56\x34\x21\x34\xc2\x17\x01\x00";;
let _ARM64_CODE = "\x21\x7c\x02\x9b\x21\x7c\x00\x53\x00\x40\x21\x4b\xe1\x0b\x40\xb9";;
let _PPC_CODE = "\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";;
let all_tests = [
(CS_ARCH_X86, [CS_MODE_16], _X86_CODE16, "X86 16bit (Intel syntax)");
@ -28,6 +29,8 @@ let all_tests = [
(CS_ARCH_ARM64, [CS_MODE_ARM], _ARM64_CODE, "ARM-64");
(CS_ARCH_MIPS, [CS_MODE_32; CS_MODE_BIG_ENDIAN], _MIPS_CODE, "MIPS-32 (Big-endian)");
(CS_ARCH_MIPS, [CS_MODE_64; CS_MODE_LITTLE_ENDIAN], _MIPS_CODE2, "MIPS-64-EL (Little-endian)");
(CS_ARCH_PPC, [CS_MODE_32; CS_MODE_BIG_ENDIAN], _PPC_CODE, "PPC-64");
];;

View File

@ -42,6 +42,7 @@ let print_detail csh arch =
match arch with
| CS_INFO_ARM _ -> ();
| CS_INFO_ARM64 _ -> ();
| CS_INFO_PPC _ -> ();
| CS_INFO_X86 _ -> ();
| CS_INFO_MIPS mips ->

View File

@ -0,0 +1,91 @@
(* Capstone Disassembler Engine
* By Guillaume Jeanne <guillaume.jeanne@ensimag.fr>, 2014> *)
open Printf
open Capstone
open Ppc
let print_string_hex comment str =
printf "%s" comment;
for i = 0 to (Array.length str - 1) do
printf "0x%02x " str.(i)
done;
printf "\n"
let _PPC_CODE = "\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";;
let all_tests = [
(CS_ARCH_PPC, [CS_MODE_32; CS_MODE_BIG_ENDIAN], _PPC_CODE, "PPC-64");
];;
let print_op csh i op =
( match op with
| PPC_OP_INVALID _ -> (); (* this would never happens *)
| PPC_OP_REG reg -> printf "\t\top[%d]: REG = %s\n" i (cs_reg_name csh reg);
| PPC_OP_IMM imm -> printf "\t\top[%d]: IMM = 0x%x\n" i imm;
| PPC_OP_MEM mem -> ( printf "\t\top[%d]: MEM\n" i;
if mem.base != 0 then
printf "\t\t\toperands[%u].mem.base: REG = %s\n" i (cs_reg_name csh mem.base);
if mem.displ != 0 then
printf "\t\t\toperands[%u].mem.disp: 0x%x\n" i mem.displ;
);
);
();;
let print_detail csh arch =
match arch with
| CS_INFO_ARM _ -> ();
| CS_INFO_ARM64 _ -> ();
| CS_INFO_MIPS _ -> ();
| CS_INFO_X86 _ -> ();
| CS_INFO_PPC ppc ->
(* print all operands info (type & value) *)
if (Array.length ppc.operands) > 0 then (
printf "\top_count: %d\n" (Array.length ppc.operands);
Array.iteri (print_op csh) ppc.operands;
);
printf "\n";;
let print_insn mode insn =
printf "0x%x\t%s\t%s\n" insn.address insn.mnemonic insn.op_str;
let csh = cs_open CS_ARCH_MIPS mode in
match csh with
| None -> ()
| Some v -> print_detail v insn.arch
let print_arch x =
let (arch, mode, code, comment) = x in
let insns = cs_disasm_quick arch mode code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn mode) insns;;
List.iter print_arch all_tests;;
(* all below code use OO class of Capstone *)
let print_insn_cls csh insn =
printf "0x%x\t%s\t%s\n" insn#address insn#mnemonic insn#op_str;
print_detail csh insn#arch;;
let print_arch_cls x =
let (arch, mode, code, comment) = x in (
let d = new cs arch mode in
let insns = d#disasm code 0x1000L 0L in
printf "*************\n";
printf "Platform: %s\n" comment;
List.iter (print_insn_cls d#get_csh) insns;
);;
List.iter print_arch_cls all_tests;;

View File

@ -51,6 +51,7 @@ let print_detail mode csh arch =
| CS_INFO_ARM64 _ -> ();
| CS_INFO_ARM _ -> ();
| CS_INFO_MIPS _ -> ();
| CS_INFO_PPC _ -> ();
| CS_INFO_X86 x86 ->
print_string_hex "\tPrefix: " x86.prefix;

File diff suppressed because it is too large Load Diff

22
make.sh
View File

@ -9,19 +9,24 @@
# build iOS lib for all iDevices, or only specific device
function build_iOS {
${MAKE} clean
SDK=`xcrun --sdk iphoneos --show-sdk-path`
GCC_BIN=`xcrun --sdk iphoneos -f gcc`
GCC_BASE="$GCC_BIN -Os -Wimplicit -isysroot $SDK"
IOS_SDK=`xcrun --sdk iphoneos --show-sdk-path`
IOS_CC=`xcrun --sdk iphoneos -f clang`
IOS_CFLAGS="-Os -Wimplicit -isysroot $IOS_SDK"
IOS_LDFLAGS="-isysroot $IOS_SDK"
if (( $# == 0 )); then
# build for all iDevices
GCC="$GCC_BASE -arch armv7 -arch armv7s -arch arm64"
IOS_ARCHS="armv7 armv7s arm64"
else
GCC="$GCC_BASE -arch $1"
IOS_ARCHS="$1"
fi
${MAKE} CC="$GCC"
CC="$IOS_CC" CFLAGS="$IOS_CFLAGS" LDFLAGS="$IOS_LDFLAGS" LIBARCHS="$IOS_ARCHS" ${MAKE}
}
function build {
if [ $(uname -s) = Darwin ]; then
export LIBARCHS="i386 x86_64"
fi
${MAKE} clean
if [ ${CC}x != x ]; then
@ -34,6 +39,11 @@ function build {
function install {
# Mac OSX needs to find the right directory for pkgconfig
if [ "$(uname)" == "Darwin" ]; then
# we are going to install into /usr/local, so remove old installs under /usr
rm -rf /usr/lib/libcapstone.*
rm -rf /usr/include/capstone
# install into /usr/local
export PREFIX=/usr/local
# find the directory automatically, so we can support both Macport & Brew
PKGCFGDIR="$(pkg-config --variable pc_path pkg-config | cut -d ':' -f 1)"
# set PKGCFGDIR only in non-Brew environment & pkg-config is available

View File

@ -28,6 +28,9 @@ endif
CFLAGS += -O3 -Wall -I$(INCDIR)
LDFLAGS += -L$(LIBDIR)
CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
LIBNAME = capstone
BIN_EXT =
@ -128,12 +131,12 @@ endif
define link-dynamic
${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall -l$(LIBNAME) -o $@
$(CC) $(LDFLAGS) $< -l$(LIBNAME) -o $@
endef
define link-static
${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall $(ARCHIVE) -o $(call staticname,$@)
$(CC) $(LDFLAGS) $< $(ARCHIVE) -o $(call staticname,$@)
endef