crabstone 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES.md +61 -0
- data/LICENSE +25 -0
- data/MANIFEST +312 -0
- data/README.md +103 -0
- data/Rakefile +27 -0
- data/bin/genconst +66 -0
- data/bin/genreg +99 -0
- data/crabstone.gemspec +27 -0
- data/examples/hello_world.rb +43 -0
- data/lib/arch/arm.rb +128 -0
- data/lib/arch/arm64.rb +167 -0
- data/lib/arch/arm64_const.rb +1055 -0
- data/lib/arch/arm64_registers.rb +295 -0
- data/lib/arch/arm_const.rb +777 -0
- data/lib/arch/arm_registers.rb +149 -0
- data/lib/arch/mips.rb +78 -0
- data/lib/arch/mips_const.rb +850 -0
- data/lib/arch/mips_registers.rb +208 -0
- data/lib/arch/ppc.rb +90 -0
- data/lib/arch/ppc_const.rb +1181 -0
- data/lib/arch/ppc_registers.rb +209 -0
- data/lib/arch/sparc.rb +79 -0
- data/lib/arch/sparc_const.rb +461 -0
- data/lib/arch/sparc_registers.rb +121 -0
- data/lib/arch/systemz.rb +79 -0
- data/lib/arch/sysz_const.rb +779 -0
- data/lib/arch/sysz_registers.rb +66 -0
- data/lib/arch/x86.rb +107 -0
- data/lib/arch/x86_const.rb +1698 -0
- data/lib/arch/x86_registers.rb +265 -0
- data/lib/arch/xcore.rb +78 -0
- data/lib/arch/xcore_const.rb +185 -0
- data/lib/arch/xcore_registers.rb +57 -0
- data/lib/crabstone.rb +564 -0
- data/test/MC/AArch64/basic-a64-instructions.s.cs +2014 -0
- data/test/MC/AArch64/gicv3-regs.s.cs +111 -0
- data/test/MC/AArch64/neon-2velem.s.cs +113 -0
- data/test/MC/AArch64/neon-3vdiff.s.cs +143 -0
- data/test/MC/AArch64/neon-aba-abd.s.cs +28 -0
- data/test/MC/AArch64/neon-across.s.cs +40 -0
- data/test/MC/AArch64/neon-add-pairwise.s.cs +11 -0
- data/test/MC/AArch64/neon-add-sub-instructions.s.cs +21 -0
- data/test/MC/AArch64/neon-bitwise-instructions.s.cs +17 -0
- data/test/MC/AArch64/neon-compare-instructions.s.cs +136 -0
- data/test/MC/AArch64/neon-crypto.s.cs +15 -0
- data/test/MC/AArch64/neon-extract.s.cs +3 -0
- data/test/MC/AArch64/neon-facge-facgt.s.cs +13 -0
- data/test/MC/AArch64/neon-frsqrt-frecp.s.cs +7 -0
- data/test/MC/AArch64/neon-halving-add-sub.s.cs +25 -0
- data/test/MC/AArch64/neon-max-min-pairwise.s.cs +37 -0
- data/test/MC/AArch64/neon-max-min.s.cs +37 -0
- data/test/MC/AArch64/neon-mla-mls-instructions.s.cs +19 -0
- data/test/MC/AArch64/neon-mov.s.cs +74 -0
- data/test/MC/AArch64/neon-mul-div-instructions.s.cs +24 -0
- data/test/MC/AArch64/neon-perm.s.cs +43 -0
- data/test/MC/AArch64/neon-rounding-halving-add.s.cs +13 -0
- data/test/MC/AArch64/neon-rounding-shift.s.cs +15 -0
- data/test/MC/AArch64/neon-saturating-add-sub.s.cs +29 -0
- data/test/MC/AArch64/neon-saturating-rounding-shift.s.cs +15 -0
- data/test/MC/AArch64/neon-saturating-shift.s.cs +15 -0
- data/test/MC/AArch64/neon-scalar-abs.s.cs +8 -0
- data/test/MC/AArch64/neon-scalar-add-sub.s.cs +3 -0
- data/test/MC/AArch64/neon-scalar-by-elem-mla.s.cs +13 -0
- data/test/MC/AArch64/neon-scalar-by-elem-mul.s.cs +13 -0
- data/test/MC/AArch64/neon-scalar-by-elem-saturating-mla.s.cs +15 -0
- data/test/MC/AArch64/neon-scalar-by-elem-saturating-mul.s.cs +18 -0
- data/test/MC/AArch64/neon-scalar-compare.s.cs +12 -0
- data/test/MC/AArch64/neon-scalar-cvt.s.cs +34 -0
- data/test/MC/AArch64/neon-scalar-dup.s.cs +23 -0
- data/test/MC/AArch64/neon-scalar-extract-narrow.s.cs +10 -0
- data/test/MC/AArch64/neon-scalar-fp-compare.s.cs +21 -0
- data/test/MC/AArch64/neon-scalar-mul.s.cs +13 -0
- data/test/MC/AArch64/neon-scalar-neg.s.cs +6 -0
- data/test/MC/AArch64/neon-scalar-recip.s.cs +11 -0
- data/test/MC/AArch64/neon-scalar-reduce-pairwise.s.cs +3 -0
- data/test/MC/AArch64/neon-scalar-rounding-shift.s.cs +3 -0
- data/test/MC/AArch64/neon-scalar-saturating-add-sub.s.cs +25 -0
- data/test/MC/AArch64/neon-scalar-saturating-rounding-shift.s.cs +9 -0
- data/test/MC/AArch64/neon-scalar-saturating-shift.s.cs +9 -0
- data/test/MC/AArch64/neon-scalar-shift-imm.s.cs +42 -0
- data/test/MC/AArch64/neon-scalar-shift.s.cs +3 -0
- data/test/MC/AArch64/neon-shift-left-long.s.cs +13 -0
- data/test/MC/AArch64/neon-shift.s.cs +22 -0
- data/test/MC/AArch64/neon-simd-copy.s.cs +42 -0
- data/test/MC/AArch64/neon-simd-ldst-multi-elem.s.cs +197 -0
- data/test/MC/AArch64/neon-simd-ldst-one-elem.s.cs +129 -0
- data/test/MC/AArch64/neon-simd-misc.s.cs +213 -0
- data/test/MC/AArch64/neon-simd-post-ldst-multi-elem.s.cs +107 -0
- data/test/MC/AArch64/neon-simd-shift.s.cs +151 -0
- data/test/MC/AArch64/neon-tbl.s.cs +21 -0
- data/test/MC/AArch64/trace-regs.s.cs +383 -0
- data/test/MC/ARM/arm-aliases.s.cs +7 -0
- data/test/MC/ARM/arm-arithmetic-aliases.s.cs +50 -0
- data/test/MC/ARM/arm-it-block.s.cs +2 -0
- data/test/MC/ARM/arm-memory-instructions.s.cs +138 -0
- data/test/MC/ARM/arm-shift-encoding.s.cs +50 -0
- data/test/MC/ARM/arm-thumb-trustzone.s.cs +3 -0
- data/test/MC/ARM/arm-trustzone.s.cs +3 -0
- data/test/MC/ARM/arm_addrmode2.s.cs +15 -0
- data/test/MC/ARM/arm_addrmode3.s.cs +9 -0
- data/test/MC/ARM/arm_instructions.s.cs +25 -0
- data/test/MC/ARM/basic-arm-instructions-v8.s.cs +10 -0
- data/test/MC/ARM/basic-arm-instructions.s.cs +997 -0
- data/test/MC/ARM/basic-thumb-instructions.s.cs +130 -0
- data/test/MC/ARM/basic-thumb2-instructions-v8.s.cs +1 -0
- data/test/MC/ARM/basic-thumb2-instructions.s.cs +1242 -0
- data/test/MC/ARM/crc32-thumb.s.cs +7 -0
- data/test/MC/ARM/crc32.s.cs +7 -0
- data/test/MC/ARM/dot-req.s.cs +3 -0
- data/test/MC/ARM/fp-armv8.s.cs +52 -0
- data/test/MC/ARM/idiv-thumb.s.cs +3 -0
- data/test/MC/ARM/idiv.s.cs +3 -0
- data/test/MC/ARM/load-store-acquire-release-v8-thumb.s.cs +15 -0
- data/test/MC/ARM/load-store-acquire-release-v8.s.cs +15 -0
- data/test/MC/ARM/mode-switch.s.cs +7 -0
- data/test/MC/ARM/neon-abs-encoding.s.cs +15 -0
- data/test/MC/ARM/neon-absdiff-encoding.s.cs +39 -0
- data/test/MC/ARM/neon-add-encoding.s.cs +119 -0
- data/test/MC/ARM/neon-bitcount-encoding.s.cs +15 -0
- data/test/MC/ARM/neon-bitwise-encoding.s.cs +126 -0
- data/test/MC/ARM/neon-cmp-encoding.s.cs +88 -0
- data/test/MC/ARM/neon-convert-encoding.s.cs +27 -0
- data/test/MC/ARM/neon-crypto.s.cs +16 -0
- data/test/MC/ARM/neon-dup-encoding.s.cs +13 -0
- data/test/MC/ARM/neon-minmax-encoding.s.cs +57 -0
- data/test/MC/ARM/neon-mov-encoding.s.cs +76 -0
- data/test/MC/ARM/neon-mul-accum-encoding.s.cs +39 -0
- data/test/MC/ARM/neon-mul-encoding.s.cs +72 -0
- data/test/MC/ARM/neon-neg-encoding.s.cs +15 -0
- data/test/MC/ARM/neon-pairwise-encoding.s.cs +47 -0
- data/test/MC/ARM/neon-reciprocal-encoding.s.cs +13 -0
- data/test/MC/ARM/neon-reverse-encoding.s.cs +13 -0
- data/test/MC/ARM/neon-satshift-encoding.s.cs +75 -0
- data/test/MC/ARM/neon-shift-encoding.s.cs +238 -0
- data/test/MC/ARM/neon-shiftaccum-encoding.s.cs +97 -0
- data/test/MC/ARM/neon-shuffle-encoding.s.cs +59 -0
- data/test/MC/ARM/neon-sub-encoding.s.cs +82 -0
- data/test/MC/ARM/neon-table-encoding.s.cs +9 -0
- data/test/MC/ARM/neon-v8.s.cs +38 -0
- data/test/MC/ARM/neon-vld-encoding.s.cs +213 -0
- data/test/MC/ARM/neon-vst-encoding.s.cs +120 -0
- data/test/MC/ARM/neon-vswp.s.cs +3 -0
- data/test/MC/ARM/neont2-abs-encoding.s.cs +15 -0
- data/test/MC/ARM/neont2-absdiff-encoding.s.cs +39 -0
- data/test/MC/ARM/neont2-add-encoding.s.cs +65 -0
- data/test/MC/ARM/neont2-bitcount-encoding.s.cs +15 -0
- data/test/MC/ARM/neont2-bitwise-encoding.s.cs +15 -0
- data/test/MC/ARM/neont2-cmp-encoding.s.cs +17 -0
- data/test/MC/ARM/neont2-convert-encoding.s.cs +19 -0
- data/test/MC/ARM/neont2-dup-encoding.s.cs +19 -0
- data/test/MC/ARM/neont2-minmax-encoding.s.cs +57 -0
- data/test/MC/ARM/neont2-mov-encoding.s.cs +58 -0
- data/test/MC/ARM/neont2-mul-accum-encoding.s.cs +41 -0
- data/test/MC/ARM/neont2-mul-encoding.s.cs +31 -0
- data/test/MC/ARM/neont2-neg-encoding.s.cs +15 -0
- data/test/MC/ARM/neont2-pairwise-encoding.s.cs +43 -0
- data/test/MC/ARM/neont2-reciprocal-encoding.s.cs +13 -0
- data/test/MC/ARM/neont2-reverse-encoding.s.cs +13 -0
- data/test/MC/ARM/neont2-satshift-encoding.s.cs +75 -0
- data/test/MC/ARM/neont2-shift-encoding.s.cs +80 -0
- data/test/MC/ARM/neont2-shiftaccum-encoding.s.cs +97 -0
- data/test/MC/ARM/neont2-shuffle-encoding.s.cs +23 -0
- data/test/MC/ARM/neont2-sub-encoding.s.cs +23 -0
- data/test/MC/ARM/neont2-table-encoding.s.cs +9 -0
- data/test/MC/ARM/neont2-vld-encoding.s.cs +51 -0
- data/test/MC/ARM/neont2-vst-encoding.s.cs +48 -0
- data/test/MC/ARM/simple-fp-encoding.s.cs +157 -0
- data/test/MC/ARM/thumb-fp-armv8.s.cs +51 -0
- data/test/MC/ARM/thumb-hints.s.cs +12 -0
- data/test/MC/ARM/thumb-neon-crypto.s.cs +16 -0
- data/test/MC/ARM/thumb-neon-v8.s.cs +38 -0
- data/test/MC/ARM/thumb-shift-encoding.s.cs +19 -0
- data/test/MC/ARM/thumb.s.cs +19 -0
- data/test/MC/ARM/thumb2-b.w-encodingT4.s.cs +2 -0
- data/test/MC/ARM/thumb2-branches.s.cs +85 -0
- data/test/MC/ARM/thumb2-mclass.s.cs +41 -0
- data/test/MC/ARM/thumb2-narrow-dp.ll.cs +379 -0
- data/test/MC/ARM/thumb2-pldw.s.cs +2 -0
- data/test/MC/ARM/vfp4-thumb.s.cs +13 -0
- data/test/MC/ARM/vfp4.s.cs +13 -0
- data/test/MC/ARM/vpush-vpop-thumb.s.cs +9 -0
- data/test/MC/ARM/vpush-vpop.s.cs +9 -0
- data/test/MC/Mips/hilo-addressing.s.cs +4 -0
- data/test/MC/Mips/micromips-alu-instructions-EB.s.cs +33 -0
- data/test/MC/Mips/micromips-alu-instructions.s.cs +33 -0
- data/test/MC/Mips/micromips-branch-instructions-EB.s.cs +11 -0
- data/test/MC/Mips/micromips-branch-instructions.s.cs +11 -0
- data/test/MC/Mips/micromips-expansions.s.cs +20 -0
- data/test/MC/Mips/micromips-jump-instructions-EB.s.cs +5 -0
- data/test/MC/Mips/micromips-jump-instructions.s.cs +6 -0
- data/test/MC/Mips/micromips-loadstore-instructions-EB.s.cs +9 -0
- data/test/MC/Mips/micromips-loadstore-instructions.s.cs +9 -0
- data/test/MC/Mips/micromips-loadstore-unaligned-EB.s.cs +5 -0
- data/test/MC/Mips/micromips-loadstore-unaligned.s.cs +5 -0
- data/test/MC/Mips/micromips-movcond-instructions-EB.s.cs +5 -0
- data/test/MC/Mips/micromips-movcond-instructions.s.cs +5 -0
- data/test/MC/Mips/micromips-multiply-instructions-EB.s.cs +5 -0
- data/test/MC/Mips/micromips-multiply-instructions.s.cs +5 -0
- data/test/MC/Mips/micromips-shift-instructions-EB.s.cs +9 -0
- data/test/MC/Mips/micromips-shift-instructions.s.cs +9 -0
- data/test/MC/Mips/micromips-trap-instructions-EB.s.cs +13 -0
- data/test/MC/Mips/micromips-trap-instructions.s.cs +13 -0
- data/test/MC/Mips/mips-alu-instructions.s.cs +53 -0
- data/test/MC/Mips/mips-control-instructions-64.s.cs +33 -0
- data/test/MC/Mips/mips-control-instructions.s.cs +33 -0
- data/test/MC/Mips/mips-coprocessor-encodings.s.cs +17 -0
- data/test/MC/Mips/mips-dsp-instructions.s.cs +43 -0
- data/test/MC/Mips/mips-expansions.s.cs +20 -0
- data/test/MC/Mips/mips-fpu-instructions.s.cs +93 -0
- data/test/MC/Mips/mips-jump-instructions.s.cs +1 -0
- data/test/MC/Mips/mips-memory-instructions.s.cs +17 -0
- data/test/MC/Mips/mips-register-names.s.cs +33 -0
- data/test/MC/Mips/mips64-alu-instructions.s.cs +47 -0
- data/test/MC/Mips/mips64-instructions.s.cs +3 -0
- data/test/MC/Mips/mips64-register-names.s.cs +33 -0
- data/test/MC/Mips/mips_directives.s.cs +12 -0
- data/test/MC/Mips/nabi-regs.s.cs +12 -0
- data/test/MC/Mips/set-at-directive.s.cs +6 -0
- data/test/MC/Mips/test_2r.s.cs +16 -0
- data/test/MC/Mips/test_2rf.s.cs +33 -0
- data/test/MC/Mips/test_3r.s.cs +243 -0
- data/test/MC/Mips/test_3rf.s.cs +83 -0
- data/test/MC/Mips/test_bit.s.cs +49 -0
- data/test/MC/Mips/test_cbranch.s.cs +11 -0
- data/test/MC/Mips/test_ctrlregs.s.cs +33 -0
- data/test/MC/Mips/test_elm.s.cs +16 -0
- data/test/MC/Mips/test_elm_insert.s.cs +4 -0
- data/test/MC/Mips/test_elm_insve.s.cs +5 -0
- data/test/MC/Mips/test_i10.s.cs +5 -0
- data/test/MC/Mips/test_i5.s.cs +45 -0
- data/test/MC/Mips/test_i8.s.cs +11 -0
- data/test/MC/Mips/test_lsa.s.cs +5 -0
- data/test/MC/Mips/test_mi10.s.cs +24 -0
- data/test/MC/Mips/test_vec.s.cs +8 -0
- data/test/MC/PowerPC/ppc64-encoding-bookII.s.cs +25 -0
- data/test/MC/PowerPC/ppc64-encoding-bookIII.s.cs +35 -0
- data/test/MC/PowerPC/ppc64-encoding-ext.s.cs +535 -0
- data/test/MC/PowerPC/ppc64-encoding-fp.s.cs +110 -0
- data/test/MC/PowerPC/ppc64-encoding-vmx.s.cs +170 -0
- data/test/MC/PowerPC/ppc64-encoding.s.cs +202 -0
- data/test/MC/PowerPC/ppc64-operands.s.cs +32 -0
- data/test/MC/README +6 -0
- data/test/MC/Sparc/sparc-alu-instructions.s.cs +47 -0
- data/test/MC/Sparc/sparc-atomic-instructions.s.cs +7 -0
- data/test/MC/Sparc/sparc-ctrl-instructions.s.cs +11 -0
- data/test/MC/Sparc/sparc-fp-instructions.s.cs +59 -0
- data/test/MC/Sparc/sparc-mem-instructions.s.cs +25 -0
- data/test/MC/Sparc/sparc-vis.s.cs +2 -0
- data/test/MC/Sparc/sparc64-alu-instructions.s.cs +13 -0
- data/test/MC/Sparc/sparc64-ctrl-instructions.s.cs +102 -0
- data/test/MC/Sparc/sparcv8-instructions.s.cs +7 -0
- data/test/MC/Sparc/sparcv9-instructions.s.cs +1 -0
- data/test/MC/SystemZ/insn-good-z196.s.cs +589 -0
- data/test/MC/SystemZ/insn-good.s.cs +2265 -0
- data/test/MC/SystemZ/regs-good.s.cs +45 -0
- data/test/MC/X86/3DNow.s.cs +29 -0
- data/test/MC/X86/address-size.s.cs +5 -0
- data/test/MC/X86/avx512-encodings.s.cs +12 -0
- data/test/MC/X86/intel-syntax-encoding.s.cs +30 -0
- data/test/MC/X86/x86-32-avx.s.cs +833 -0
- data/test/MC/X86/x86-32-fma3.s.cs +169 -0
- data/test/MC/X86/x86-32-ms-inline-asm.s.cs +27 -0
- data/test/MC/X86/x86_64-avx-clmul-encoding.s.cs +11 -0
- data/test/MC/X86/x86_64-avx-encoding.s.cs +1058 -0
- data/test/MC/X86/x86_64-bmi-encoding.s.cs +51 -0
- data/test/MC/X86/x86_64-encoding.s.cs +59 -0
- data/test/MC/X86/x86_64-fma3-encoding.s.cs +169 -0
- data/test/MC/X86/x86_64-fma4-encoding.s.cs +98 -0
- data/test/MC/X86/x86_64-hle-encoding.s.cs +3 -0
- data/test/MC/X86/x86_64-imm-widths.s.cs +27 -0
- data/test/MC/X86/x86_64-rand-encoding.s.cs +13 -0
- data/test/MC/X86/x86_64-rtm-encoding.s.cs +4 -0
- data/test/MC/X86/x86_64-sse4a.s.cs +1 -0
- data/test/MC/X86/x86_64-tbm-encoding.s.cs +40 -0
- data/test/MC/X86/x86_64-xop-encoding.s.cs +152 -0
- data/test/README +6 -0
- data/test/test.rb +205 -0
- data/test/test.rb.SPEC +235 -0
- data/test/test_arm.rb +202 -0
- data/test/test_arm.rb.SPEC +275 -0
- data/test/test_arm64.rb +150 -0
- data/test/test_arm64.rb.SPEC +116 -0
- data/test/test_detail.rb +228 -0
- data/test/test_detail.rb.SPEC +322 -0
- data/test/test_exhaustive.rb +80 -0
- data/test/test_mips.rb +118 -0
- data/test/test_mips.rb.SPEC +91 -0
- data/test/test_ppc.rb +137 -0
- data/test/test_ppc.rb.SPEC +84 -0
- data/test/test_sanity.rb +83 -0
- data/test/test_skipdata.rb +111 -0
- data/test/test_skipdata.rb.SPEC +58 -0
- data/test/test_sparc.rb +113 -0
- data/test/test_sparc.rb.SPEC +116 -0
- data/test/test_sysz.rb +111 -0
- data/test/test_sysz.rb.SPEC +61 -0
- data/test/test_x86.rb +189 -0
- data/test/test_x86.rb.SPEC +579 -0
- data/test/test_xcore.rb +100 -0
- data/test/test_xcore.rb.SPEC +75 -0
- metadata +393 -0
@@ -0,0 +1,322 @@
|
|
1
|
+
****************
|
2
|
+
Platform: X86 16bit (Intel syntax)
|
3
|
+
Code: 0x8d 0x4c 0x32 0x08 0x01 0xd8 0x81 0xc6 0x34 0x12 0x00 0x00
|
4
|
+
Disasm:
|
5
|
+
0x1000: lea cx, word ptr [si + 0x32] // insn-ID: 315, insn-mnem: lea
|
6
|
+
0x1003: or byte ptr [bx + di], al // insn-ID: 325, insn-mnem: or
|
7
|
+
Implicit registers modified: flags
|
8
|
+
0x1005: fadd dword ptr [bx + di + 0x34c6] // insn-ID: 15, insn-mnem: fadd
|
9
|
+
Implicit registers modified: fpsw
|
10
|
+
0x1009: adc al, byte ptr [bx + si] // insn-ID: 6, insn-mnem: adc
|
11
|
+
Implicit registers read: flags
|
12
|
+
Implicit registers modified: flags
|
13
|
+
0x100b:
|
14
|
+
|
15
|
+
****************
|
16
|
+
Platform: X86 32bit (ATT syntax)
|
17
|
+
Code: 0x8d 0x4c 0x32 0x08 0x01 0xd8 0x81 0xc6 0x34 0x12 0x00 0x00
|
18
|
+
Disasm:
|
19
|
+
0x1000: leal 8(%edx, %esi), %ecx // insn-ID: 315, insn-mnem: lea
|
20
|
+
This instruction belongs to groups: not64bitmode
|
21
|
+
0x1004: addl %ebx, %eax // insn-ID: 8, insn-mnem: add
|
22
|
+
Implicit registers modified: eflags
|
23
|
+
0x1006: addl $0x1234, %esi // insn-ID: 8, insn-mnem: add
|
24
|
+
Implicit registers modified: eflags
|
25
|
+
0x100c:
|
26
|
+
|
27
|
+
****************
|
28
|
+
Platform: X86 32 (Intel syntax)
|
29
|
+
Code: 0x8d 0x4c 0x32 0x08 0x01 0xd8 0x81 0xc6 0x34 0x12 0x00 0x00
|
30
|
+
Disasm:
|
31
|
+
0x1000: lea ecx, dword ptr [edx + esi + 8] // insn-ID: 315, insn-mnem: lea
|
32
|
+
This instruction belongs to groups: not64bitmode
|
33
|
+
0x1004: add eax, ebx // insn-ID: 8, insn-mnem: add
|
34
|
+
Implicit registers modified: eflags
|
35
|
+
0x1006: add esi, 0x1234 // insn-ID: 8, insn-mnem: add
|
36
|
+
Implicit registers modified: eflags
|
37
|
+
0x100c:
|
38
|
+
|
39
|
+
****************
|
40
|
+
Platform: X86 64 (Intel syntax)
|
41
|
+
Code: 0x55 0x48 0x8b 0x05 0xb8 0x13 0x00 0x00
|
42
|
+
Disasm:
|
43
|
+
0x1000: push rbp // insn-ID: 580, insn-mnem: push
|
44
|
+
Implicit registers read: rsp
|
45
|
+
Implicit registers modified: rsp
|
46
|
+
This instruction belongs to groups: mode64
|
47
|
+
0x1001: mov rax, qword ptr [rip + 0x13b8] // insn-ID: 442, insn-mnem: mov
|
48
|
+
0x1008:
|
49
|
+
|
50
|
+
****************
|
51
|
+
Platform: ARM
|
52
|
+
Code: 0xed 0xff 0xff 0xeb 0x04 0xe0 0x2d 0xe5 0x00 0x00 0x00 0x00 0xe0 0x83 0x22 0xe5 0xf1 0x02 0x03 0x0e 0x00 0x00 0xa0 0xe3 0x02 0x30 0xc1 0xe7 0x00 0x00 0x53 0xe3
|
53
|
+
Disasm:
|
54
|
+
0x1000: bl #0xfbc // insn-ID: 13, insn-mnem: bl
|
55
|
+
Implicit registers read: pc
|
56
|
+
Implicit registers modified: lr
|
57
|
+
This instruction belongs to groups: jump arm
|
58
|
+
0x1004: str lr, [sp, #-4]! // insn-ID: 212, insn-mnem: str
|
59
|
+
This instruction belongs to groups: arm
|
60
|
+
0x1008: andeq r0, r0, r0 // insn-ID: 8, insn-mnem: and
|
61
|
+
This instruction belongs to groups: arm
|
62
|
+
0x100c: str r8, [r2, #-0x3e0]! // insn-ID: 212, insn-mnem: str
|
63
|
+
This instruction belongs to groups: arm
|
64
|
+
0x1010: mcreq p2, #0, r0, c3, c1, #7 // insn-ID: 74, insn-mnem: mcr
|
65
|
+
This instruction belongs to groups: arm
|
66
|
+
0x1014: mov r0, #0 // insn-ID: 80, insn-mnem: mov
|
67
|
+
This instruction belongs to groups: arm
|
68
|
+
0x1018: strb r3, [r1, r2] // insn-ID: 203, insn-mnem: strb
|
69
|
+
This instruction belongs to groups: arm
|
70
|
+
0x101c: cmp r3, #0 // insn-ID: 23, insn-mnem: cmp
|
71
|
+
Implicit registers modified: cpsr
|
72
|
+
This instruction belongs to groups: arm
|
73
|
+
0x1020:
|
74
|
+
|
75
|
+
****************
|
76
|
+
Platform: THUMB-2
|
77
|
+
Code: 0x4f 0xf0 0x00 0x01 0xbd 0xe8 0x00 0x88 0xd1 0xe8 0x00 0xf0
|
78
|
+
Disasm:
|
79
|
+
0x1000: mov.w r1, #0 // insn-ID: 80, insn-mnem: mov
|
80
|
+
This instruction belongs to groups: thumb2
|
81
|
+
0x1004: pop.w {fp, pc} // insn-ID: 425, insn-mnem: pop
|
82
|
+
This instruction belongs to groups: thumb2
|
83
|
+
0x1008: tbb [r1, r0] // insn-ID: 420, insn-mnem: tbb
|
84
|
+
This instruction belongs to groups: thumb2 jump
|
85
|
+
0x100c:
|
86
|
+
|
87
|
+
****************
|
88
|
+
Platform: ARM: Cortex-A15 + NEON
|
89
|
+
Code: 0x10 0xf1 0x10 0xe7 0x11 0xf2 0x31 0xe7 0xdc 0xa1 0x2e 0xf3 0xe8 0x4e 0x62 0xf3
|
90
|
+
Disasm:
|
91
|
+
0x1000: sdiv r0, r0, r1 // insn-ID: 122, insn-mnem: sdiv
|
92
|
+
This instruction belongs to groups: arm
|
93
|
+
0x1004: udiv r1, r1, r2 // insn-ID: 231, insn-mnem: udiv
|
94
|
+
This instruction belongs to groups: arm
|
95
|
+
0x1008: vbit q5, q15, q6 // insn-ID: 274, insn-mnem: vbit
|
96
|
+
This instruction belongs to groups: neon
|
97
|
+
0x100c: vcgt.f32 q10, q9, q12 // insn-ID: 278, insn-mnem: vcgt
|
98
|
+
This instruction belongs to groups: neon
|
99
|
+
0x1010:
|
100
|
+
|
101
|
+
****************
|
102
|
+
Platform: THUMB
|
103
|
+
Code: 0x70 0x47 0xeb 0x46 0x83 0xb0 0xc9 0x68
|
104
|
+
Disasm:
|
105
|
+
0x1000: bx lr // insn-ID: 15, insn-mnem: bx
|
106
|
+
This instruction belongs to groups: thumb jump
|
107
|
+
0x1002: mov fp, sp // insn-ID: 80, insn-mnem: mov
|
108
|
+
This instruction belongs to groups: thumb thumb1only
|
109
|
+
0x1004: sub sp, #0xc // insn-ID: 213, insn-mnem: sub
|
110
|
+
This instruction belongs to groups: thumb thumb1only
|
111
|
+
0x1006: ldr r1, [r1, #0xc] // insn-ID: 73, insn-mnem: ldr
|
112
|
+
This instruction belongs to groups: thumb thumb1only
|
113
|
+
0x1008:
|
114
|
+
|
115
|
+
****************
|
116
|
+
Platform: Thumb-MClass
|
117
|
+
Code: 0xef 0xf3 0x02 0x80
|
118
|
+
Disasm:
|
119
|
+
0x1000: mrs r0, eapsr // insn-ID: 87, insn-mnem: mrs
|
120
|
+
This instruction belongs to groups: thumb mclass
|
121
|
+
0x1004:
|
122
|
+
|
123
|
+
****************
|
124
|
+
Platform: Arm-V8
|
125
|
+
Code: 0xe0 0x3b 0xb2 0xee 0x42 0x00 0x01 0xe1 0x51 0xf0 0x7f 0xf5
|
126
|
+
Disasm:
|
127
|
+
0x1000: vcvtt.f64.f16 d3, s1 // insn-ID: 292, insn-mnem: vcvtt
|
128
|
+
This instruction belongs to groups: fparmv8 dpvfp
|
129
|
+
0x1004: crc32b r0, r1, r2 // insn-ID: 25, insn-mnem: crc32b
|
130
|
+
This instruction belongs to groups: arm v8 crc
|
131
|
+
0x1008: dmb oshld // insn-ID: 32, insn-mnem: dmb
|
132
|
+
This instruction belongs to groups: arm databarrier
|
133
|
+
0x100c:
|
134
|
+
|
135
|
+
****************
|
136
|
+
Platform: MIPS-32 (Big-endian)
|
137
|
+
Code: 0x0c 0x10 0x00 0x97 0x00 0x00 0x00 0x00 0x24 0x02 0x00 0x0c 0x8f 0xa2 0x00 0x00 0x34 0x21 0x34 0x56 0x00 0x80 0x04 0x08
|
138
|
+
Disasm:
|
139
|
+
0x1000: jal 0x40025c // insn-ID: 322, insn-mnem: jal
|
140
|
+
Implicit registers modified: ra
|
141
|
+
This instruction belongs to groups: stdenc
|
142
|
+
0x1004: nop // insn-ID: 582, insn-mnem: nop
|
143
|
+
This instruction belongs to groups: stdenc
|
144
|
+
0x1008: addiu $v0, $zero, 0xc // insn-ID: 21, insn-mnem: addiu
|
145
|
+
This instruction belongs to groups: stdenc
|
146
|
+
0x100c: lw $v0, ($sp) // insn-ID: 353, insn-mnem: lw
|
147
|
+
This instruction belongs to groups: stdenc
|
148
|
+
0x1010: ori $at, $at, 0x3456 // insn-ID: 445, insn-mnem: ori
|
149
|
+
This instruction belongs to groups: stdenc
|
150
|
+
0x1014: jr.hb $a0 // insn-ID: 585, insn-mnem: jr.hb
|
151
|
+
This instruction belongs to groups: stdenc mips32 notmips32r6 notmips64r6 jump
|
152
|
+
0x1018:
|
153
|
+
|
154
|
+
****************
|
155
|
+
Platform: MIPS-64-EL (Little-endian)
|
156
|
+
Code: 0x56 0x34 0x21 0x34 0xc2 0x17 0x01 0x00
|
157
|
+
Disasm:
|
158
|
+
0x1000: ori $at, $at, 0x3456 // insn-ID: 445, insn-mnem: ori
|
159
|
+
This instruction belongs to groups: stdenc
|
160
|
+
0x1004: srl $v0, $at, 0x1f // insn-ID: 525, insn-mnem: srl
|
161
|
+
This instruction belongs to groups: stdenc
|
162
|
+
0x1008:
|
163
|
+
|
164
|
+
****************
|
165
|
+
Platform: MIPS-32R6 | Micro (Big-endian)
|
166
|
+
Code: 0x00 0x07 0x00 0x07 0x00 0x11 0x93 0x7c 0x01 0x8c 0x8b 0x7c 0x00 0xc7 0x48 0xd0
|
167
|
+
Disasm:
|
168
|
+
0x1000: break 7, 0 // insn-ID: 114, insn-mnem: break
|
169
|
+
This instruction belongs to groups: micromips
|
170
|
+
0x1004: wait 0x11 // insn-ID: 577, insn-mnem: wait
|
171
|
+
This instruction belongs to groups: micromips
|
172
|
+
0x1008: syscall 0x18c // insn-ID: 555, insn-mnem: syscall
|
173
|
+
This instruction belongs to groups: micromips
|
174
|
+
0x100c: rotrv $t1, $a2, $a3 // insn-ID: 471, insn-mnem: rotrv
|
175
|
+
This instruction belongs to groups: micromips
|
176
|
+
0x1010:
|
177
|
+
|
178
|
+
****************
|
179
|
+
Platform: MIPS-32R6 (Big-endian)
|
180
|
+
Code: 0xec 0x80 0x00 0x19 0x7c 0x43 0x22 0xa0
|
181
|
+
Disasm:
|
182
|
+
0x1000: addiupc $a0, 0x64 // insn-ID: 3, insn-mnem: addiupc
|
183
|
+
This instruction belongs to groups: stdenc mips32r6
|
184
|
+
0x1004: align $a0, $v0, $v1, 2 // insn-ID: 22, insn-mnem: align
|
185
|
+
This instruction belongs to groups: stdenc mips32r6
|
186
|
+
0x1008:
|
187
|
+
|
188
|
+
****************
|
189
|
+
Platform: ARM-64
|
190
|
+
Code: 0x09 0x00 0x38 0xd5 0xbf 0x40 0x00 0xd5 0x0c 0x05 0x13 0xd5 0x20 0x50 0x02 0x0e 0x20 0xe4 0x3d 0x0f 0x00 0x18 0xa0 0x5f 0xa2 0x00 0xae 0x9e 0x9f 0x37 0x03 0xd5 0xbf 0x33 0x03 0xd5 0xdf 0x3f 0x03 0xd5 0x21 0x7c 0x02 0x9b 0x21 0x7c 0x00 0x53 0x00 0x40 0x21 0x4b 0xe1 0x0b 0x40 0xb9 0x20 0x04 0x81 0xda 0x20 0x08 0x02 0x8b 0x10 0x5b 0xe8 0x3c
|
191
|
+
Disasm:
|
192
|
+
0x1000: mrs x9, midr_el1 // insn-ID: 192, insn-mnem: mrs
|
193
|
+
0x1004: msr spsel, #0 // insn-ID: 193, insn-mnem: msr
|
194
|
+
Implicit registers modified: nzcv
|
195
|
+
0x1008: msr dbgdtrtx_el0, x12 // insn-ID: 193, insn-mnem: msr
|
196
|
+
0x100c: tbx v0.8b, {v1.16b, v2.16b, v3.16b}, v2.8b // insn-ID: 347, insn-mnem: tbx
|
197
|
+
This instruction belongs to groups: neon
|
198
|
+
0x1010: scvtf v0.2s, v1.2s, #3 // insn-ID: 234, insn-mnem: scvtf
|
199
|
+
This instruction belongs to groups: neon
|
200
|
+
0x1014: fmla s0, s0, v0.s[3] // insn-ID: 114, insn-mnem: fmla
|
201
|
+
This instruction belongs to groups: neon
|
202
|
+
0x1018: fmov x2, v5.d[1] // insn-ID: 116, insn-mnem: fmov
|
203
|
+
This instruction belongs to groups: fparmv8
|
204
|
+
0x101c: dsb nsh // insn-ID: 60, insn-mnem: dsb
|
205
|
+
0x1020: dmb osh // insn-ID: 58, insn-mnem: dmb
|
206
|
+
0x1024: isb // insn-ID: 142, insn-mnem: isb
|
207
|
+
0x1028: mul x1, x1, x2 // insn-ID: 195, insn-mnem: mul
|
208
|
+
0x102c: lsr w1, w1, #0 // insn-ID: 184, insn-mnem: lsr
|
209
|
+
0x1030: sub w0, w0, w1, uxtw // insn-ID: 340, insn-mnem: sub
|
210
|
+
0x1034: ldr w1, [sp, #8] // insn-ID: 162, insn-mnem: ldr
|
211
|
+
0x1038: cneg x0, x1, ne // insn-ID: 440, insn-mnem: cneg
|
212
|
+
Implicit registers read: nzcv
|
213
|
+
0x103c: add x0, x1, x2, lsl #2 // insn-ID: 6, insn-mnem: add
|
214
|
+
0x1040: ldr q16, [x24, w8, uxtw #4] // insn-ID: 162, insn-mnem: ldr
|
215
|
+
0x1044:
|
216
|
+
|
217
|
+
****************
|
218
|
+
Platform: PPC-64
|
219
|
+
Code: 0x80 0x20 0x00 0x00 0x80 0x3f 0x00 0x00 0x10 0x43 0x23 0x0e 0xd0 0x44 0x00 0x80 0x4c 0x43 0x22 0x02 0x2d 0x03 0x00 0x80 0x7c 0x43 0x20 0x14 0x7c 0x43 0x20 0x93 0x4f 0x20 0x00 0x21 0x4c 0xc8 0x00 0x21 0x40 0x82 0x00 0x14
|
220
|
+
Disasm:
|
221
|
+
0x1000: lwz r1, (0) // insn-ID: 347, insn-mnem: lwz
|
222
|
+
0x1004: lwz r1, (r31) // insn-ID: 347, insn-mnem: lwz
|
223
|
+
0x1008: vpkpx v2, v3, v4 // insn-ID: 570, insn-mnem: vpkpx
|
224
|
+
This instruction belongs to groups: altivec
|
225
|
+
0x100c: stfs f2, 0x80(r4) // insn-ID: 443, insn-mnem: stfs
|
226
|
+
0x1010: crand 2, 3, 4 // insn-ID: 52, insn-mnem: crand
|
227
|
+
0x1014: cmpwi cr2, r3, 0x80 // insn-ID: 47, insn-mnem: cmpwi
|
228
|
+
0x1018: addc r2, r3, r4 // insn-ID: 2, insn-mnem: addc
|
229
|
+
Implicit registers modified: ca
|
230
|
+
0x101c: mulhd. r2, r3, r4 // insn-ID: 384, insn-mnem: mulhd
|
231
|
+
Implicit registers modified: cr0
|
232
|
+
0x1020: bdnzlrl+ // insn-ID: 28, insn-mnem: bdnzlrl
|
233
|
+
Implicit registers read: ctr lr rm
|
234
|
+
Implicit registers modified: ctr
|
235
|
+
0x1024: bgelrl- cr2 // insn-ID: 38, insn-mnem: blrl
|
236
|
+
Implicit registers read: ctr lr rm
|
237
|
+
Implicit registers modified: lr ctr
|
238
|
+
0x1028: bne 0x103c // insn-ID: 13, insn-mnem: b
|
239
|
+
Implicit registers read: ctr rm
|
240
|
+
Implicit registers modified: ctr
|
241
|
+
0x102c:
|
242
|
+
|
243
|
+
****************
|
244
|
+
Platform: Sparc
|
245
|
+
Code: 0x80 0xa0 0x40 0x02 0x85 0xc2 0x60 0x08 0x85 0xe8 0x20 0x01 0x81 0xe8 0x00 0x00 0x90 0x10 0x20 0x01 0xd5 0xf6 0x10 0x16 0x21 0x00 0x00 0x0a 0x86 0x00 0x40 0x02 0x01 0x00 0x00 0x00 0x12 0xbf 0xff 0xff 0x10 0xbf 0xff 0xff 0xa0 0x02 0x00 0x09 0x0d 0xbf 0xff 0xff 0xd4 0x20 0x60 0x00 0xd4 0x4e 0x00 0x16 0x2a 0xc2 0x80 0x03
|
246
|
+
Disasm:
|
247
|
+
0x1000: cmp %g1, %g2 // insn-ID: 33, insn-mnem: cmp
|
248
|
+
Implicit registers modified: icc
|
249
|
+
0x1004: jmpl %o1+8, %g2 // insn-ID: 194, insn-mnem: jmpl
|
250
|
+
0x1008: restore %g0, 1, %g2 // insn-ID: 226, insn-mnem: restore
|
251
|
+
0x100c: restore // insn-ID: 226, insn-mnem: restore
|
252
|
+
0x1010: mov 1, %o0 // insn-ID: 207, insn-mnem: mov
|
253
|
+
0x1014: casx [%i0], %l6, %o2 // insn-ID: 28, insn-mnem: casx
|
254
|
+
This instruction belongs to groups: 64bit
|
255
|
+
0x1018: sethi 0xa, %l0 // insn-ID: 232, insn-mnem: sethi
|
256
|
+
0x101c: add %g1, %g2, %g3 // insn-ID: 6, insn-mnem: add
|
257
|
+
0x1020: nop // insn-ID: 217, insn-mnem: nop
|
258
|
+
0x1024: bne 0x1020 // insn-ID: 16, insn-mnem: b
|
259
|
+
Implicit registers read: icc
|
260
|
+
This instruction belongs to groups: jump
|
261
|
+
0x1028: ba 0x1024 // insn-ID: 16, insn-mnem: b
|
262
|
+
This instruction belongs to groups: jump
|
263
|
+
0x102c: add %o0, %o1, %l0 // insn-ID: 6, insn-mnem: add
|
264
|
+
0x1030: fbg 0x102c // insn-ID: 19, insn-mnem: fb
|
265
|
+
Implicit registers read: fcc0
|
266
|
+
This instruction belongs to groups: jump
|
267
|
+
0x1034: st %o2, [%g1] // insn-ID: 246, insn-mnem: st
|
268
|
+
0x1038: ldsb [%i0+%l6], %o2 // insn-ID: 198, insn-mnem: ldsb
|
269
|
+
0x103c: brnz,a,pn %o2, 0x1048 // insn-ID: 24, insn-mnem: brnz
|
270
|
+
This instruction belongs to groups: 64bit jump
|
271
|
+
0x1040:
|
272
|
+
|
273
|
+
****************
|
274
|
+
Platform: SparcV9
|
275
|
+
Code: 0x81 0xa8 0x0a 0x24 0x89 0xa0 0x10 0x20 0x89 0xa0 0x1a 0x60 0x89 0xa0 0x00 0xe0
|
276
|
+
Disasm:
|
277
|
+
0x1000: fcmps %f0, %f4 // insn-ID: 70, insn-mnem: fcmps
|
278
|
+
0x1004: fstox %f0, %f4 // insn-ID: 181, insn-mnem: fstox
|
279
|
+
This instruction belongs to groups: 64bit
|
280
|
+
0x1008: fqtoi %f0, %f4 // insn-ID: 159, insn-mnem: fqtoi
|
281
|
+
This instruction belongs to groups: hardquad
|
282
|
+
0x100c: fnegq %f0, %f4 // insn-ID: 127, insn-mnem: fnegq
|
283
|
+
This instruction belongs to groups: v9
|
284
|
+
0x1010:
|
285
|
+
|
286
|
+
****************
|
287
|
+
Platform: SystemZ
|
288
|
+
Code: 0xed 0x00 0x00 0x00 0x00 0x1a 0x5a 0x0f 0x1f 0xff 0xc2 0x09 0x80 0x00 0x00 0x00 0x07 0xf7 0xeb 0x2a 0xff 0xff 0x7f 0x57 0xe3 0x01 0xff 0xff 0x7f 0x57 0xeb 0x00 0xf0 0x00 0x00 0x24 0xb2 0x4f 0x00 0x78
|
289
|
+
Disasm:
|
290
|
+
0x1000: adb %f0, 0 // insn-ID: 2, insn-mnem: adb
|
291
|
+
Implicit registers modified: cc
|
292
|
+
0x1006: a %r0, 0xfff(%r15, %r1) // insn-ID: 1, insn-mnem: a
|
293
|
+
Implicit registers modified: cc
|
294
|
+
0x100a: afi %r0, -0x80000000 // insn-ID: 6, insn-mnem: afi
|
295
|
+
Implicit registers modified: cc
|
296
|
+
0x1010: br %r7 // insn-ID: 283, insn-mnem: br
|
297
|
+
This instruction belongs to groups: jump
|
298
|
+
0x1012: xiy 0x7ffff(%r15), 0x2a // insn-ID: 678, insn-mnem: xiy
|
299
|
+
Implicit registers modified: cc
|
300
|
+
0x1018: xy %r0, 0x7ffff(%r1, %r15) // insn-ID: 681, insn-mnem: xy
|
301
|
+
Implicit registers modified: cc
|
302
|
+
0x101e: stmg %r0, %r0, 0(%r15) // insn-ID: 657, insn-mnem: stmg
|
303
|
+
0x1024: ear %r7, %a8 // insn-ID: 383, insn-mnem: ear
|
304
|
+
0x1028:
|
305
|
+
|
306
|
+
****************
|
307
|
+
Platform: XCore
|
308
|
+
Code: 0xfe 0x0f 0xfe 0x17 0x13 0x17 0xc6 0xfe 0xec 0x17 0x97 0xf8 0xec 0x4f 0x1f 0xfd 0xec 0x37 0x07 0xf2 0x45 0x5b 0xf9 0xfa 0x02 0x06 0x1b 0x10
|
309
|
+
Disasm:
|
310
|
+
0x1000: get r11, ed // insn-ID: 43, insn-mnem: get
|
311
|
+
Implicit registers modified: r11
|
312
|
+
0x1002: ldw et, sp[4] // insn-ID: 66, insn-mnem: ldw
|
313
|
+
Implicit registers read: sp
|
314
|
+
0x1004: setd res[r3], r4 // insn-ID: 93, insn-mnem: setd
|
315
|
+
0x1006: init t[r2]:lr, r1 // insn-ID: 50, insn-mnem: init
|
316
|
+
0x100a: divu r9, r1, r3 // insn-ID: 26, insn-mnem: divu
|
317
|
+
0x100e: lda16 r9, r3[-r11] // insn-ID: 62, insn-mnem: lda16
|
318
|
+
0x1012: ldw dp, dp[0x81c5] // insn-ID: 66, insn-mnem: ldw
|
319
|
+
0x1016: lmul r11, r0, r2, r5, r8, r10 // insn-ID: 68, insn-mnem: lmul
|
320
|
+
0x101a: add r1, r2, r3 // insn-ID: 1, insn-mnem: add
|
321
|
+
0x101c:
|
322
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Library by Nguyen Anh Quynh
|
4
|
+
# Original binding by Nguyen Anh Quynh and Tan Sheng Di
|
5
|
+
# Additional binding work by Ben Nagy
|
6
|
+
# (c) 2013 COSEINC. All Rights Reserved.
|
7
|
+
|
8
|
+
require 'crabstone'
|
9
|
+
require 'stringio'
|
10
|
+
|
11
|
+
module TestExhaustive
|
12
|
+
|
13
|
+
include Crabstone
|
14
|
+
|
15
|
+
@files = Dir['**/*.cs']
|
16
|
+
check = pass = fail = error = 0
|
17
|
+
@files.each do |fn|
|
18
|
+
|
19
|
+
lines = File.readlines fn
|
20
|
+
arch, mode, syntax = lines.shift.delete('# ').split(',')
|
21
|
+
|
22
|
+
archnum = Crabstone.const_get arch.sub('CS_','')
|
23
|
+
|
24
|
+
begin
|
25
|
+
modenum = Integer(mode)
|
26
|
+
rescue
|
27
|
+
modenum = mode.gsub('CS_','').split('+').map {|m| Crabstone.const_get(m)}.inject(:+)
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
cs = Disassembler.new(archnum, modenum)
|
32
|
+
check +=1
|
33
|
+
rescue
|
34
|
+
warn "Error #{$!} processing #{fn}"
|
35
|
+
end
|
36
|
+
|
37
|
+
if syntax =~ /ATT/
|
38
|
+
cs.syntax = :att
|
39
|
+
end
|
40
|
+
if arch =~ /arm/i
|
41
|
+
cs.syntax = :no_regname
|
42
|
+
end
|
43
|
+
|
44
|
+
lines.each.with_index {|l, i|
|
45
|
+
|
46
|
+
bytes, text = l.chomp.split(' = ')
|
47
|
+
bytes = bytes.split(',').map {|b| b.to_i(16)}.pack('c*')
|
48
|
+
# #32 or $32 -> #0x20 #-32 -> #-0x20
|
49
|
+
want = text.gsub(/([\$#])(-?)([0-9]{2,})/) {|s| "#{$1}#{$2}0x#{$3.to_i.to_s(16)}"}.downcase
|
50
|
+
|
51
|
+
begin
|
52
|
+
disasm = cs.disasm(bytes,0).map {|i|"#{i.mnemonic} #{i.op_str}"}
|
53
|
+
rescue
|
54
|
+
puts "[**] #{fn}:#{i+2} want #{text}, got #{$!} with #{bytes.inspect}, #{arch}, #{mode}"
|
55
|
+
error += 1
|
56
|
+
next
|
57
|
+
end
|
58
|
+
|
59
|
+
if disasm.size > 1
|
60
|
+
puts "[!!] #{fn}:#{i+2} disasm too big"
|
61
|
+
fail += 1
|
62
|
+
next
|
63
|
+
end
|
64
|
+
if disasm.first != want
|
65
|
+
puts "[!!] #{fn}:#{i+2} want #{want.inspect}, got #{disasm.first.inspect}"
|
66
|
+
fail +=1
|
67
|
+
next
|
68
|
+
end
|
69
|
+
|
70
|
+
puts "[OK] #{fn}:#{i+2} #{bytes.inspect} = #{text}"
|
71
|
+
pass += 1
|
72
|
+
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
if check != @files.size
|
77
|
+
warn "Missed some: #{check} vs #{@files.size}"
|
78
|
+
end
|
79
|
+
puts "Files: #{check}, Pass: #{pass}, Fail: #{fail}, Error: #{error}"
|
80
|
+
end
|
data/test/test_mips.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Library by Nguyen Anh Quynh
|
4
|
+
# Original binding by Nguyen Anh Quynh and Tan Sheng Di
|
5
|
+
# Additional binding work by Ben Nagy
|
6
|
+
# (c) 2013 COSEINC. All Rights Reserved.
|
7
|
+
|
8
|
+
require 'crabstone'
|
9
|
+
require 'stringio'
|
10
|
+
|
11
|
+
module TestMIPS
|
12
|
+
|
13
|
+
MIPS_CODE = "\x0C\x10\x00\x97\x00\x00\x00\x00\x24\x02\x00\x0c\x8f\xa2\x00\x00\x34\x21\x34\x56"
|
14
|
+
MIPS_CODE2 = "\x56\x34\x21\x34\xc2\x17\x01\x00"
|
15
|
+
MIPS_32R6M = "\x00\x07\x00\x07\x00\x11\x93\x7c\x01\x8c\x8b\x7c\x00\xc7\x48\xd0"
|
16
|
+
MIPS_32R6 = "\xec\x80\x00\x19\x7c\x43\x22\xa0"
|
17
|
+
|
18
|
+
include Crabstone
|
19
|
+
include Crabstone::MIPS
|
20
|
+
|
21
|
+
@platforms = [
|
22
|
+
Hash[
|
23
|
+
'arch' => ARCH_MIPS,
|
24
|
+
'mode' => MODE_MIPS32 + MODE_BIG_ENDIAN, # new MODE_MIPS32
|
25
|
+
'code' => MIPS_CODE,
|
26
|
+
'comment' => "MIPS-32 (Big-endian)"
|
27
|
+
],
|
28
|
+
Hash[
|
29
|
+
'arch' => ARCH_MIPS,
|
30
|
+
'mode' => MODE_64 + MODE_LITTLE_ENDIAN, # old alias
|
31
|
+
'code' => MIPS_CODE2,
|
32
|
+
'comment' => "MIPS-64-EL (Little-endian)"
|
33
|
+
],
|
34
|
+
Hash[
|
35
|
+
'arch' => ARCH_MIPS,
|
36
|
+
'mode' => MODE_MIPS32R6 + MODE_MICRO + MODE_BIG_ENDIAN,
|
37
|
+
'code' => MIPS_32R6M,
|
38
|
+
'comment' => "MIPS-32R6 | Micro (Big-endian)"
|
39
|
+
],
|
40
|
+
Hash[
|
41
|
+
'arch' => ARCH_MIPS,
|
42
|
+
'mode' => MODE_MIPS32R6 + MODE_BIG_ENDIAN,
|
43
|
+
'code' => MIPS_32R6,
|
44
|
+
'comment' => "MIPS-32R6 (Big-endian)"
|
45
|
+
]
|
46
|
+
]
|
47
|
+
|
48
|
+
def self.uint32 i
|
49
|
+
Integer(i) & 0xffffffff
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.print_detail cs, insn, sio
|
53
|
+
if insn.op_count > 0
|
54
|
+
if insn.writes_reg? :ra
|
55
|
+
print "[w:ra] "
|
56
|
+
end
|
57
|
+
sio.puts "\top_count: #{insn.op_count}"
|
58
|
+
insn.operands.each_with_index do |op,idx|
|
59
|
+
case op[:type]
|
60
|
+
when OP_REG
|
61
|
+
sio.puts "\t\toperands[#{idx}].type: REG = #{cs.reg_name(op.value)}"
|
62
|
+
when OP_IMM
|
63
|
+
sio.puts "\t\toperands[#{idx}].type: IMM = 0x#{self.uint32(op.value).to_s(16)}"
|
64
|
+
when OP_MEM
|
65
|
+
sio.puts "\t\toperands[#{idx}].type: MEM"
|
66
|
+
if op.value[:base].nonzero?
|
67
|
+
sio.puts "\t\t\toperands[#{idx}].mem.base: REG = %s" % cs.reg_name(op.value[:base])
|
68
|
+
end
|
69
|
+
if op.value[:disp].nonzero?
|
70
|
+
sio.puts "\t\t\toperands[#{idx}].mem.disp: 0x%x" % (self.uint32(op.value[:disp]))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
sio.puts
|
76
|
+
end
|
77
|
+
|
78
|
+
ours = StringIO.new
|
79
|
+
|
80
|
+
begin
|
81
|
+
cs = Disassembler.new(0,0)
|
82
|
+
print "MIPS Test: Capstone v #{cs.version.join('.')} - "
|
83
|
+
ensure
|
84
|
+
cs.close
|
85
|
+
end
|
86
|
+
|
87
|
+
#Test through all modes and architectures
|
88
|
+
@platforms.each do |p|
|
89
|
+
ours.puts "****************"
|
90
|
+
ours.puts "Platform: #{p['comment']}"
|
91
|
+
ours.puts "Code:#{p['code'].bytes.map {|b| "0x%.2x" % b}.join(' ')} "
|
92
|
+
ours.puts "Disasm:"
|
93
|
+
|
94
|
+
cs = Disassembler.new(p['arch'], p['mode'])
|
95
|
+
cs.decomposer = true
|
96
|
+
cache = nil
|
97
|
+
|
98
|
+
cs.disasm(p['code'], 0x1000).each {|insn|
|
99
|
+
ours.puts "0x#{insn.address.to_s(16)}:\t#{insn.mnemonic}\t#{insn.op_str}"
|
100
|
+
self.print_detail(cs, insn, ours)
|
101
|
+
cache = insn.address + insn.size
|
102
|
+
}
|
103
|
+
|
104
|
+
cs.close
|
105
|
+
ours.printf("0x%x:\n", cache)
|
106
|
+
ours.puts
|
107
|
+
end
|
108
|
+
|
109
|
+
ours.rewind
|
110
|
+
theirs = File.binread(__FILE__ + ".SPEC")
|
111
|
+
if ours.read == theirs
|
112
|
+
puts "#{__FILE__}: PASS"
|
113
|
+
else
|
114
|
+
ours.rewind
|
115
|
+
puts ours.read
|
116
|
+
puts "#{__FILE__}: FAIL"
|
117
|
+
end
|
118
|
+
end
|