Skip to content

Commit

Permalink
java/ocaml/python: add the missing generic instruction operand types
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Oct 31, 2014
1 parent b0464ef commit 69271dd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bindings/java/capstone/Capstone.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,14 @@ public NativeLong cs_disasm(NativeLong handle, byte[] code, NativeLong code_len,
public static final int CS_OPT_ON = 3; // Turn ON an option (CS_OPT_DETAIL)
public static final int CS_OPT_SYNTAX_NOREGNAME = 3; // PPC asm syntax: Prints register name with only number (CS_OPT_SYNTAX)

// query id for cs_support()
// Common instruction operand types - to be consistent across all architectures.
public static final int CS_OP_INVALID = 0;
public static final int CS_OP_REG = 1;
public static final int CS_OP_IMM = 2;
public static final int CS_OP_MEM = 3;
public static final int CS_OP_FP = 4;

// Query id for cs_support()
public static final int CS_SUPPORT_DIET = CS_ARCH_ALL+1; // diet mode

protected class NativeStruct {
Expand Down
10 changes: 10 additions & 0 deletions bindings/ocaml/capstone.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ open Systemz
open Xcore
open Printf (* debug *)

(* Hardware architectures *)
type arch =
| CS_ARCH_ARM
| CS_ARCH_ARM64
Expand All @@ -21,6 +22,7 @@ type arch =
| CS_ARCH_SYSZ
| CS_ARCH_XCORE

(* Hardware modes *)
type mode =
| CS_MODE_LITTLE_ENDIAN (* little-endian mode (default mode) *)
| CS_MODE_ARM (* ARM mode *)
Expand All @@ -37,6 +39,7 @@ type mode =
| CS_MODE_BIG_ENDIAN (* big-endian mode *)


(* Runtime option for the disassembled engine *)
type opt_type =
| CS_OPT_SYNTAX (* Asssembly output syntax *)
| CS_OPT_DETAIL (* Break down instruction structure into details *)
Expand All @@ -46,13 +49,20 @@ type opt_type =
| CS_OPT_SKIPDATA_SETUP (* Setup user-defined function for SKIPDATA option *)


(* Runtime option value (associated with option type above) *)
let _CS_OPT_OFF = 0L;; (* Turn OFF an option - default option of CS_OPT_DETAIL, CS_OPT_SKIPDATA. *)
let _CS_OPT_ON = 3L;; (* Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA). *)
let _CS_OPT_SYNTAX_DEFAULT = 0L;; (* Default asm syntax (CS_OPT_SYNTAX). *)
let _CS_OPT_SYNTAX_INTEL = 1L;; (* X86 Intel asm syntax - default on X86 (CS_OPT_SYNTAX). *)
let _CS_OPT_SYNTAX_ATT = 2L;; (* X86 ATT asm syntax (CS_OPT_SYNTAX). *)
let _CS_OPT_SYNTAX_NOREGNAME = 3L;; (* Prints register name with only number (CS_OPT_SYNTAX) *)

(* Common instruction operand types - to be consistent across all architectures. *)
let _CS_OP_INVALID = 0;; (* uninitialized/invalid operand. *)
let _CS_OP_REG = 1;; (* Register operand. *)
let _CS_OP_IMM = 2;; (* Immediate operand. *)
let _CS_OP_MEM = 3;; (* Memory operand. *)
let _CS_OP_FP = 4;; (* Floating-Point operand. *)

type cs_arch =
| CS_INFO_ARM of cs_arm
Expand Down
7 changes: 7 additions & 0 deletions bindings/python/capstone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@
CS_OPT_OFF = 0 # Turn OFF an option - default option of CS_OPT_DETAIL
CS_OPT_ON = 3 # Turn ON an option (CS_OPT_DETAIL)

# Common instruction operand types - to be consistent across all architectures.
CS_OP_INVALID = 0
CS_OP_REG = 1
CS_OP_IMM = 2
CS_OP_MEM = 3
CS_OP_FP = 4

# Capstone syntax value
CS_OPT_SYNTAX_DEFAULT = 0 # Default assembly syntax of all platforms (CS_OPT_SYNTAX)
CS_OPT_SYNTAX_INTEL = 1 # Intel X86 asm syntax - default syntax on X86 (CS_OPT_SYNTAX, CS_ARCH_X86)
Expand Down

0 comments on commit 69271dd

Please sign in to comment.