modifiers.s
7.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
; RUN: llvm-mc -triple avr -show-encoding < %s | FileCheck %s
; TODO: Add support for lo8(-foo + 3), and add test
; FIXME: most of these tests use values (i.e. 0x0815) that are out of bounds.
foo:
ldi r24, lo8(0x42)
ldi r24, lo8(0x2342)
ldi r24, lo8(0x23)
ldi r24, hi8(0x2342)
; CHECK: ldi r24, lo8(66) ; encoding: [0x82,0xe4]
; CHECK: ldi r24, lo8(9026) ; encoding: [0x82,0xe4]
; CHECK: ldi r24, lo8(35) ; encoding: [0x83,0xe2]
; CHECK: ldi r24, hi8(9026) ; encoding: [0x83,0xe2]
bar:
ldi r24, lo8(bar)
ldi r24, hi8(bar)
; CHECK: ldi r24, lo8(bar) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: lo8(bar), kind: fixup_lo8_ldi
; CHECK: ldi r24, hi8(bar) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: hi8(bar), kind: fixup_hi8_ldi
lo8:
ldi r24, lo8(0x0815)
ldi r24, lo8(foo)
ldi r24, lo8(bar + 5)
; CHECK: ldi r24, lo8(2069) ; encoding: [0x85,0xe1]
; CHECK: ldi r24, lo8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: lo8(foo), kind: fixup_lo8_ldi
; CHECK: ldi r24, lo8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: lo8(bar+5), kind: fixup_lo8_ldi
lo8_neg:
ldi r24, -lo8(123456)
ldi r24, -lo8(foo)
; CHECK: ldi r24, -lo8(123456) ; encoding: [0x80,0xec]
; CHECK: ldi r24, -lo8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -lo8(foo), kind: fixup_lo8_ldi_neg
hi8:
ldi r24, hi8(0x0815)
ldi r24, hi8(foo)
ldi r24, hi8(bar + 5)
; CHECK: ldi r24, hi8(2069) ; encoding: [0x88,0xe0]
; CHECK: ldi r24, hi8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: hi8(foo), kind: fixup_hi8_ldi
; CHECK: ldi r24, hi8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: hi8(bar+5), kind: fixup_hi8_ldi
hi8_neg:
ldi r24, -hi8(123456)
ldi r24, -hi8(foo)
; CHECK: ldi r24, -hi8(123456) ; encoding: [0x8d,0xe1]
; CHECK: ldi r24, -hi8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -hi8(foo), kind: fixup_hi8_ldi_neg
hh8:
ldi r24, hh8(0x0815)
ldi r24, hh8(foo)
ldi r24, hh8(bar + 5)
; CHECK: ldi r24, hh8(2069) ; encoding: [0x80,0xe0]
; CHECK: ldi r24, hh8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: hh8(foo), kind: fixup_hh8_ldi
; CHECK: ldi r24, hh8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: hh8(bar+5), kind: fixup_hh8_ldi
hh8_neg:
ldi r24, -hh8(123456)
ldi r24, -hh8(foo)
; CHECK: ldi r24, -hh8(123456) ; encoding: [0x8e,0xef]
; CHECK: ldi r24, -hh8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -hh8(foo), kind: fixup_hh8_ldi_neg
hlo8: ; synonym with hh8() above, hence the... odd results
ldi r24, hlo8(0x0815)
ldi r24, hlo8(foo)
ldi r24, hlo8(bar + 5)
; CHECK: ldi r24, hh8(2069) ; encoding: [0x80,0xe0]
; CHECK: ldi r24, hh8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: hh8(foo), kind: fixup_hh8_ldi
; CHECK: ldi r24, hh8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: hh8(bar+5), kind: fixup_hh8_ldi
hlo8_neg:
ldi r24, -hlo8(123456)
ldi r24, -hlo8(foo)
; CHECK: ldi r24, -hh8(123456) ; encoding: [0x8e,0xef]
; CHECK: ldi r24, -hh8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -hh8(foo), kind: fixup_hh8_ldi_neg
hhi8:
ldi r24, hhi8(0x0815)
ldi r24, hhi8(foo)
ldi r24, hhi8(bar + 5)
; CHECK: ldi r24, hhi8(2069) ; encoding: [0x80,0xe0]
; CHECK: ldi r24, hhi8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: hhi8(foo), kind: fixup_ms8_ldi
; CHECK: ldi r24, hhi8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: hhi8(bar+5), kind: fixup_ms8_ldi
hhi8_neg:
ldi r24, -hhi8(123456)
ldi r24, -hhi8(foo)
; CHECK: ldi r24, -hhi8(123456) ; encoding: [0x8f,0xef]
; CHECK: ldi r24, -hhi8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -hhi8(foo), kind: fixup_ms8_ldi_neg
pm_lo8:
ldi r24, pm_lo8(0x0815)
ldi r24, pm_lo8(foo)
ldi r24, pm_lo8(bar + 5)
; CHECK: ldi r24, pm_lo8(2069) ; encoding: [0x8a,0xe0]
; CHECK: ldi r24, pm_lo8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: pm_lo8(foo), kind: fixup_lo8_ldi_pm
; CHECK: ldi r24, pm_lo8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: pm_lo8(bar+5), kind: fixup_lo8_ldi_pm
pm_hi8:
ldi r24, pm_hi8(0x0815)
ldi r24, pm_hi8(foo)
ldi r24, pm_hi8(bar + 5)
; CHECK: ldi r24, pm_hi8(2069) ; encoding: [0x84,0xe0]
; CHECK: ldi r24, pm_hi8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: pm_hi8(foo), kind: fixup_hi8_ldi_pm
; CHECK: ldi r24, pm_hi8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: pm_hi8(bar+5), kind: fixup_hi8_ldi_pm
pm_hh8:
ldi r24, pm_hh8(0x0815)
ldi r24, pm_hh8(foo)
ldi r24, pm_hh8(bar + 5)
; CHECK: ldi r24, pm_hh8(2069) ; encoding: [0x80,0xe0]
; CHECK: ldi r24, pm_hh8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: pm_hh8(foo), kind: fixup_hh8_ldi_pm
; CHECK: ldi r24, pm_hh8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: pm_hh8(bar+5), kind: fixup_hh8_ldi_pm
pm_lo8_neg:
ldi r24, -pm_lo8(0x0815)
ldi r24, -pm_lo8(foo)
ldi r24, -pm_lo8(bar + 5)
; CHECK: ldi r24, -pm_lo8(2069) ; encoding: [0x85,0xef]
; CHECK: ldi r24, -pm_lo8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -pm_lo8(foo), kind: fixup_lo8_ldi_pm_neg
; CHECK: ldi r24, -pm_lo8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -pm_lo8(bar+5), kind: fixup_lo8_ldi_pm_neg
pm_hi8_neg:
ldi r24, -pm_hi8(0x0815)
ldi r24, -pm_hi8(foo)
ldi r24, -pm_hi8(bar + 5)
; CHECK: ldi r24, -pm_hi8(2069) ; encoding: [0x8b,0xef]
; CHECK: ldi r24, -pm_hi8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -pm_hi8(foo), kind: fixup_hi8_ldi_pm_neg
; CHECK: ldi r24, -pm_hi8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -pm_hi8(bar+5), kind: fixup_hi8_ldi_pm_neg
pm_hh8_neg:
ldi r24, -pm_hh8(0x0815)
ldi r24, -pm_hh8(foo)
ldi r24, -pm_hh8(bar + 5)
; CHECK: ldi r24, -pm_hh8(2069) ; encoding: [0x8f,0xef]
; CHECK: ldi r24, -pm_hh8(foo) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -pm_hh8(foo), kind: fixup_hh8_ldi_pm_neg
; CHECK: ldi r24, -pm_hh8(bar+5) ; encoding: [0x80'A',0xe0]
; CHECK: ; fixup A - offset: 0, value: -pm_hh8(bar+5), kind: fixup_hh8_ldi_pm_neg