aarch64 2.0.1 → 2.0.2
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 +4 -4
- data/lib/aarch64/version.rb +1 -1
- data/lib/aarch64.rb +23 -2
- data/test/base_instructions_test.rb +24 -0
- data/test/dsl_test.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4148547f29912a9cea29d06ba88ebafff8ffd701b187ab9aa3a0b4ee1d309b0
|
4
|
+
data.tar.gz: dc7b08ee7be2e57acfb2d5181d374a9baf6806be65dee0318cd95417349a2cfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f215a62f40c5ad36e81ec7d1d1110e21639ab0b19950283f4b5dbde46e5b26c17081a527d41dca600c4a8e8aa07eb0fc5f1f21a68d4425084c5eaf94de8baaef
|
7
|
+
data.tar.gz: 4d0027eeb4a45b5d77e409b2fc343d59ec19548b4874f1c2e61bfeabcecb991ee2527a0969133f1029aa13e2623361bef3e6637ed65f9617001f5709ab31b99a
|
data/lib/aarch64/version.rb
CHANGED
data/lib/aarch64.rb
CHANGED
@@ -10,6 +10,7 @@ module AArch64
|
|
10
10
|
alias sp? sp
|
11
11
|
alias zr? zr
|
12
12
|
def integer?; false; end
|
13
|
+
def register?; true; end
|
13
14
|
end
|
14
15
|
|
15
16
|
class XRegister < Register
|
@@ -22,6 +23,7 @@ module AArch64
|
|
22
23
|
def opc; 0b10; end
|
23
24
|
def opc2; 0b11; end
|
24
25
|
def opc3; 0b10; end
|
26
|
+
def name; "X#{to_i}"; end
|
25
27
|
end
|
26
28
|
|
27
29
|
class WRegister < Register
|
@@ -34,6 +36,7 @@ module AArch64
|
|
34
36
|
def opc; 0b11; end
|
35
37
|
def opc2; 0b10; end
|
36
38
|
def opc3; 0b00; end
|
39
|
+
def name; "W#{to_i}"; end
|
37
40
|
end
|
38
41
|
|
39
42
|
31.times { |i|
|
@@ -2715,14 +2718,26 @@ module AArch64
|
|
2715
2718
|
if label.integer?
|
2716
2719
|
label = wrap_offset_with_label label
|
2717
2720
|
end
|
2718
|
-
|
2721
|
+
|
2722
|
+
sf = 0
|
2723
|
+
if imm > 31
|
2724
|
+
sf = 1
|
2725
|
+
imm -= 32
|
2726
|
+
end
|
2727
|
+
a TBNZ.new(rt, imm, label, sf)
|
2719
2728
|
end
|
2720
2729
|
|
2721
2730
|
def tbz rt, imm, label
|
2722
2731
|
if label.integer?
|
2723
2732
|
label = wrap_offset_with_label label
|
2724
2733
|
end
|
2725
|
-
|
2734
|
+
|
2735
|
+
sf = 0
|
2736
|
+
if imm > 31
|
2737
|
+
sf = 1
|
2738
|
+
imm -= 32
|
2739
|
+
end
|
2740
|
+
a TBZ.new(rt, imm, label, sf)
|
2726
2741
|
end
|
2727
2742
|
|
2728
2743
|
def tlbi tlbi_op, xt = XZR
|
@@ -2827,6 +2842,12 @@ module AArch64
|
|
2827
2842
|
a YIELD.new
|
2828
2843
|
end
|
2829
2844
|
|
2845
|
+
##
|
2846
|
+
# Yields the offset in the instructions
|
2847
|
+
def patch_location
|
2848
|
+
yield @insns.length * 4
|
2849
|
+
end
|
2850
|
+
|
2830
2851
|
def write_to io
|
2831
2852
|
io.write to_binary
|
2832
2853
|
end
|
@@ -2774,6 +2774,12 @@ class BaseInstructionsTest < AArch64::Test
|
|
2774
2774
|
end
|
2775
2775
|
end
|
2776
2776
|
|
2777
|
+
def test_ldb_x30
|
2778
|
+
assert_bytes [0xfe,0x7b,0xc1,0xa8] do |asm|
|
2779
|
+
asm.ldp x30, x30, [sp], 16
|
2780
|
+
end
|
2781
|
+
end
|
2782
|
+
|
2777
2783
|
def test_LDP_gen
|
2778
2784
|
# LDP <Wt1>, <Wt2>, [<Xn|SP>], #<imm>
|
2779
2785
|
# LDP <Xt1>, <Xt2>, [<Xn|SP>], #<imm>
|
@@ -8866,6 +8872,18 @@ class BaseInstructionsTest < AArch64::Test
|
|
8866
8872
|
asm.tbnz w3, 5, label
|
8867
8873
|
asm.put_label label
|
8868
8874
|
end
|
8875
|
+
|
8876
|
+
assert_one_insn "tbnz x0, #0x20, #4" do |asm|
|
8877
|
+
label = asm.make_label :foo
|
8878
|
+
asm.tbnz x0, 32, label
|
8879
|
+
asm.put_label label
|
8880
|
+
end
|
8881
|
+
|
8882
|
+
assert_one_insn "tbnz w0, #0, #4" do |asm|
|
8883
|
+
label = asm.make_label :foo
|
8884
|
+
asm.tbnz x0, 0, label
|
8885
|
+
asm.put_label label
|
8886
|
+
end
|
8869
8887
|
end
|
8870
8888
|
|
8871
8889
|
def test_TBZ
|
@@ -8878,6 +8896,12 @@ class BaseInstructionsTest < AArch64::Test
|
|
8878
8896
|
asm.tbz w3, 5, label
|
8879
8897
|
asm.put_label label
|
8880
8898
|
end
|
8899
|
+
|
8900
|
+
assert_one_insn "tbz x0, #0x20, #4" do |asm|
|
8901
|
+
label = asm.make_label :foo
|
8902
|
+
asm.tbz x0, 32, label
|
8903
|
+
asm.put_label label
|
8904
|
+
end
|
8881
8905
|
end
|
8882
8906
|
|
8883
8907
|
def test_TLBI_SYS
|
data/test/dsl_test.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
3
|
class DSLTest < AArch64::Test
|
4
|
+
def test_patch_location
|
5
|
+
asm = AArch64::Assembler.new
|
6
|
+
found = nil
|
7
|
+
asm.pretty do
|
8
|
+
asm.mov x0, x1
|
9
|
+
asm.patch_location { |loc| found = loc }
|
10
|
+
asm.movz x2, 5
|
11
|
+
end
|
12
|
+
|
13
|
+
bytes = asm.to_binary
|
14
|
+
assert_equal 8, bytes.bytesize
|
15
|
+
assert_equal 4, found
|
16
|
+
end
|
17
|
+
|
4
18
|
def test_dsl_has_methods
|
5
19
|
assert_bytes [0x9f,0x08,0x25,0xab] do |asm|
|
6
20
|
asm.pretty do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aarch64
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hatstone
|