crabstone 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/test/test_arm.rb
ADDED
@@ -0,0 +1,202 @@
|
|
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 TestARM
|
12
|
+
|
13
|
+
include Crabstone
|
14
|
+
include Crabstone::ARM
|
15
|
+
|
16
|
+
ARM_CODE = "\xED\xFF\xFF\xEB\x04\xe0\x2d\xe5\x00\x00\x00\x00\xe0\x83\x22\xe5\xf1\x02\x03\x0e\x00\x00\xa0\xe3\x02\x30\xc1\xe7\x00\x00\x53\xe3\x00\x02\x01\xf1\x05\x40\xd0\xe8\xf4\x80\x00\x00"
|
17
|
+
ARM_CODE2 = "\xd1\xe8\x00\xf0\xf0\x24\x04\x07\x1f\x3c\xf2\xc0\x00\x00\x4f\xf0\x00\x01\x46\x6c"
|
18
|
+
THUMB_CODE = "\x70\x47\xeb\x46\x83\xb0\xc9\x68\x1f\xb1\x30\xbf\xaf\xf3\x20\x84"
|
19
|
+
THUMB_CODE2 = "\x4f\xf0\x00\x01\xbd\xe8\x00\x88\xd1\xe8\x00\xf0\x18\xbf\xad\xbf\xf3\xff\x0b\x0c\x86\xf3\x00\x89\x80\xf3\x00\x8c\x4f\xfa\x99\xf6\xd0\xff\xa2\x01"
|
20
|
+
THUMB_MCLASS = "\xef\xf3\x02\x80"
|
21
|
+
ARMV8 = "\xe0\x3b\xb2\xee\x42\x00\x01\xe1\x51\xf0\x7f\xf5"
|
22
|
+
|
23
|
+
@platforms = [
|
24
|
+
Hash[
|
25
|
+
'arch' => ARCH_ARM,
|
26
|
+
'mode' => MODE_ARM,
|
27
|
+
'code' => ARM_CODE,
|
28
|
+
'comment' => "ARM"
|
29
|
+
],
|
30
|
+
Hash[
|
31
|
+
'arch' => ARCH_ARM,
|
32
|
+
'mode' => MODE_THUMB,
|
33
|
+
'code' => THUMB_CODE,
|
34
|
+
'comment' => "Thumb"
|
35
|
+
],
|
36
|
+
Hash[
|
37
|
+
'arch' => ARCH_ARM,
|
38
|
+
'mode' => MODE_THUMB,
|
39
|
+
'code' => ARM_CODE2,
|
40
|
+
'comment' => "Thumb-mixed"
|
41
|
+
],
|
42
|
+
Hash[
|
43
|
+
'arch' => ARCH_ARM,
|
44
|
+
'mode' => MODE_THUMB,
|
45
|
+
'code' => THUMB_CODE2,
|
46
|
+
'comment' => "Thumb-2 & register named with numbers",
|
47
|
+
'syntax' => :no_regname
|
48
|
+
],
|
49
|
+
Hash[
|
50
|
+
'arch' => ARCH_ARM,
|
51
|
+
'mode' => MODE_THUMB + MODE_MCLASS,
|
52
|
+
'code' => THUMB_MCLASS,
|
53
|
+
'comment' => "Thumb-MClass",
|
54
|
+
'syntax' => :no_regname
|
55
|
+
],
|
56
|
+
Hash[
|
57
|
+
'arch' => ARCH_ARM,
|
58
|
+
'mode' => MODE_ARM + MODE_V8,
|
59
|
+
'code' => ARMV8,
|
60
|
+
'comment' => "Arm-V8",
|
61
|
+
'syntax' => :no_regname
|
62
|
+
],
|
63
|
+
]
|
64
|
+
|
65
|
+
def self.uint32 i
|
66
|
+
Integer(i) & 0xffffffff
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.uint64 i
|
70
|
+
Integer(i) & ((1<<64)-1)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.print_detail(cs, i, sio)
|
74
|
+
|
75
|
+
# Sanity checks for register equivalency (string, const or numeric literal)
|
76
|
+
if i.reads_reg?( 'sp' ) || i.reads_reg?( 12 ) || i.reads_reg?( REG_SP )
|
77
|
+
unless i.reads_reg?( 'sp' ) && i.reads_reg?( 12 ) && i.reads_reg?( REG_SP )
|
78
|
+
fail "Error in reg read decomposition"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
if i.writes_reg?( 'lr' ) || i.writes_reg?( 10 ) || i.writes_reg?( REG_LR )
|
82
|
+
unless i.writes_reg?( 'lr' ) && i.writes_reg?( 10 ) && i.writes_reg?( REG_LR )
|
83
|
+
fail "Error in reg write decomposition"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
if i.op_count > 0 then
|
88
|
+
sio.puts "\top_count: #{i.op_count}"
|
89
|
+
i.operands.each.with_index do |op,idx|
|
90
|
+
|
91
|
+
case op[:type]
|
92
|
+
when OP_REG
|
93
|
+
sio.puts "\t\toperands[#{idx}].type: REG = #{cs.reg_name(op[:value][:reg])}"
|
94
|
+
when OP_IMM
|
95
|
+
sio.puts "\t\toperands[#{idx}].type: IMM = 0x#{self.uint64(op.value).to_s(16)}"
|
96
|
+
when OP_FP
|
97
|
+
sio.puts "\t\toperands[#{idx}].type: FP = 0x#{self.uint32(op[:value][:fp])}"
|
98
|
+
when OP_CIMM
|
99
|
+
sio.puts "\t\toperands[#{idx}].type: C-IMM = #{self.uint32(op[:value][:imm])}"
|
100
|
+
when OP_PIMM
|
101
|
+
sio.puts "\t\toperands[#{idx}].type: P-IMM = #{self.uint32(op[:value][:imm])}"
|
102
|
+
when OP_SETEND
|
103
|
+
if op.value == SETEND_BE
|
104
|
+
sio.puts "\t\toperands[#{idx}].type: SETEND = be"
|
105
|
+
else
|
106
|
+
sio.puts "\t\toperands[#{idx}].type: SETEND = le"
|
107
|
+
end
|
108
|
+
when OP_SYSREG
|
109
|
+
sio.puts "\t\toperands[#{idx}].type: SYSREG = #{op.value}"
|
110
|
+
when OP_MEM
|
111
|
+
sio.puts "\t\toperands[#{idx}].type: MEM"
|
112
|
+
if op[:value][:mem][:base] != 0 then
|
113
|
+
sio.puts "\t\t\toperands[#{idx}].mem.base: REG = %s" % cs.reg_name(op.value[:base])
|
114
|
+
end
|
115
|
+
if op[:value][:mem][:index] != 0 then
|
116
|
+
sio.puts "\t\t\toperands[#{idx}].mem.index: REG = %s" % cs.reg_name(op.value[:index])
|
117
|
+
end
|
118
|
+
if op[:value][:mem][:scale] != 1 then
|
119
|
+
sio.puts "\t\t\toperands[#{idx}].mem.scale = %u" % op[:value][:mem][:scale]
|
120
|
+
end
|
121
|
+
if op[:value][:mem][:disp] != 0 then
|
122
|
+
sio.puts "\t\t\toperands[#{idx}].mem.disp: 0x#{self.uint32(op.value[:disp]).to_s(16)}"
|
123
|
+
end
|
124
|
+
else
|
125
|
+
# unknown type - test will fail anyway
|
126
|
+
end
|
127
|
+
|
128
|
+
if op[:shift][:type].nonzero? && op[:shift][:value]
|
129
|
+
sio.puts "\t\t\tShift: #{op[:shift][:type]} = #{op[:shift][:value]}"
|
130
|
+
end
|
131
|
+
|
132
|
+
if op[:vector_index] != -1
|
133
|
+
sio.puts "\t\toperands[#{idx}].vector_index = #{op[:vector_index]}"
|
134
|
+
end
|
135
|
+
|
136
|
+
if op[:subtracted]
|
137
|
+
sio.puts "\t\tSubtracted: True\n"
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
if not [CC_AL, CC_INVALID].include? i.cc
|
144
|
+
sio.puts "\tCode condition: #{i.cc}"
|
145
|
+
end
|
146
|
+
sio.puts "\tUpdate-flags: True" if i.update_flags
|
147
|
+
sio.puts "\tWrite-back: True" if i.writeback
|
148
|
+
sio.puts "\tCPSI-mode: #{i.cps_mode}" if i.cps_mode.nonzero?
|
149
|
+
sio.puts "\tCPSI-flag: #{i.cps_flag}" if i.cps_flag.nonzero?
|
150
|
+
sio.puts "\tVector-data: #{i.vector_data}" if i.vector_data.nonzero?
|
151
|
+
sio.puts "\tVector-size: #{i.vector_size}" if i.vector_size.nonzero?
|
152
|
+
sio.puts "\tUser-mode: True" if i.usermode
|
153
|
+
sio.puts "\tMemory-barrier: #{i.mem_barrier}" if i.mem_barrier.nonzero?
|
154
|
+
|
155
|
+
sio.puts
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
ours = StringIO.new
|
160
|
+
|
161
|
+
begin
|
162
|
+
cs = Disassembler.new(0,0)
|
163
|
+
print "ARM Test: Capstone v #{cs.version.join('.')} - "
|
164
|
+
ensure
|
165
|
+
cs.close
|
166
|
+
end
|
167
|
+
|
168
|
+
#Test through all modes and architectures
|
169
|
+
@platforms.each do |p|
|
170
|
+
ours.puts "****************"
|
171
|
+
ours.puts "Platform: #{p['comment']}"
|
172
|
+
ours.puts "Code:#{p['code'].bytes.map {|b| "0x%.2x" % b}.join(' ')} "
|
173
|
+
ours.puts "Disasm:"
|
174
|
+
cs = Disassembler.new(p['arch'], p['mode'])
|
175
|
+
|
176
|
+
if p['syntax']
|
177
|
+
cs.syntax = p['syntax']
|
178
|
+
end
|
179
|
+
|
180
|
+
cs.decomposer = true
|
181
|
+
cache = nil
|
182
|
+
cs.disasm(p['code'], 0x1000).each {|insn|
|
183
|
+
ours.puts "0x#{insn.address.to_s(16)}:\t#{insn.mnemonic}\t#{insn.op_str}"
|
184
|
+
self.print_detail(cs, insn, ours)
|
185
|
+
cache = insn.address + insn.size
|
186
|
+
}
|
187
|
+
ours.printf("0x%x:\n", cache)
|
188
|
+
ours.puts
|
189
|
+
|
190
|
+
cs.close
|
191
|
+
end
|
192
|
+
|
193
|
+
ours.rewind
|
194
|
+
theirs = File.binread(__FILE__ + ".SPEC")
|
195
|
+
if ours.read == theirs
|
196
|
+
puts "#{__FILE__}: PASS"
|
197
|
+
else
|
198
|
+
ours.rewind
|
199
|
+
puts ours.read
|
200
|
+
puts "#{__FILE__}: FAIL"
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,275 @@
|
|
1
|
+
****************
|
2
|
+
Platform: ARM
|
3
|
+
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 0x00 0x02 0x01 0xf1 0x05 0x40 0xd0 0xe8 0xf4 0x80 0x00 0x00
|
4
|
+
Disasm:
|
5
|
+
0x1000: bl #0xfbc
|
6
|
+
op_count: 1
|
7
|
+
operands[0].type: IMM = 0xfbc
|
8
|
+
|
9
|
+
0x1004: str lr, [sp, #-4]!
|
10
|
+
op_count: 2
|
11
|
+
operands[0].type: REG = lr
|
12
|
+
operands[1].type: MEM
|
13
|
+
operands[1].mem.base: REG = sp
|
14
|
+
operands[1].mem.disp: 0xfffffffc
|
15
|
+
Write-back: True
|
16
|
+
|
17
|
+
0x1008: andeq r0, r0, r0
|
18
|
+
op_count: 3
|
19
|
+
operands[0].type: REG = r0
|
20
|
+
operands[1].type: REG = r0
|
21
|
+
operands[2].type: REG = r0
|
22
|
+
Code condition: 1
|
23
|
+
|
24
|
+
0x100c: str r8, [r2, #-0x3e0]!
|
25
|
+
op_count: 2
|
26
|
+
operands[0].type: REG = r8
|
27
|
+
operands[1].type: MEM
|
28
|
+
operands[1].mem.base: REG = r2
|
29
|
+
operands[1].mem.disp: 0xfffffc20
|
30
|
+
Write-back: True
|
31
|
+
|
32
|
+
0x1010: mcreq p2, #0, r0, c3, c1, #7
|
33
|
+
op_count: 6
|
34
|
+
operands[0].type: P-IMM = 2
|
35
|
+
operands[1].type: IMM = 0x0
|
36
|
+
operands[2].type: REG = r0
|
37
|
+
operands[3].type: C-IMM = 3
|
38
|
+
operands[4].type: C-IMM = 1
|
39
|
+
operands[5].type: IMM = 0x7
|
40
|
+
Code condition: 1
|
41
|
+
|
42
|
+
0x1014: mov r0, #0
|
43
|
+
op_count: 2
|
44
|
+
operands[0].type: REG = r0
|
45
|
+
operands[1].type: IMM = 0x0
|
46
|
+
|
47
|
+
0x1018: strb r3, [r1, r2]
|
48
|
+
op_count: 2
|
49
|
+
operands[0].type: REG = r3
|
50
|
+
operands[1].type: MEM
|
51
|
+
operands[1].mem.base: REG = r1
|
52
|
+
operands[1].mem.index: REG = r2
|
53
|
+
|
54
|
+
0x101c: cmp r3, #0
|
55
|
+
op_count: 2
|
56
|
+
operands[0].type: REG = r3
|
57
|
+
operands[1].type: IMM = 0x0
|
58
|
+
Update-flags: True
|
59
|
+
|
60
|
+
0x1020: setend be
|
61
|
+
op_count: 1
|
62
|
+
operands[0].type: SETEND = be
|
63
|
+
|
64
|
+
0x1024: ldm r0, {r0, r2, lr} ^
|
65
|
+
op_count: 4
|
66
|
+
operands[0].type: REG = r0
|
67
|
+
operands[1].type: REG = r0
|
68
|
+
operands[2].type: REG = r2
|
69
|
+
operands[3].type: REG = lr
|
70
|
+
User-mode: True
|
71
|
+
|
72
|
+
0x1028: strdeq r8, sb, [r0], -r4
|
73
|
+
op_count: 4
|
74
|
+
operands[0].type: REG = r8
|
75
|
+
operands[1].type: REG = sb
|
76
|
+
operands[2].type: MEM
|
77
|
+
operands[2].mem.base: REG = r0
|
78
|
+
operands[3].type: REG = r4
|
79
|
+
Subtracted: True
|
80
|
+
Code condition: 1
|
81
|
+
Write-back: True
|
82
|
+
|
83
|
+
0x102c:
|
84
|
+
|
85
|
+
****************
|
86
|
+
Platform: Thumb
|
87
|
+
Code:0x70 0x47 0xeb 0x46 0x83 0xb0 0xc9 0x68 0x1f 0xb1 0x30 0xbf 0xaf 0xf3 0x20 0x84
|
88
|
+
Disasm:
|
89
|
+
0x1000: bx lr
|
90
|
+
op_count: 1
|
91
|
+
operands[0].type: REG = lr
|
92
|
+
|
93
|
+
0x1002: mov fp, sp
|
94
|
+
op_count: 2
|
95
|
+
operands[0].type: REG = fp
|
96
|
+
operands[1].type: REG = sp
|
97
|
+
|
98
|
+
0x1004: sub sp, #0xc
|
99
|
+
op_count: 2
|
100
|
+
operands[0].type: REG = sp
|
101
|
+
operands[1].type: IMM = 0xc
|
102
|
+
|
103
|
+
0x1006: ldr r1, [r1, #0xc]
|
104
|
+
op_count: 2
|
105
|
+
operands[0].type: REG = r1
|
106
|
+
operands[1].type: MEM
|
107
|
+
operands[1].mem.base: REG = r1
|
108
|
+
operands[1].mem.disp: 0xc
|
109
|
+
|
110
|
+
0x1008: cbz r7, #0x1012
|
111
|
+
op_count: 2
|
112
|
+
operands[0].type: REG = r7
|
113
|
+
operands[1].type: IMM = 0x1012
|
114
|
+
|
115
|
+
0x100a: wfi
|
116
|
+
|
117
|
+
0x100c: cpsie.w f
|
118
|
+
CPSI-mode: 2
|
119
|
+
CPSI-flag: 1
|
120
|
+
|
121
|
+
0x1010:
|
122
|
+
|
123
|
+
****************
|
124
|
+
Platform: Thumb-mixed
|
125
|
+
Code:0xd1 0xe8 0x00 0xf0 0xf0 0x24 0x04 0x07 0x1f 0x3c 0xf2 0xc0 0x00 0x00 0x4f 0xf0 0x00 0x01 0x46 0x6c
|
126
|
+
Disasm:
|
127
|
+
0x1000: tbb [r1, r0]
|
128
|
+
op_count: 1
|
129
|
+
operands[0].type: MEM
|
130
|
+
operands[0].mem.base: REG = r1
|
131
|
+
operands[0].mem.index: REG = r0
|
132
|
+
|
133
|
+
0x1004: movs r4, #0xf0
|
134
|
+
op_count: 2
|
135
|
+
operands[0].type: REG = r4
|
136
|
+
operands[1].type: IMM = 0xf0
|
137
|
+
Update-flags: True
|
138
|
+
|
139
|
+
0x1006: lsls r4, r0, #0x1c
|
140
|
+
op_count: 3
|
141
|
+
operands[0].type: REG = r4
|
142
|
+
operands[1].type: REG = r0
|
143
|
+
operands[2].type: IMM = 0x1c
|
144
|
+
Update-flags: True
|
145
|
+
|
146
|
+
0x1008: subs r4, #0x1f
|
147
|
+
op_count: 2
|
148
|
+
operands[0].type: REG = r4
|
149
|
+
operands[1].type: IMM = 0x1f
|
150
|
+
Update-flags: True
|
151
|
+
|
152
|
+
0x100a: stm r0!, {r1, r4, r5, r6, r7}
|
153
|
+
op_count: 6
|
154
|
+
operands[0].type: REG = r0
|
155
|
+
operands[1].type: REG = r1
|
156
|
+
operands[2].type: REG = r4
|
157
|
+
operands[3].type: REG = r5
|
158
|
+
operands[4].type: REG = r6
|
159
|
+
operands[5].type: REG = r7
|
160
|
+
Write-back: True
|
161
|
+
|
162
|
+
0x100c: movs r0, r0
|
163
|
+
op_count: 2
|
164
|
+
operands[0].type: REG = r0
|
165
|
+
operands[1].type: REG = r0
|
166
|
+
Update-flags: True
|
167
|
+
|
168
|
+
0x100e: mov.w r1, #0
|
169
|
+
op_count: 2
|
170
|
+
operands[0].type: REG = r1
|
171
|
+
operands[1].type: IMM = 0x0
|
172
|
+
|
173
|
+
0x1012: ldr r6, [r0, #0x44]
|
174
|
+
op_count: 2
|
175
|
+
operands[0].type: REG = r6
|
176
|
+
operands[1].type: MEM
|
177
|
+
operands[1].mem.base: REG = r0
|
178
|
+
operands[1].mem.disp: 0x44
|
179
|
+
|
180
|
+
0x1014:
|
181
|
+
|
182
|
+
****************
|
183
|
+
Platform: Thumb-2 & register named with numbers
|
184
|
+
Code:0x4f 0xf0 0x00 0x01 0xbd 0xe8 0x00 0x88 0xd1 0xe8 0x00 0xf0 0x18 0xbf 0xad 0xbf 0xf3 0xff 0x0b 0x0c 0x86 0xf3 0x00 0x89 0x80 0xf3 0x00 0x8c 0x4f 0xfa 0x99 0xf6 0xd0 0xff 0xa2 0x01
|
185
|
+
Disasm:
|
186
|
+
0x1000: mov.w r1, #0
|
187
|
+
op_count: 2
|
188
|
+
operands[0].type: REG = r1
|
189
|
+
operands[1].type: IMM = 0x0
|
190
|
+
|
191
|
+
0x1004: pop.w {r11, pc}
|
192
|
+
op_count: 2
|
193
|
+
operands[0].type: REG = r11
|
194
|
+
operands[1].type: REG = pc
|
195
|
+
|
196
|
+
0x1008: tbb [r1, r0]
|
197
|
+
op_count: 1
|
198
|
+
operands[0].type: MEM
|
199
|
+
operands[0].mem.base: REG = r1
|
200
|
+
operands[0].mem.index: REG = r0
|
201
|
+
|
202
|
+
0x100c: it ne
|
203
|
+
Code condition: 2
|
204
|
+
|
205
|
+
0x100e: iteet ge
|
206
|
+
Code condition: 11
|
207
|
+
|
208
|
+
0x1010: vdupge.8 d16, d11[1]
|
209
|
+
op_count: 2
|
210
|
+
operands[0].type: REG = d16
|
211
|
+
operands[1].type: REG = d11
|
212
|
+
operands[1].vector_index = 1
|
213
|
+
Code condition: 11
|
214
|
+
Vector-size: 8
|
215
|
+
|
216
|
+
0x1014: msrlt cpsr_fc, r6
|
217
|
+
op_count: 2
|
218
|
+
operands[0].type: SYSREG = 144
|
219
|
+
operands[1].type: REG = r6
|
220
|
+
Code condition: 12
|
221
|
+
|
222
|
+
0x1018: msrlt apsr_nzcvqg, r0
|
223
|
+
op_count: 2
|
224
|
+
operands[0].type: SYSREG = 259
|
225
|
+
operands[1].type: REG = r0
|
226
|
+
Code condition: 12
|
227
|
+
|
228
|
+
0x101c: sxtbge.w r6, r9, ror #8
|
229
|
+
op_count: 2
|
230
|
+
operands[0].type: REG = r6
|
231
|
+
operands[1].type: REG = r9
|
232
|
+
Shift: 4 = 8
|
233
|
+
Code condition: 11
|
234
|
+
|
235
|
+
0x1020: vaddw.u16 q8, q8, d18
|
236
|
+
op_count: 3
|
237
|
+
operands[0].type: REG = q8
|
238
|
+
operands[1].type: REG = q8
|
239
|
+
operands[2].type: REG = d18
|
240
|
+
Vector-data: 10
|
241
|
+
|
242
|
+
0x1024:
|
243
|
+
|
244
|
+
****************
|
245
|
+
Platform: Thumb-MClass
|
246
|
+
Code:0xef 0xf3 0x02 0x80
|
247
|
+
Disasm:
|
248
|
+
0x1000: mrs r0, eapsr
|
249
|
+
op_count: 2
|
250
|
+
operands[0].type: REG = r0
|
251
|
+
operands[1].type: SYSREG = 263
|
252
|
+
|
253
|
+
0x1004:
|
254
|
+
|
255
|
+
****************
|
256
|
+
Platform: Arm-V8
|
257
|
+
Code:0xe0 0x3b 0xb2 0xee 0x42 0x00 0x01 0xe1 0x51 0xf0 0x7f 0xf5
|
258
|
+
Disasm:
|
259
|
+
0x1000: vcvtt.f64.f16 d3, s1
|
260
|
+
op_count: 2
|
261
|
+
operands[0].type: REG = d3
|
262
|
+
operands[1].type: REG = s1
|
263
|
+
Vector-data: 17
|
264
|
+
|
265
|
+
0x1004: crc32b r0, r1, r2
|
266
|
+
op_count: 3
|
267
|
+
operands[0].type: REG = r0
|
268
|
+
operands[1].type: REG = r1
|
269
|
+
operands[2].type: REG = r2
|
270
|
+
|
271
|
+
0x1008: dmb oshld
|
272
|
+
Memory-barrier: 2
|
273
|
+
|
274
|
+
0x100c:
|
275
|
+
|