Skip to content

Commit

Permalink
Update OCaml bindings with RADIX16 option
Browse files Browse the repository at this point in the history
  • Loading branch information
aziem committed Sep 14, 2016
1 parent 43899e8 commit 792935b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bindings/ocaml/ffi_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,23 @@ module Types (F: Cstubs.Types.TYPE) =
| KS_OPT_SYNTAX_NASM
| KS_OPT_SYNTAX_MASM
| KS_OPT_SYNTAX_GAS
| KS_OPT_SYNTAX_RADIX16


let ks_opt_syntax_intel = constant "KS_OPT_SYNTAX_INTEL" int64_t
let ks_opt_syntax_att = constant "KS_OPT_SYNTAX_ATT" int64_t
let ks_opt_syntax_nasm = constant "KS_OPT_SYNTAX_NASM" int64_t
let ks_opt_syntax_masm = constant "KS_OPT_SYNTAX_MASM" int64_t
let ks_opt_syntax_gas = constant "KS_OPT_SYNTAX_GAS" int64_t
let ks_opt_syntax_radix16 = constant "KS_OPT_SYNTAX_RADIX16" int64_t

let ks_opt_value = enum "ks_opt_value" [
KS_OPT_SYNTAX_INTEL, ks_opt_syntax_intel;
KS_OPT_SYNTAX_ATT, ks_opt_syntax_att;
KS_OPT_SYNTAX_NASM, ks_opt_syntax_nasm;
KS_OPT_SYNTAX_MASM, ks_opt_syntax_masm;
KS_OPT_SYNTAX_GAS, ks_opt_syntax_gas;
KS_OPT_SYNTAX_RADIX16, ks_opt_syntax_radix16
]


Expand Down
1 change: 1 addition & 0 deletions bindings/ocaml/keystone.mli
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ module Types : sig
| KS_OPT_SYNTAX_NASM
| KS_OPT_SYNTAX_MASM
| KS_OPT_SYNTAX_GAS
| KS_OPT_SYNTAX_RADIX16

type ks_mode =
| KS_MODE_ARM
Expand Down
7 changes: 5 additions & 2 deletions bindings/ocaml/test_bindings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ open Keystone
module T = Keystone.Types

let test_ks arch mode ?(syntax=T.KS_OPT_SYNTAX_INTEL) ?(endian=T.KS_MODE_LITTLE_ENDIAN) asm =
Printf.printf "ASSEMBLING %s\n" asm; flush stdout;
match (ks_open arch ~endian:endian mode) with
| Result.Ok engine ->
begin
Expand All @@ -16,7 +17,8 @@ let test_ks arch mode ?(syntax=T.KS_OPT_SYNTAX_INTEL) ?(endian=T.KS_MODE_LITTLE_
result.stat_count;
ignore(ks_close engine)

| Result.Error s -> Printf.printf "ERROR: failed on ks_asm with: %s\n" s
| Result.Error s -> ignore (ks_close engine);
Printf.printf "ERROR: failed on ks_asm with: %s\n" s
end

| Result.Error e -> Printf.printf "ERROR: failed on ks_open: %s\n" e
Expand All @@ -28,6 +30,7 @@ let _ =
test_ks T.KS_ARCH_X86 T.KS_MODE_64 "add rax, rcx";
test_ks T.KS_ARCH_X86 T.KS_MODE_32 ~syntax:T.KS_OPT_SYNTAX_ATT "add %ecx, %eax";
test_ks T.KS_ARCH_X86 T.KS_MODE_64 ~syntax:T.KS_OPT_SYNTAX_ATT "add %rcx, %rax";
test_ks T.KS_ARCH_X86 T.KS_MODE_32 ~syntax:T.KS_OPT_SYNTAX_RADIX16 "add eax, 0x15";

test_ks T.KS_ARCH_ARM T.KS_MODE_ARM "sub r1, r2, r5";
test_ks T.KS_ARCH_ARM T.KS_MODE_ARM "sub r1, r2, r5";
Expand All @@ -52,4 +55,4 @@ let _ =
test_ks T.KS_ARCH_SPARC T.KS_MODE_SPARC32 "add %g1, %g2, %g3";
test_ks T.KS_ARCH_SPARC T.KS_MODE_SPARC32 ~endian:T.KS_MODE_BIG_ENDIAN "add %g1, %g2, %g3";

test_ks T.KS_ARCH_SYSTEMZ T.KS_MODE_BIG_ENDIAN "a %r0, 4092(%r15, %r1)"
test_ks T.KS_ARCH_SYSTEMZ T.KS_MODE_BIG_ENDIAN "a %r0, 4095(%r15, %r1)"

0 comments on commit 792935b

Please sign in to comment.