Debian Codegraph @

Source/UnitTests/Common/AssemblerTest.cpp

raw symbols SCIP
1 // Copyright 2023 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include <gtest/gtest.h>
5
6 #include <string_view>
7 #include <vector>
8
9 #include "Common/Assembler/GekkoAssembler.h"
10
11 using namespace Common::GekkoAssembler;
12
13 constexpr char instructions[] = "add r3, r4, r5\n"
14 "add. r3, r4, r5\n"
15 "addo r3, r4, r5\n"
16 "addo. r3, r4, r5\n"
17 "addc r3, r4, r5\n"
18 "addc. r3, r4, r5\n"
19 "addco r3, r4, r5\n"
20 "addco. r3, r4, r5\n"
21 "adde r3, r4, r5\n"
22 "adde. r3, r4, r5\n"
23 "addeo r3, r4, r5\n"
24 "addeo. r3, r4, r5\n"
25 "addme r3, r4\n"
26 "addme. r3, r4\n"
27 "addmeo r3, r4\n"
28 "addmeo. r3, r4\n"
29 "addze r3, r4\n"
30 "addze. r3, r4\n"
31 "addzeo r3, r4\n"
32 "addzeo. r3, r4\n"
33 "divw r3, r4, r5\n"
34 "divw. r3, r4, r5\n"
35 "divwo r3, r4, r5\n"
36 "divwo. r3, r4, r5\n"
37 "divwu r3, r4, r5\n"
38 "divwu. r3, r4, r5\n"
39 "divwuo r3, r4, r5\n"
40 "divwuo. r3, r4, r5\n"
41 "mullw r3, r4, r5\n"
42 "mullw. r3, r4, r5\n"
43 "mullwo r3, r4, r5\n"
44 "mullwo. r3, r4, r5\n"
45 "neg r3, r4\n"
46 "neg. r3, r4\n"
47 "nego r3, r4\n"
48 "nego. r3, r4\n"
49 "subf r3, r4, r5\n"
50 "subf. r3, r4, r5\n"
51 "subfo r3, r4, r5\n"
52 "subfo. r3, r4, r5\n"
53 "subfc r3, r4, r5\n"
54 "subfc. r3, r4, r5\n"
55 "subfco r3, r4, r5\n"
56 "subfco. r3, r4, r5\n"
57 "subfe r3, r4, r5\n"
58 "subfe. r3, r4, r5\n"
59 "subfeo r3, r4, r5\n"
60 "subfeo. r3, r4, r5\n"
61 "subfme r3, r4\n"
62 "subfme. r3, r4\n"
63 "subfmeo r3, r4\n"
64 "subfmeo. r3, r4\n"
65 "subfze r3, r4\n"
66 "subfze. r3, r4\n"
67 "subfzeo r3, r4\n"
68 "subfzeo. r3, r4\n"
69 "addi r3, r4, 1000\n"
70 "addic r3, r4, 1000\n"
71 "addic. r3, r4, 1000\n"
72 "addis r3, r4, 1000\n"
73 "mulli r3, r4, 1000\n"
74 "subfic r3, r4, 1000\n"
75 "cmpi cr1, 0, r4, 1000\n"
76 "cmpli cr1, 0, r4, 1000\n"
77 "andi. r4, r6, 1000\n"
78 "andis. r4, r6, 1000\n"
79 "ori r4, r6, 1000\n"
80 "oris r4, r6, 1000\n"
81 "xori r4, r6, 1000\n"
82 "xoris r4, r6, 1000\n"
83 "lbz r3, 100(r4)\n"
84 "lbzu r3, 100( r4)\n"
85 "lha r3, 100( r4)\n"
86 "lhau r3, 100( r4)\n"
87 "lhz r3, 100( r4)\n"
88 "lhzu r3, 100( r4)\n"
89 "lwz r3, 100( r4)\n"
90 "lwzu r3, 100( r4)\n"
91 "stb r6, 100( r4)\n"
92 "stbu r6, 100( r4)\n"
93 "sth r6, 100( r4)\n"
94 "sthu r6, 100( r4)\n"
95 "stw r6, 100( r4)\n"
96 "stwu r6, 100( r4)\n"
97 "lmw r6, 100( r4)\n"
98 "stmw r6, 100( r4)\n"
99 "lfd r3, 100( r4)\n"
100 "lfdu r3, 100( r4)\n"
101 "lfs r3, 100( r4)\n"
102 "lfsu r3, 100( r4)\n"
103 "stfd r6, 100( r4)\n"
104 "stfdu r6, 100( r4)\n"
105 "stfs r6, 100( r4)\n"
106 "stfsu r6, 100( r4)\n"
107 "twi 8, r4, 1000\n"
108 "psq_l r3, 200( r4), 0, 2\n"
109 "psq_lu r3, 200( r4), 0, 2\n"
110 "psq_st r6, 200( r4), 0, 2\n"
111 "psq_stu r6, 200( r4), 0, 2\n"
112 "mulhw r3, r4, r5\n"
113 "mulhw. r3, r4, r5\n"
114 "mulhwu r3, r4, r5\n"
115 "mulhwu. r3, r4, r5\n"
116 "and r4, r6, r5\n"
117 "and. r4, r6, r5\n"
118 "andc r4, r6, r5\n"
119 "andc. r4, r6, r5\n"
120 "cntlzw r4, r6\n"
121 "cntlzw. r4, r6\n"
122 "eqv r4, r6, r5\n"
123 "eqv. r4, r6, r5\n"
124 "extsb r4, r6\n"
125 "extsb. r4, r6\n"
126 "extsh r4, r6\n"
127 "extsh. r4, r6\n"
128 "nand r4, r6, r5\n"
129 "nand. r4, r6, r5\n"
130 "nor r4, r6, r5\n"
131 "nor. r4, r6, r5\n"
132 "or r4, r6, r5\n"
133 "or. r4, r6, r5\n"
134 "orc r4, r6, r5\n"
135 "orc. r4, r6, r5\n"
136 "xor r4, r6, r5\n"
137 "xor. r4, r6, r5\n"
138 "rlwimi r4, r6, 0, 10, 15\n"
139 "rlwimi. r4, r6, 0, 10, 15\n"
140 "rlwinm r4, r6, 0, 10, 15\n"
141 "rlwinm. r4, r6, 0, 10, 15\n"
142 "rlwnm r4, r6, r5, 10, 15\n"
143 "rlwnm. r4, r6, r5, 10, 15\n"
144 "slw r4, r6, r5\n"
145 "slw. r4, r6, r5\n"
146 "sraw r4, r6, r5\n"
147 "sraw. r4, r6, r5\n"
148 "srawi r4, r6, 0\n"
149 "srawi. r4, r6, 0\n"
150 "srw r4, r6, r5\n"
151 "srw. r4, r6, r5\n"
152 "fadd r3, r4, r5\n"
153 "fadd. r3, r4, r5\n"
154 "fadds r3, r4, r5\n"
155 "fadds. r3, r4, r5\n"
156 "fdiv r3, r4, r5\n"
157 "fdiv. r3, r4, r5\n"
158 "fdivs r3, r4, r5\n"
159 "fdivs. r3, r4, r5\n"
160 "fmul r3, r4, r7\n"
161 "fmul. r3, r4, r7\n"
162 "fmuls r3, r4, r7\n"
163 "fmuls. r3, r4, r7\n"
164 "fres r3, r5\n"
165 "fres. r3, r5\n"
166 "frsqrte r3, r5\n"
167 "frsqrte. r3, r5\n"
168 "fsub r3, r4, r5\n"
169 "fsub. r3, r4, r5\n"
170 "fsubs r3, r4, r5\n"
171 "fsubs. r3, r4, r5\n"
172 "fsel r3, r4, r7, r5\n"
173 "fsel. r3, r4, r7, r5\n"
174 "fmadd r3, r4, r7, r5\n"
175 "fmadd. r3, r4, r7, r5\n"
176 "fmadds r3, r4, r7, r5\n"
177 "fmadds. r3, r4, r7, r5\n"
178 "fmsub r3, r4, r7, r5\n"
179 "fmsub. r3, r4, r7, r5\n"
180 "fmsubs r3, r4, r7, r5\n"
181 "fmsubs. r3, r4, r7, r5\n"
182 "fnmadd r3, r4, r7, r5\n"
183 "fnmadd. r3, r4, r7, r5\n"
184 "fnmadds r3, r4, r7, r5\n"
185 "fnmadds. r3, r4, r7, r5\n"
186 "fnmsub r3, r4, r7, r5\n"
187 "fnmsub. r3, r4, r7, r5\n"
188 "fnmsubs r3, r4, r7, r5\n"
189 "fnmsubs. r3, r4, r7, r5\n"
190 "fctiw r3, r5\n"
191 "fctiw. r3, r5\n"
192 "fctiwz r3, r5\n"
193 "fctiwz. r3, r5\n"
194 "frsp r3, r5\n"
195 "frsp. r3, r5\n"
196 "mffs r3\n"
197 "mffs. r3\n"
198 "mtfsb0 21\n"
199 "mtfsb0. 21\n"
200 "mtfsb1 21\n"
201 "mtfsb1. 21\n"
202 "mtfsf 255, r5\n"
203 "mtfsf. 255, r5\n"
204 "mtfsfi cr1, 5\n"
205 "mtfsfi. cr1, 5\n"
206 "fabs r3, r5\n"
207 "fabs. r3, r5\n"
208 "fmr r3, r5\n"
209 "fmr. r3, r5\n"
210 "fnabs r3, r5\n"
211 "fnabs. r3, r5\n"
212 "fneg r3, r5\n"
213 "fneg. r3, r5\n"
214 "ps_div r3, r4, r5\n"
215 "ps_div. r3, r4, r5\n"
216 "ps_sub r3, r4, r5\n"
217 "ps_sub. r3, r4, r5\n"
218 "ps_add r3, r4, r5\n"
219 "ps_add. r3, r4, r5\n"
220 "ps_sel r3, r4, r7, r5\n"
221 "ps_sel. r3, r4, r7, r5\n"
222 "ps_res r3, r5\n"
223 "ps_res. r3, r5\n"
224 "ps_mul r3, r4, r7\n"
225 "ps_mul. r3, r4, r7\n"
226 "ps_rsqrte r3, r5\n"
227 "ps_rsqrte. r3, r5\n"
228 "ps_msub r3, r4, r7, r5\n"
229 "ps_msub. r3, r4, r7, r5\n"
230 "ps_madd r3, r4, r7, r5\n"
231 "ps_madd. r3, r4, r7, r5\n"
232 "ps_nmsub r3, r4, r7, r5\n"
233 "ps_nmsub. r3, r4, r7, r5\n"
234 "ps_nmadd r3, r4, r7, r5\n"
235 "ps_nmadd. r3, r4, r7, r5\n"
236 "ps_neg r3, r5\n"
237 "ps_neg. r3, r5\n"
238 "ps_mr r3, r5\n"
239 "ps_mr. r3, r5\n"
240 "ps_nabs r3, r5\n"
241 "ps_nabs. r3, r5\n"
242 "ps_abs r3, r5\n"
243 "ps_abs. r3, r5\n"
244 "ps_sum0 r3, r4, r7, r5\n"
245 "ps_sum0. r3, r4, r7, r5\n"
246 "ps_sum1 r3, r4, r7, r5\n"
247 "ps_sum1. r3, r4, r7, r5\n"
248 "ps_muls0 r3, r4, r7\n"
249 "ps_muls0. r3, r4, r7\n"
250 "ps_muls1 r3, r4, r7\n"
251 "ps_muls1. r3, r4, r7\n"
252 "ps_madds0 r3, r4, r7, r5\n"
253 "ps_madds0. r3, r4, r7, r5\n"
254 "ps_madds1 r3, r4, r7, r5\n"
255 "ps_madds1. r3, r4, r7, r5\n"
256 "ps_merge00 r3, r4, r5\n"
257 "ps_merge00. r3, r4, r5\n"
258 "ps_merge01 r3, r4, r5\n"
259 "ps_merge01. r3, r4, r5\n"
260 "ps_merge10 r3, r4, r5\n"
261 "ps_merge10. r3, r4, r5\n"
262 "ps_merge11 r3, r4, r5\n"
263 "ps_merge11. r3, r4, r5\n"
264 "cmp cr1, 0, r4, r5\n"
265 "cmpl cr1, 0, r4, r5\n"
266 "fcmpo cr1, r4, r5\n"
267 "fcmpu cr1, r4, r5\n"
268 "mcrfs cr1, 7\n"
269 "lbzux r3, r4, r5\n"
270 "lbzx r3, r4, r5\n"
271 "lhaux r3, r4, r5\n"
272 "lhax r3, r4, r5\n"
273 "lhzux r3, r4, r5\n"
274 "lhzx r3, r4, r5\n"
275 "lwzux r3, r4, r5\n"
276 "lwzx r3, r4, r5\n"
277 "stbux r6, r4, r5\n"
278 "stbx r6, r4, r5\n"
279 "sthux r6, r4, r5\n"
280 "sthx r6, r4, r5\n"
281 "stwux r6, r4, r5\n"
282 "stwx r6, r4, r5\n"
283 "lhbrx r3, r4, r5\n"
284 "lwbrx r3, r4, r5\n"
285 "sthbrx r6, r4, r5\n"
286 "stwbrx r6, r4, r5\n"
287 "lswi r5, r4, 1\n"
288 "lswx r3, r4, r5\n"
289 "stswi r6, r4, 1\n"
290 "stswx r6, r4, r5\n"
291 "lwarx r3, r4, r5\n"
292 "stwcx. r6, r4, r5\n"
293 "lfdux r3, r4, r5\n"
294 "lfdx r3, r4, r5\n"
295 "lfsux r3, r4, r5\n"
296 "lfsx r3, r4, r5\n"
297 "stfdux r6, r4, r5\n"
298 "stfdx r6, r4, r5\n"
299 "stfiwx r6, r4, r5\n"
300 "stfsux r6, r4, r5\n"
301 "stfsx r6, r4, r5\n"
302 "crand 21, 22, 23\n"
303 "crandc 21, 22, 23\n"
304 "creqv 21, 22, 23\n"
305 "crnand 21, 22, 23\n"
306 "crnor 21, 22, 23\n"
307 "cror 21, 22, 23\n"
308 "crorc 21, 22, 23\n"
309 "crxor 21, 22, 23\n"
310 "mcrf cr1, 7\n"
311 "tw 8, r4, r5\n"
312 "mcrxr cr1\n"
313 "mfcr r3\n"
314 "mfmsr r3\n"
315 "mfspr r3, LR\n"
316 "mftb r3, 268\n"
317 "mtcrf 255, r6\n"
318 "mtmsr r6\n"
319 "mtspr LR, r3\n"
320 "dcbf r4, r5\n"
321 "dcbi r4, r5\n"
322 "dcbst r4, r5\n"
323 "dcbt r4, r5\n"
324 "dcbtst r4, r5\n"
325 "dcbz r4, r5\n"
326 "icbi r4, r5\n"
327 "mfsr r3, 0\n"
328 "mfsrin r3, r5\n"
329 "mtsr 0, r6\n"
330 "mtsrin r6, r5\n"
331 "tlbie r5\n"
332 "eciwx r3, r4, r5\n"
333 "ecowx r6, r4, r5\n"
334 "psq_lx r3, r4, r5, 0, 2\n"
335 "psq_stx r6, r4, r5, 0, 2\n"
336 "psq_lux r3, r4, r5, 0, 2\n"
337 "psq_stux r6, r4, r5, 0, 2\n"
338 "ps_cmpu0 cr1, r4, r5\n"
339 "ps_cmpo0 cr1, r4, r5\n"
340 "ps_cmpu1 cr1, r4, r5\n"
341 "ps_cmpo1 cr1, r4, r5\n"
342 "dcbz_l r4, r5\n"
343 "b 0x1000\n"
344 "ba 0x1000\n"
345 "bl 0x1000\n"
346 "bla 0x1000\n"
347 "bc 12, 2, -0xc\n"
348 "bca 12, 2, -0xc\n"
349 "bcl 12, 2, -0xc\n"
350 "bcla 12, 2, -0xc\n"
351 "bcctr 12, 2\n"
352 "bcctrl 12, 2\n"
353 "bclr 12, 2\n"
354 "bclrl 12, 2\n";
355
356 constexpr u8 expected_instructions[] = {
357 0x7c, 0x64, 0x2a, 0x14, 0x7c, 0x64, 0x2a, 0x15, 0x7c, 0x64, 0x2e, 0x14, 0x7c, 0x64, 0x2e, 0x15,
358 0x7c, 0x64, 0x28, 0x14, 0x7c, 0x64, 0x28, 0x15, 0x7c, 0x64, 0x2c, 0x14, 0x7c, 0x64, 0x2c, 0x15,
359 0x7c, 0x64, 0x29, 0x14, 0x7c, 0x64, 0x29, 0x15, 0x7c, 0x64, 0x2d, 0x14, 0x7c, 0x64, 0x2d, 0x15,
360 0x7c, 0x64, 0x01, 0xd4, 0x7c, 0x64, 0x01, 0xd5, 0x7c, 0x64, 0x05, 0xd4, 0x7c, 0x64, 0x05, 0xd5,
361 0x7c, 0x64, 0x01, 0x94, 0x7c, 0x64, 0x01, 0x95, 0x7c, 0x64, 0x05, 0x94, 0x7c, 0x64, 0x05, 0x95,
362 0x7c, 0x64, 0x2b, 0xd6, 0x7c, 0x64, 0x2b, 0xd7, 0x7c, 0x64, 0x2f, 0xd6, 0x7c, 0x64, 0x2f, 0xd7,
363 0x7c, 0x64, 0x2b, 0x96, 0x7c, 0x64, 0x2b, 0x97, 0x7c, 0x64, 0x2f, 0x96, 0x7c, 0x64, 0x2f, 0x97,
364 0x7c, 0x64, 0x29, 0xd6, 0x7c, 0x64, 0x29, 0xd7, 0x7c, 0x64, 0x2d, 0xd6, 0x7c, 0x64, 0x2d, 0xd7,
365 0x7c, 0x64, 0x00, 0xd0, 0x7c, 0x64, 0x00, 0xd1, 0x7c, 0x64, 0x04, 0xd0, 0x7c, 0x64, 0x04, 0xd1,
366 0x7c, 0x64, 0x28, 0x50, 0x7c, 0x64, 0x28, 0x51, 0x7c, 0x64, 0x2c, 0x50, 0x7c, 0x64, 0x2c, 0x51,
367 0x7c, 0x64, 0x28, 0x10, 0x7c, 0x64, 0x28, 0x11, 0x7c, 0x64, 0x2c, 0x10, 0x7c, 0x64, 0x2c, 0x11,
368 0x7c, 0x64, 0x29, 0x10, 0x7c, 0x64, 0x29, 0x11, 0x7c, 0x64, 0x2d, 0x10, 0x7c, 0x64, 0x2d, 0x11,
369 0x7c, 0x64, 0x01, 0xd0, 0x7c, 0x64, 0x01, 0xd1, 0x7c, 0x64, 0x05, 0xd0, 0x7c, 0x64, 0x05, 0xd1,
370 0x7c, 0x64, 0x01, 0x90, 0x7c, 0x64, 0x01, 0x91, 0x7c, 0x64, 0x05, 0x90, 0x7c, 0x64, 0x05, 0x91,
371 0x38, 0x64, 0x03, 0xe8, 0x30, 0x64, 0x03, 0xe8, 0x34, 0x64, 0x03, 0xe8, 0x3c, 0x64, 0x03, 0xe8,
372 0x1c, 0x64, 0x03, 0xe8, 0x20, 0x64, 0x03, 0xe8, 0x2c, 0x84, 0x03, 0xe8, 0x28, 0x84, 0x03, 0xe8,
373 0x70, 0xc4, 0x03, 0xe8, 0x74, 0xc4, 0x03, 0xe8, 0x60, 0xc4, 0x03, 0xe8, 0x64, 0xc4, 0x03, 0xe8,
374 0x68, 0xc4, 0x03, 0xe8, 0x6c, 0xc4, 0x03, 0xe8, 0x88, 0x64, 0x00, 0x64, 0x8c, 0x64, 0x00, 0x64,
375 0xa8, 0x64, 0x00, 0x64, 0xac, 0x64, 0x00, 0x64, 0xa0, 0x64, 0x00, 0x64, 0xa4, 0x64, 0x00, 0x64,
376 0x80, 0x64, 0x00, 0x64, 0x84, 0x64, 0x00, 0x64, 0x98, 0xc4, 0x00, 0x64, 0x9c, 0xc4, 0x00, 0x64,
377 0xb0, 0xc4, 0x00, 0x64, 0xb4, 0xc4, 0x00, 0x64, 0x90, 0xc4, 0x00, 0x64, 0x94, 0xc4, 0x00, 0x64,
378 0xb8, 0xc4, 0x00, 0x64, 0xbc, 0xc4, 0x00, 0x64, 0xc8, 0x64, 0x00, 0x64, 0xcc, 0x64, 0x00, 0x64,
379 0xc0, 0x64, 0x00, 0x64, 0xc4, 0x64, 0x00, 0x64, 0xd8, 0xc4, 0x00, 0x64, 0xdc, 0xc4, 0x00, 0x64,
380 0xd0, 0xc4, 0x00, 0x64, 0xd4, 0xc4, 0x00, 0x64, 0x0d, 0x04, 0x03, 0xe8, 0xe0, 0x64, 0x20, 0xc8,
381 0xe4, 0x64, 0x20, 0xc8, 0xf0, 0xc4, 0x20, 0xc8, 0xf4, 0xc4, 0x20, 0xc8, 0x7c, 0x64, 0x28, 0x96,
382 0x7c, 0x64, 0x28, 0x97, 0x7c, 0x64, 0x28, 0x16, 0x7c, 0x64, 0x28, 0x17, 0x7c, 0xc4, 0x28, 0x38,
383 0x7c, 0xc4, 0x28, 0x39, 0x7c, 0xc4, 0x28, 0x78, 0x7c, 0xc4, 0x28, 0x79, 0x7c, 0xc4, 0x00, 0x34,
384 0x7c, 0xc4, 0x00, 0x35, 0x7c, 0xc4, 0x2a, 0x38, 0x7c, 0xc4, 0x2a, 0x39, 0x7c, 0xc4, 0x07, 0x74,
385 0x7c, 0xc4, 0x07, 0x75, 0x7c, 0xc4, 0x07, 0x34, 0x7c, 0xc4, 0x07, 0x35, 0x7c, 0xc4, 0x2b, 0xb8,
386 0x7c, 0xc4, 0x2b, 0xb9, 0x7c, 0xc4, 0x28, 0xf8, 0x7c, 0xc4, 0x28, 0xf9, 0x7c, 0xc4, 0x2b, 0x78,
387 0x7c, 0xc4, 0x2b, 0x79, 0x7c, 0xc4, 0x2b, 0x38, 0x7c, 0xc4, 0x2b, 0x39, 0x7c, 0xc4, 0x2a, 0x78,
388 0x7c, 0xc4, 0x2a, 0x79, 0x50, 0xc4, 0x02, 0x9e, 0x50, 0xc4, 0x02, 0x9f, 0x54, 0xc4, 0x02, 0x9e,
389 0x54, 0xc4, 0x02, 0x9f, 0x5c, 0xc4, 0x2a, 0x9e, 0x5c, 0xc4, 0x2a, 0x9f, 0x7c, 0xc4, 0x28, 0x30,
390 0x7c, 0xc4, 0x28, 0x31, 0x7c, 0xc4, 0x2e, 0x30, 0x7c, 0xc4, 0x2e, 0x31, 0x7c, 0xc4, 0x06, 0x70,
391 0x7c, 0xc4, 0x06, 0x71, 0x7c, 0xc4, 0x2c, 0x30, 0x7c, 0xc4, 0x2c, 0x31, 0xfc, 0x64, 0x28, 0x2a,
392 0xfc, 0x64, 0x28, 0x2b, 0xec, 0x64, 0x28, 0x2a, 0xec, 0x64, 0x28, 0x2b, 0xfc, 0x64, 0x28, 0x24,
393 0xfc, 0x64, 0x28, 0x25, 0xec, 0x64, 0x28, 0x24, 0xec, 0x64, 0x28, 0x25, 0xfc, 0x64, 0x01, 0xf2,
394 0xfc, 0x64, 0x01, 0xf3, 0xec, 0x64, 0x01, 0xf2, 0xec, 0x64, 0x01, 0xf3, 0xec, 0x60, 0x28, 0x30,
395 0xec, 0x60, 0x28, 0x31, 0xfc, 0x60, 0x28, 0x34, 0xfc, 0x60, 0x28, 0x35, 0xfc, 0x64, 0x28, 0x28,
396 0xfc, 0x64, 0x28, 0x29, 0xec, 0x64, 0x28, 0x28, 0xec, 0x64, 0x28, 0x29, 0xfc, 0x64, 0x29, 0xee,
397 0xfc, 0x64, 0x29, 0xef, 0xfc, 0x64, 0x29, 0xfa, 0xfc, 0x64, 0x29, 0xfb, 0xec, 0x64, 0x29, 0xfa,
398 0xec, 0x64, 0x29, 0xfb, 0xfc, 0x64, 0x29, 0xf8, 0xfc, 0x64, 0x29, 0xf9, 0xec, 0x64, 0x29, 0xf8,
399 0xec, 0x64, 0x29, 0xf9, 0xfc, 0x64, 0x29, 0xfe, 0xfc, 0x64, 0x29, 0xff, 0xec, 0x64, 0x29, 0xfe,
400 0xec, 0x64, 0x29, 0xff, 0xfc, 0x64, 0x29, 0xfc, 0xfc, 0x64, 0x29, 0xfd, 0xec, 0x64, 0x29, 0xfc,
401 0xec, 0x64, 0x29, 0xfd, 0xfc, 0x60, 0x28, 0x1c, 0xfc, 0x60, 0x28, 0x1d, 0xfc, 0x60, 0x28, 0x1e,
402 0xfc, 0x60, 0x28, 0x1f, 0xfc, 0x60, 0x28, 0x18, 0xfc, 0x60, 0x28, 0x19, 0xfc, 0x60, 0x04, 0x8e,
403 0xfc, 0x60, 0x04, 0x8f, 0xfe, 0xa0, 0x00, 0x8c, 0xfe, 0xa0, 0x00, 0x8d, 0xfe, 0xa0, 0x00, 0x4c,
404 0xfe, 0xa0, 0x00, 0x4d, 0xfd, 0xfe, 0x2d, 0x8e, 0xfd, 0xfe, 0x2d, 0x8f, 0xfc, 0x80, 0x51, 0x0c,
405 0xfc, 0x80, 0x51, 0x0d, 0xfc, 0x60, 0x2a, 0x10, 0xfc, 0x60, 0x2a, 0x11, 0xfc, 0x60, 0x28, 0x90,
406 0xfc, 0x60, 0x28, 0x91, 0xfc, 0x60, 0x29, 0x10, 0xfc, 0x60, 0x29, 0x11, 0xfc, 0x60, 0x28, 0x50,
407 0xfc, 0x60, 0x28, 0x51, 0x10, 0x64, 0x28, 0x24, 0x10, 0x64, 0x28, 0x25, 0x10, 0x64, 0x28, 0x28,
408 0x10, 0x64, 0x28, 0x29, 0x10, 0x64, 0x28, 0x2a, 0x10, 0x64, 0x28, 0x2b, 0x10, 0x64, 0x29, 0xee,
409 0x10, 0x64, 0x29, 0xef, 0x10, 0x60, 0x28, 0x30, 0x10, 0x60, 0x28, 0x31, 0x10, 0x64, 0x01, 0xf2,
410 0x10, 0x64, 0x01, 0xf3, 0x10, 0x60, 0x28, 0x34, 0x10, 0x60, 0x28, 0x35, 0x10, 0x64, 0x29, 0xf8,
411 0x10, 0x64, 0x29, 0xf9, 0x10, 0x64, 0x29, 0xfa, 0x10, 0x64, 0x29, 0xfb, 0x10, 0x64, 0x29, 0xfc,
412 0x10, 0x64, 0x29, 0xfd, 0x10, 0x64, 0x29, 0xfe, 0x10, 0x64, 0x29, 0xff, 0x10, 0x60, 0x28, 0x50,
413 0x10, 0x60, 0x28, 0x51, 0x10, 0x60, 0x28, 0x90, 0x10, 0x60, 0x28, 0x91, 0x10, 0x60, 0x29, 0x10,
414 0x10, 0x60, 0x29, 0x11, 0x10, 0x60, 0x2a, 0x10, 0x10, 0x60, 0x2a, 0x11, 0x10, 0x64, 0x29, 0xd4,
415 0x10, 0x64, 0x29, 0xd5, 0x10, 0x64, 0x29, 0xd6, 0x10, 0x64, 0x29, 0xd7, 0x10, 0x64, 0x01, 0xd8,
416 0x10, 0x64, 0x01, 0xd9, 0x10, 0x64, 0x01, 0xda, 0x10, 0x64, 0x01, 0xdb, 0x10, 0x64, 0x29, 0xdc,
417 0x10, 0x64, 0x29, 0xdd, 0x10, 0x64, 0x29, 0xde, 0x10, 0x64, 0x29, 0xdf, 0x10, 0x64, 0x2c, 0x20,
418 0x10, 0x64, 0x2c, 0x21, 0x10, 0x64, 0x2c, 0x60, 0x10, 0x64, 0x2c, 0x61, 0x10, 0x64, 0x2c, 0xa0,
419 0x10, 0x64, 0x2c, 0xa1, 0x10, 0x64, 0x2c, 0xe0, 0x10, 0x64, 0x2c, 0xe1, 0x7c, 0x84, 0x28, 0x00,
420 0x7c, 0x84, 0x28, 0x40, 0xfc, 0x84, 0x28, 0x40, 0xfc, 0x84, 0x28, 0x00, 0xfc, 0x9c, 0x00, 0x80,
421 0x7c, 0x64, 0x28, 0xee, 0x7c, 0x64, 0x28, 0xae, 0x7c, 0x64, 0x2a, 0xee, 0x7c, 0x64, 0x2a, 0xae,
422 0x7c, 0x64, 0x2a, 0x6e, 0x7c, 0x64, 0x2a, 0x2e, 0x7c, 0x64, 0x28, 0x6e, 0x7c, 0x64, 0x28, 0x2e,
423 0x7c, 0xc4, 0x29, 0xee, 0x7c, 0xc4, 0x29, 0xae, 0x7c, 0xc4, 0x2b, 0x6e, 0x7c, 0xc4, 0x2b, 0x2e,
424 0x7c, 0xc4, 0x29, 0x6e, 0x7c, 0xc4, 0x29, 0x2e, 0x7c, 0x64, 0x2e, 0x2c, 0x7c, 0x64, 0x2c, 0x2c,
425 0x7c, 0xc4, 0x2f, 0x2c, 0x7c, 0xc4, 0x2d, 0x2c, 0x7c, 0xa4, 0x0c, 0xaa, 0x7c, 0x64, 0x2c, 0x2a,
426 0x7c, 0xc4, 0x0d, 0xaa, 0x7c, 0xc4, 0x2d, 0x2a, 0x7c, 0x64, 0x28, 0x28, 0x7c, 0xc4, 0x29, 0x2d,
427 0x7c, 0x64, 0x2c, 0xee, 0x7c, 0x64, 0x2c, 0xae, 0x7c, 0x64, 0x2c, 0x6e, 0x7c, 0x64, 0x2c, 0x2e,
428 0x7c, 0xc4, 0x2d, 0xee, 0x7c, 0xc4, 0x2d, 0xae, 0x7c, 0xc4, 0x2f, 0xae, 0x7c, 0xc4, 0x2d, 0x6e,
429 0x7c, 0xc4, 0x2d, 0x2e, 0x4e, 0xb6, 0xba, 0x02, 0x4e, 0xb6, 0xb9, 0x02, 0x4e, 0xb6, 0xba, 0x42,
430 0x4e, 0xb6, 0xb9, 0xc2, 0x4e, 0xb6, 0xb8, 0x42, 0x4e, 0xb6, 0xbb, 0x82, 0x4e, 0xb6, 0xbb, 0x42,
431 0x4e, 0xb6, 0xb9, 0x82, 0x4c, 0x9c, 0x00, 0x00, 0x7d, 0x04, 0x28, 0x08, 0x7c, 0x80, 0x04, 0x00,
432 0x7c, 0x60, 0x00, 0x26, 0x7c, 0x60, 0x00, 0xa6, 0x7c, 0x68, 0x02, 0xa6, 0x7c, 0x6c, 0x42, 0xe6,
433 0x7c, 0xcf, 0xf1, 0x20, 0x7c, 0xc0, 0x01, 0x24, 0x7c, 0x68, 0x03, 0xa6, 0x7c, 0x04, 0x28, 0xac,
434 0x7c, 0x04, 0x2b, 0xac, 0x7c, 0x04, 0x28, 0x6c, 0x7c, 0x04, 0x2a, 0x2c, 0x7c, 0x04, 0x29, 0xec,
435 0x7c, 0x04, 0x2f, 0xec, 0x7c, 0x04, 0x2f, 0xac, 0x7c, 0x60, 0x04, 0xa6, 0x7c, 0x60, 0x2d, 0x26,
436 0x7c, 0xc0, 0x01, 0xa4, 0x7c, 0xc0, 0x29, 0xe4, 0x7c, 0x00, 0x2a, 0x64, 0x7c, 0x64, 0x2a, 0x6c,
437 0x7c, 0xc4, 0x2b, 0x6c, 0x10, 0x64, 0x29, 0x0c, 0x10, 0xc4, 0x29, 0x0e, 0x10, 0x64, 0x29, 0x4c,
438 0x10, 0xc4, 0x29, 0x4e, 0x10, 0x84, 0x28, 0x00, 0x10, 0x84, 0x28, 0x40, 0x10, 0x84, 0x28, 0x80,
439 0x10, 0x84, 0x28, 0xc0, 0x10, 0x04, 0x2f, 0xec, 0x48, 0x00, 0x10, 0x00, 0x48, 0x00, 0x10, 0x02,
440 0x48, 0x00, 0x10, 0x01, 0x48, 0x00, 0x10, 0x03, 0x41, 0x82, 0xff, 0xf4, 0x41, 0x82, 0xff, 0xf6,
441 0x41, 0x82, 0xff, 0xf5, 0x41, 0x82, 0xff, 0xf7, 0x4d, 0x82, 0x04, 0x20, 0x4d, 0x82, 0x04, 0x21,
442 0x4d, 0x82, 0x00, 0x20, 0x4d, 0x82, 0x00, 0x21,
443 };
444
445 TEST(Assembler, AllInstructions)
446 {
447 auto res = Assemble(instructions, 0);
448 ASSERT_TRUE(!IsFailure(res));
449 auto&& code_blocks = GetT(res);
450 ASSERT_EQ(code_blocks.size(), 1);
451 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expected_instructions));
452
453 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
454 {
455 EXPECT_EQ(code_blocks[0].instructions[i], expected_instructions[i]) << " -> i=" << i;
456 }
457 }
458
459 constexpr char extended_instructions[] = "subi 0, 4, 8\n"
460 "subis 0, 4, 8\n"
461 "subic 0, 4, 8\n"
462 "subic. 0, 4, 8\n"
463 "cmpwi 0, 4\n"
464 "cmpwi 0, 4, 8\n"
465 "cmpw 0, 4\n"
466 "cmpw 0, 4, 8\n"
467 "cmplwi 0, 4\n"
468 "cmplwi 0, 4, 8\n"
469 "cmplw 0, 4\n"
470 "cmplw 0, 4, 8\n"
471 "crset 0\n"
472 "crclr 0\n"
473 "crmove 0, 4\n"
474 "crnot 0, 4\n"
475 "twlt 0, 4\n"
476 "twlti 0, 4\n"
477 "twle 0, 4\n"
478 "twlei 0, 4\n"
479 "tweq 0, 4\n"
480 "tweqi 0, 4\n"
481 "twge 0, 4\n"
482 "twgei 0, 4\n"
483 "twgt 0, 4\n"
484 "twgti 0, 4\n"
485 "twnl 0, 4\n"
486 "twnli 0, 4\n"
487 "twne 0, 4\n"
488 "twnei 0, 4\n"
489 "twng 0, 4\n"
490 "twngi 0, 4\n"
491 "twllt 0, 4\n"
492 "twllti 0, 4\n"
493 "twlle 0, 4\n"
494 "twllei 0, 4\n"
495 "twlge 0, 4\n"
496 "twlgei 0, 4\n"
497 "twlgt 0, 4\n"
498 "twlgti 0, 4\n"
499 "twlnl 0, 4\n"
500 "twlnli 0, 4\n"
501 "twlng 0, 4\n"
502 "twlngi 0, 4\n"
503 "trap \n"
504 "mtxer 0\n"
505 "mfxer 0\n"
506 "mtlr 0\n"
507 "mflr 0\n"
508 "mtctr 0\n"
509 "mfctr 0\n"
510 "mtdsisr 0\n"
511 "mfdsisr 0\n"
512 "mtdar 0\n"
513 "mfdar 0\n"
514 "mtdec 0\n"
515 "mfdec 0\n"
516 "mtsdr1 0\n"
517 "mfsdr1 0\n"
518 "mtsrr0 0\n"
519 "mfsrr0 0\n"
520 "mtsrr1 0\n"
521 "mfsrr1 0\n"
522 "mtear 0\n"
523 "mfear 0\n"
524 "mttbl 0\n"
525 "mftbl 0\n"
526 "mttbu 0\n"
527 "mftbu 0\n"
528 "mtsprg 0, 4\n"
529 "mfsprg 0, 1\n"
530 "mtibatu 0, 1\n"
531 "mfibatu 0, 1\n"
532 "mtibatl 0, 1\n"
533 "mfibatl 0, 1\n"
534 "mtdbatu 0, 1\n"
535 "mfdbatu 0, 1\n"
536 "mtdbatl 0, 1\n"
537 "mfdbatl 0, 1\n"
538 "nop \n"
539 "li 0, 4\n"
540 "lis 0, 4\n"
541 "la 0, 4(8)\n"
542 "mtcr 0\n"
543 "mfspr 0, 4\n"
544 "mftb 0, 268\n"
545 "mtspr 0, 4\n"
546 "sub 0, 4, 8\n"
547 "sub. 0, 4, 8\n"
548 "subo 0, 4, 8\n"
549 "subo. 0, 4, 8\n"
550 "subc 0, 4, 8\n"
551 "subc. 0, 4, 8\n"
552 "subco 0, 4, 8\n"
553 "subco. 0, 4, 8\n"
554 "extlwi 0, 4, 8, 12\n"
555 "extlwi. 0, 4, 8, 12\n"
556 "extrwi 0, 4, 8, 12\n"
557 "extrwi. 0, 4, 8, 12\n"
558 "inslwi 0, 4, 8, 12\n"
559 "inslwi. 0, 4, 8, 12\n"
560 "insrwi 0, 4, 8, 12\n"
561 "insrwi. 0, 4, 8, 12\n"
562 "rotlwi 0, 4, 8\n"
563 "rotlwi. 0, 4, 8\n"
564 "rotrwi 0, 4, 8\n"
565 "rotrwi. 0, 4, 8\n"
566 "rotlw 0, 4, 8\n"
567 "rotlw. 0, 4, 8\n"
568 "slwi 0, 4, 8\n"
569 "slwi. 0, 4, 8\n"
570 "srwi 0, 4, 8\n"
571 "srwi. 0, 4, 8\n"
572 "clrlwi 0, 4, 8\n"
573 "clrlwi. 0, 4, 8\n"
574 "clrrwi 0, 4, 8\n"
575 "clrrwi. 0, 4, 8\n"
576 "clrlslwi 0, 4, 12, 8\n"
577 "clrlslwi. 0, 4, 12, 8\n"
578 "mr 0, 4\n"
579 "mr. 0, 4\n"
580 "not 0, 4\n"
581 "not. 0, 4\n"
582 "bt 0, 4\n"
583 "btl 0, 4\n"
584 "bta 0, 4\n"
585 "btla 0, 4\n"
586 "bt- 0, 4\n"
587 "btl- 0, 4\n"
588 "bta- 0, 4\n"
589 "btla- 0, 4\n"
590 "bt+ 0, 4\n"
591 "btl+ 0, 4\n"
592 "bta+ 0, 4\n"
593 "btla+ 0, 4\n"
594 "bf 0, 4\n"
595 "bfl 0, 4\n"
596 "bfa 0, 4\n"
597 "bfla 0, 4\n"
598 "bf- 0, 4\n"
599 "bfl- 0, 4\n"
600 "bfa- 0, 4\n"
601 "bfla- 0, 4\n"
602 "bf+ 0, 4\n"
603 "bfl+ 0, 4\n"
604 "bfa+ 0, 4\n"
605 "bfla+ 0, 4\n"
606 "bdnz 0\n"
607 "bdnzl 0\n"
608 "bdnza 0\n"
609 "bdnzla 0\n"
610 "bdnz- 0\n"
611 "bdnzl- 0\n"
612 "bdnza- 0\n"
613 "bdnzla- 0\n"
614 "bdnz+ 0\n"
615 "bdnzl+ 0\n"
616 "bdnza+ 0\n"
617 "bdnzla+ 0\n"
618 "bdnzt 0, 4\n"
619 "bdnztl 0, 4\n"
620 "bdnzta 0, 4\n"
621 "bdnztla 0, 4\n"
622 "bdnzt- 0, 4\n"
623 "bdnztl- 0, 4\n"
624 "bdnzta- 0, 4\n"
625 "bdnztla- 0, 4\n"
626 "bdnzt+ 0, 4\n"
627 "bdnztl+ 0, 4\n"
628 "bdnzta+ 0, 4\n"
629 "bdnztla+ 0, 4\n"
630 "bdnzf 0, 4\n"
631 "bdnzfl 0, 4\n"
632 "bdnzfa 0, 4\n"
633 "bdnzfla 0, 4\n"
634 "bdnzf- 0, 4\n"
635 "bdnzfl- 0, 4\n"
636 "bdnzfa- 0, 4\n"
637 "bdnzfla- 0, 4\n"
638 "bdnzf+ 0, 4\n"
639 "bdnzfl+ 0, 4\n"
640 "bdnzfa+ 0, 4\n"
641 "bdnzfla+ 0, 4\n"
642 "bdz 0\n"
643 "bdzl 0\n"
644 "bdza 0\n"
645 "bdzla 0\n"
646 "bdz- 0\n"
647 "bdzl- 0\n"
648 "bdza- 0\n"
649 "bdzla- 0\n"
650 "bdz+ 0\n"
651 "bdzl+ 0\n"
652 "bdza+ 0\n"
653 "bdzla+ 0\n"
654 "bdzt 0, 4\n"
655 "bdztl 0, 4\n"
656 "bdzta 0, 4\n"
657 "bdztla 0, 4\n"
658 "bdzt- 0, 4\n"
659 "bdztl- 0, 4\n"
660 "bdzta- 0, 4\n"
661 "bdztla- 0, 4\n"
662 "bdzt+ 0, 4\n"
663 "bdztl+ 0, 4\n"
664 "bdzta+ 0, 4\n"
665 "bdztla+ 0, 4\n"
666 "bdzf 0, 4\n"
667 "bdzfl 0, 4\n"
668 "bdzfa 0, 4\n"
669 "bdzfla 0, 4\n"
670 "bdzf- 0, 4\n"
671 "bdzfl- 0, 4\n"
672 "bdzfa- 0, 4\n"
673 "bdzfla- 0, 4\n"
674 "bdzf+ 0, 4\n"
675 "bdzfl+ 0, 4\n"
676 "bdzfa+ 0, 4\n"
677 "bdzfla+ 0, 4\n"
678 "blt 0 \n"
679 "blt 0, 4\n"
680 "bltl 0 \n"
681 "bltl 0, 4\n"
682 "blta 0 \n"
683 "blta 0, 4\n"
684 "bltla 0 \n"
685 "bltla 0, 4\n"
686 "blt- 0 \n"
687 "blt- 0, 4\n"
688 "bltl- 0 \n"
689 "bltl- 0, 4\n"
690 "blta- 0 \n"
691 "blta- 0, 4\n"
692 "bltla- 0 \n"
693 "bltla- 0, 4\n"
694 "blt+ 0 \n"
695 "blt+ 0, 4\n"
696 "bltl+ 0 \n"
697 "bltl+ 0, 4\n"
698 "blta+ 0 \n"
699 "blta+ 0, 4\n"
700 "bltla+ 0 \n"
701 "bltla+ 0, 4\n"
702 "ble 0 \n"
703 "ble 0, 4\n"
704 "blel 0 \n"
705 "blel 0, 4\n"
706 "blea 0 \n"
707 "blea 0, 4\n"
708 "blela 0 \n"
709 "blela 0, 4\n"
710 "ble- 0 \n"
711 "ble- 0, 4\n"
712 "blel- 0 \n"
713 "blel- 0, 4\n"
714 "blea- 0 \n"
715 "blea- 0, 4\n"
716 "blela- 0 \n"
717 "blela- 0, 4\n"
718 "ble+ 0 \n"
719 "ble+ 0, 4\n"
720 "blel+ 0 \n"
721 "blel+ 0, 4\n"
722 "blea+ 0 \n"
723 "blea+ 0, 4\n"
724 "blela+ 0 \n"
725 "blela+ 0, 4\n"
726 "beq 0 \n"
727 "beq 0, 4\n"
728 "beql 0 \n"
729 "beql 0, 4\n"
730 "beqa 0 \n"
731 "beqa 0, 4\n"
732 "beqla 0 \n"
733 "beqla 0, 4\n"
734 "beq- 0 \n"
735 "beq- 0, 4\n"
736 "beql- 0 \n"
737 "beql- 0, 4\n"
738 "beqa- 0 \n"
739 "beqa- 0, 4\n"
740 "beqla- 0 \n"
741 "beqla- 0, 4\n"
742 "beq+ 0 \n"
743 "beq+ 0, 4\n"
744 "beql+ 0 \n"
745 "beql+ 0, 4\n"
746 "beqa+ 0 \n"
747 "beqa+ 0, 4\n"
748 "beqla+ 0 \n"
749 "beqla+ 0, 4\n"
750 "bge 0 \n"
751 "bge 0, 4\n"
752 "bgel 0 \n"
753 "bgel 0, 4\n"
754 "bgea 0 \n"
755 "bgea 0, 4\n"
756 "bgela 0 \n"
757 "bgela 0, 4\n"
758 "bge- 0 \n"
759 "bge- 0, 4\n"
760 "bgel- 0 \n"
761 "bgel- 0, 4\n"
762 "bgea- 0 \n"
763 "bgea- 0, 4\n"
764 "bgela- 0 \n"
765 "bgela- 0, 4\n"
766 "bge+ 0 \n"
767 "bge+ 0, 4\n"
768 "bgel+ 0 \n"
769 "bgel+ 0, 4\n"
770 "bgea+ 0 \n"
771 "bgea+ 0, 4\n"
772 "bgela+ 0 \n"
773 "bgela+ 0, 4\n"
774 "bgt 0 \n"
775 "bgt 0, 4\n"
776 "bgtl 0 \n"
777 "bgtl 0, 4\n"
778 "bgta 0 \n"
779 "bgta 0, 4\n"
780 "bgtla 0 \n"
781 "bgtla 0, 4\n"
782 "bgt- 0 \n"
783 "bgt- 0, 4\n"
784 "bgtl- 0 \n"
785 "bgtl- 0, 4\n"
786 "bgta- 0 \n"
787 "bgta- 0, 4\n"
788 "bgtla- 0 \n"
789 "bgtla- 0, 4\n"
790 "bgt+ 0 \n"
791 "bgt+ 0, 4\n"
792 "bgtl+ 0 \n"
793 "bgtl+ 0, 4\n"
794 "bgta+ 0 \n"
795 "bgta+ 0, 4\n"
796 "bgtla+ 0 \n"
797 "bgtla+ 0, 4\n"
798 "bnl 0 \n"
799 "bnl 0, 4\n"
800 "bnll 0 \n"
801 "bnll 0, 4\n"
802 "bnla 0 \n"
803 "bnla 0, 4\n"
804 "bnlla 0 \n"
805 "bnlla 0, 4\n"
806 "bnl- 0 \n"
807 "bnl- 0, 4\n"
808 "bnll- 0 \n"
809 "bnll- 0, 4\n"
810 "bnla- 0 \n"
811 "bnla- 0, 4\n"
812 "bnlla- 0 \n"
813 "bnlla- 0, 4\n"
814 "bnl+ 0 \n"
815 "bnl+ 0, 4\n"
816 "bnll+ 0 \n"
817 "bnll+ 0, 4\n"
818 "bnla+ 0 \n"
819 "bnla+ 0, 4\n"
820 "bnlla+ 0 \n"
821 "bnlla+ 0, 4\n"
822 "bne 0 \n"
823 "bne 0, 4\n"
824 "bnel 0 \n"
825 "bnel 0, 4\n"
826 "bnea 0 \n"
827 "bnea 0, 4\n"
828 "bnela 0 \n"
829 "bnela 0, 4\n"
830 "bne- 0 \n"
831 "bne- 0, 4\n"
832 "bnel- 0 \n"
833 "bnel- 0, 4\n"
834 "bnea- 0 \n"
835 "bnea- 0, 4\n"
836 "bnela- 0 \n"
837 "bnela- 0, 4\n"
838 "bne+ 0 \n"
839 "bne+ 0, 4\n"
840 "bnel+ 0 \n"
841 "bnel+ 0, 4\n"
842 "bnea+ 0 \n"
843 "bnea+ 0, 4\n"
844 "bnela+ 0 \n"
845 "bnela+ 0, 4\n"
846 "bng 0 \n"
847 "bng 0, 4\n"
848 "bngl 0 \n"
849 "bngl 0, 4\n"
850 "bnga 0 \n"
851 "bnga 0, 4\n"
852 "bngla 0 \n"
853 "bngla 0, 4\n"
854 "bng- 0 \n"
855 "bng- 0, 4\n"
856 "bngl- 0 \n"
857 "bngl- 0, 4\n"
858 "bnga- 0 \n"
859 "bnga- 0, 4\n"
860 "bngla- 0 \n"
861 "bngla- 0, 4\n"
862 "bng+ 0 \n"
863 "bng+ 0, 4\n"
864 "bngl+ 0 \n"
865 "bngl+ 0, 4\n"
866 "bnga+ 0 \n"
867 "bnga+ 0, 4\n"
868 "bngla+ 0 \n"
869 "bngla+ 0, 4\n"
870 "bso 0 \n"
871 "bso 0, 4\n"
872 "bsol 0 \n"
873 "bsol 0, 4\n"
874 "bsoa 0 \n"
875 "bsoa 0, 4\n"
876 "bsola 0 \n"
877 "bsola 0, 4\n"
878 "bso- 0 \n"
879 "bso- 0, 4\n"
880 "bsol- 0 \n"
881 "bsol- 0, 4\n"
882 "bsoa- 0 \n"
883 "bsoa- 0, 4\n"
884 "bsola- 0 \n"
885 "bsola- 0, 4\n"
886 "bso+ 0 \n"
887 "bso+ 0, 4\n"
888 "bsol+ 0 \n"
889 "bsol+ 0, 4\n"
890 "bsoa+ 0 \n"
891 "bsoa+ 0, 4\n"
892 "bsola+ 0 \n"
893 "bsola+ 0, 4\n"
894 "bns 0 \n"
895 "bns 0, 4\n"
896 "bnsl 0 \n"
897 "bnsl 0, 4\n"
898 "bnsa 0 \n"
899 "bnsa 0, 4\n"
900 "bnsla 0 \n"
901 "bnsla 0, 4\n"
902 "bns- 0 \n"
903 "bns- 0, 4\n"
904 "bnsl- 0 \n"
905 "bnsl- 0, 4\n"
906 "bnsa- 0 \n"
907 "bnsa- 0, 4\n"
908 "bnsla- 0 \n"
909 "bnsla- 0, 4\n"
910 "bns+ 0 \n"
911 "bns+ 0, 4\n"
912 "bnsl+ 0 \n"
913 "bnsl+ 0, 4\n"
914 "bnsa+ 0 \n"
915 "bnsa+ 0, 4\n"
916 "bnsla+ 0 \n"
917 "bnsla+ 0, 4\n"
918 "bun 0 \n"
919 "bun 0, 4\n"
920 "bunl 0 \n"
921 "bunl 0, 4\n"
922 "buna 0 \n"
923 "buna 0, 4\n"
924 "bunla 0 \n"
925 "bunla 0, 4\n"
926 "bun- 0 \n"
927 "bun- 0, 4\n"
928 "bunl- 0 \n"
929 "bunl- 0, 4\n"
930 "buna- 0 \n"
931 "buna- 0, 4\n"
932 "bunla- 0 \n"
933 "bunla- 0, 4\n"
934 "bun+ 0 \n"
935 "bun+ 0, 4\n"
936 "bunl+ 0 \n"
937 "bunl+ 0, 4\n"
938 "buna+ 0 \n"
939 "buna+ 0, 4\n"
940 "bunla+ 0 \n"
941 "bunla+ 0, 4\n"
942 "bnu 0 \n"
943 "bnu 0, 4\n"
944 "bnul 0 \n"
945 "bnul 0, 4\n"
946 "bnua 0 \n"
947 "bnua 0, 4\n"
948 "bnula 0 \n"
949 "bnula 0, 4\n"
950 "bnu- 0 \n"
951 "bnu- 0, 4\n"
952 "bnul- 0 \n"
953 "bnul- 0, 4\n"
954 "bnua- 0 \n"
955 "bnua- 0, 4\n"
956 "bnula- 0 \n"
957 "bnula- 0, 4\n"
958 "bnu+ 0 \n"
959 "bnu+ 0, 4\n"
960 "bnul+ 0 \n"
961 "bnul+ 0, 4\n"
962 "bnua+ 0 \n"
963 "bnua+ 0, 4\n"
964 "bnula+ 0 \n"
965 "bnula+ 0, 4\n"
966 "blr \n"
967 "blrl \n"
968 "bctr \n"
969 "bctrl \n"
970 "btlr 0\n"
971 "btlrl 0\n"
972 "btlr- 0\n"
973 "btlrl- 0\n"
974 "btlr+ 0\n"
975 "btlrl+ 0\n"
976 "btctr 0\n"
977 "btctrl 0\n"
978 "btctr- 0\n"
979 "btctrl- 0\n"
980 "btctr+ 0\n"
981 "btctrl+ 0\n"
982 "bflr 0\n"
983 "bflrl 0\n"
984 "bflr- 0\n"
985 "bflrl- 0\n"
986 "bflr+ 0\n"
987 "bflrl+ 0\n"
988 "bfctr 0\n"
989 "bfctrl 0\n"
990 "bfctr- 0\n"
991 "bfctrl- 0\n"
992 "bfctr+ 0\n"
993 "bfctrl+ 0\n"
994 "bdnzlr \n"
995 "bdnzlrl \n"
996 "bdnzlr- \n"
997 "bdnzlrl- \n"
998 "bdnzlr+ \n"
999 "bdnzlrl+ \n"
1000 "bdnztlr 0\n"
1001 "bdnztlrl 0\n"
1002 "bdnztlr- 0\n"
1003 "bdnztlrl- 0\n"
1004 "bdnztlr+ 0\n"
1005 "bdnztlrl+ 0\n"
1006 "bdnzflr 0\n"
1007 "bdnzflrl 0\n"
1008 "bdnzflr- 0\n"
1009 "bdnzflrl- 0\n"
1010 "bdnzflr+ 0\n"
1011 "bdnzflrl+ 0\n"
1012 "bdzlr \n"
1013 "bdzlrl \n"
1014 "bdzlr- \n"
1015 "bdzlrl- \n"
1016 "bdzlr+ \n"
1017 "bdzlrl+ \n"
1018 "bdztlr 0\n"
1019 "bdztlrl 0\n"
1020 "bdztlr- 0\n"
1021 "bdztlrl- 0\n"
1022 "bdztlr+ 0\n"
1023 "bdztlrl+ 0\n"
1024 "bdzflr 0\n"
1025 "bdzflrl 0\n"
1026 "bdzflr- 0\n"
1027 "bdzflrl- 0\n"
1028 "bdzflr+ 0\n"
1029 "bdzflrl+ 0\n"
1030 "bltlr\n"
1031 "bltlr 0\n"
1032 "bltlrl\n"
1033 "bltlrl 0\n"
1034 "bltlr-\n"
1035 "bltlr- 0\n"
1036 "bltlrl-\n"
1037 "bltlrl- 0\n"
1038 "bltlr+\n"
1039 "bltlr+ 0\n"
1040 "bltlrl+\n"
1041 "bltlrl+ 0\n"
1042 "bltctr\n"
1043 "bltctr 0\n"
1044 "bltctrl\n"
1045 "bltctrl 0\n"
1046 "bltctr-\n"
1047 "bltctr- 0\n"
1048 "bltctrl-\n"
1049 "bltctrl- 0\n"
1050 "bltctr+\n"
1051 "bltctr+ 0\n"
1052 "bltctrl+\n"
1053 "bltctrl+ 0\n"
1054 "blelr\n"
1055 "blelr 0\n"
1056 "blelrl\n"
1057 "blelrl 0\n"
1058 "blelr-\n"
1059 "blelr- 0\n"
1060 "blelrl-\n"
1061 "blelrl- 0\n"
1062 "blelr+\n"
1063 "blelr+ 0\n"
1064 "blelrl+\n"
1065 "blelrl+ 0\n"
1066 "blectr\n"
1067 "blectr 0\n"
1068 "blectrl\n"
1069 "blectrl 0\n"
1070 "blectr-\n"
1071 "blectr- 0\n"
1072 "blectrl-\n"
1073 "blectrl- 0\n"
1074 "blectr+\n"
1075 "blectr+ 0\n"
1076 "blectrl+\n"
1077 "blectrl+ 0\n"
1078 "beqlr\n"
1079 "beqlr 0\n"
1080 "beqlrl\n"
1081 "beqlrl 0\n"
1082 "beqlr-\n"
1083 "beqlr- 0\n"
1084 "beqlrl-\n"
1085 "beqlrl- 0\n"
1086 "beqlr+\n"
1087 "beqlr+ 0\n"
1088 "beqlrl+\n"
1089 "beqlrl+ 0\n"
1090 "beqctr\n"
1091 "beqctr 0\n"
1092 "beqctrl\n"
1093 "beqctrl 0\n"
1094 "beqctr-\n"
1095 "beqctr- 0\n"
1096 "beqctrl-\n"
1097 "beqctrl- 0\n"
1098 "beqctr+\n"
1099 "beqctr+ 0\n"
1100 "beqctrl+\n"
1101 "beqctrl+ 0\n"
1102 "bgelr\n"
1103 "bgelr 0\n"
1104 "bgelrl\n"
1105 "bgelrl 0\n"
1106 "bgelr-\n"
1107 "bgelr- 0\n"
1108 "bgelrl-\n"
1109 "bgelrl- 0\n"
1110 "bgelr+\n"
1111 "bgelr+ 0\n"
1112 "bgelrl+\n"
1113 "bgelrl+ 0\n"
1114 "bgectr\n"
1115 "bgectr 0\n"
1116 "bgectrl\n"
1117 "bgectrl 0\n"
1118 "bgectr-\n"
1119 "bgectr- 0\n"
1120 "bgectrl-\n"
1121 "bgectrl- 0\n"
1122 "bgectr+\n"
1123 "bgectr+ 0\n"
1124 "bgectrl+\n"
1125 "bgectrl+ 0\n"
1126 "bgtlr\n"
1127 "bgtlr 0\n"
1128 "bgtlrl\n"
1129 "bgtlrl 0\n"
1130 "bgtlr-\n"
1131 "bgtlr- 0\n"
1132 "bgtlrl-\n"
1133 "bgtlrl- 0\n"
1134 "bgtlr+\n"
1135 "bgtlr+ 0\n"
1136 "bgtlrl+\n"
1137 "bgtlrl+ 0\n"
1138 "bgtctr\n"
1139 "bgtctr 0\n"
1140 "bgtctrl\n"
1141 "bgtctrl 0\n"
1142 "bgtctr-\n"
1143 "bgtctr- 0\n"
1144 "bgtctrl-\n"
1145 "bgtctrl- 0\n"
1146 "bgtctr+\n"
1147 "bgtctr+ 0\n"
1148 "bgtctrl+\n"
1149 "bgtctrl+ 0\n"
1150 "bnllr\n"
1151 "bnllr 0\n"
1152 "bnllrl\n"
1153 "bnllrl 0\n"
1154 "bnllr-\n"
1155 "bnllr- 0\n"
1156 "bnllrl-\n"
1157 "bnllrl- 0\n"
1158 "bnllr+\n"
1159 "bnllr+ 0\n"
1160 "bnllrl+\n"
1161 "bnllrl+ 0\n"
1162 "bnlctr\n"
1163 "bnlctr 0\n"
1164 "bnlctrl\n"
1165 "bnlctrl 0\n"
1166 "bnlctr-\n"
1167 "bnlctr- 0\n"
1168 "bnlctrl-\n"
1169 "bnlctrl- 0\n"
1170 "bnlctr+\n"
1171 "bnlctr+ 0\n"
1172 "bnlctrl+\n"
1173 "bnlctrl+ 0\n"
1174 "bnelr\n"
1175 "bnelr 0\n"
1176 "bnelrl\n"
1177 "bnelrl 0\n"
1178 "bnelr-\n"
1179 "bnelr- 0\n"
1180 "bnelrl-\n"
1181 "bnelrl- 0\n"
1182 "bnelr+\n"
1183 "bnelr+ 0\n"
1184 "bnelrl+\n"
1185 "bnelrl+ 0\n"
1186 "bnectr\n"
1187 "bnectr 0\n"
1188 "bnectrl\n"
1189 "bnectrl 0\n"
1190 "bnectr-\n"
1191 "bnectr- 0\n"
1192 "bnectrl-\n"
1193 "bnectrl- 0\n"
1194 "bnectr+\n"
1195 "bnectr+ 0\n"
1196 "bnectrl+\n"
1197 "bnectrl+ 0\n"
1198 "bnglr\n"
1199 "bnglr 0\n"
1200 "bnglrl\n"
1201 "bnglrl 0\n"
1202 "bnglr-\n"
1203 "bnglr- 0\n"
1204 "bnglrl-\n"
1205 "bnglrl- 0\n"
1206 "bnglr+\n"
1207 "bnglr+ 0\n"
1208 "bnglrl+\n"
1209 "bnglrl+ 0\n"
1210 "bngctr\n"
1211 "bngctr 0\n"
1212 "bngctrl\n"
1213 "bngctrl 0\n"
1214 "bngctr-\n"
1215 "bngctr- 0\n"
1216 "bngctrl-\n"
1217 "bngctrl- 0\n"
1218 "bngctr+\n"
1219 "bngctr+ 0\n"
1220 "bngctrl+\n"
1221 "bngctrl+ 0\n"
1222 "bsolr\n"
1223 "bsolr 0\n"
1224 "bsolrl\n"
1225 "bsolrl 0\n"
1226 "bsolr-\n"
1227 "bsolr- 0\n"
1228 "bsolrl-\n"
1229 "bsolrl- 0\n"
1230 "bsolr+\n"
1231 "bsolr+ 0\n"
1232 "bsolrl+\n"
1233 "bsolrl+ 0\n"
1234 "bsoctr\n"
1235 "bsoctr 0\n"
1236 "bsoctrl\n"
1237 "bsoctrl 0\n"
1238 "bsoctr-\n"
1239 "bsoctr- 0\n"
1240 "bsoctrl-\n"
1241 "bsoctrl- 0\n"
1242 "bsoctr+\n"
1243 "bsoctr+ 0\n"
1244 "bsoctrl+\n"
1245 "bsoctrl+ 0\n"
1246 "bnslr\n"
1247 "bnslr 0\n"
1248 "bnslrl\n"
1249 "bnslrl 0\n"
1250 "bnslr-\n"
1251 "bnslr- 0\n"
1252 "bnslrl-\n"
1253 "bnslrl- 0\n"
1254 "bnslr+\n"
1255 "bnslr+ 0\n"
1256 "bnslrl+\n"
1257 "bnslrl+ 0\n"
1258 "bnsctr\n"
1259 "bnsctr 0\n"
1260 "bnsctrl\n"
1261 "bnsctrl 0\n"
1262 "bnsctr-\n"
1263 "bnsctr- 0\n"
1264 "bnsctrl-\n"
1265 "bnsctrl- 0\n"
1266 "bnsctr+\n"
1267 "bnsctr+ 0\n"
1268 "bnsctrl+\n"
1269 "bnsctrl+ 0\n"
1270 "bunlr\n"
1271 "bunlr 0\n"
1272 "bunlrl\n"
1273 "bunlrl 0\n"
1274 "bunlr-\n"
1275 "bunlr- 0\n"
1276 "bunlrl-\n"
1277 "bunlrl- 0\n"
1278 "bunlr+\n"
1279 "bunlr+ 0\n"
1280 "bunlrl+\n"
1281 "bunlrl+ 0\n"
1282 "bunctr\n"
1283 "bunctr 0\n"
1284 "bunctrl\n"
1285 "bunctrl 0\n"
1286 "bunctr-\n"
1287 "bunctr- 0\n"
1288 "bunctrl-\n"
1289 "bunctrl- 0\n"
1290 "bunctr+\n"
1291 "bunctr+ 0\n"
1292 "bunctrl+\n"
1293 "bunctrl+ 0\n"
1294 "bnulr\n"
1295 "bnulr 0\n"
1296 "bnulrl\n"
1297 "bnulrl 0\n"
1298 "bnulr-\n"
1299 "bnulr- 0\n"
1300 "bnulrl-\n"
1301 "bnulrl- 0\n"
1302 "bnulr+\n"
1303 "bnulr+ 0\n"
1304 "bnulrl+\n"
1305 "bnulrl+ 0\n"
1306 "bnuctr\n"
1307 "bnuctr 0\n"
1308 "bnuctrl\n"
1309 "bnuctrl 0\n"
1310 "bnuctr-\n"
1311 "bnuctr- 0\n"
1312 "bnuctrl-\n"
1313 "bnuctrl- 0\n"
1314 "bnuctr+\n"
1315 "bnuctr+ 0\n"
1316 "bnuctrl+\n"
1317 "bnuctrl+ 0\n";
1318
1319 constexpr u8 extended_expect[] = {
1320 0x38, 0x04, 0xff, 0xf8, 0x3c, 0x04, 0xff, 0xf8, 0x30, 0x04, 0xff, 0xf8, 0x34, 0x04, 0xff, 0xf8,
1321 0x2c, 0x00, 0x00, 0x04, 0x2c, 0x04, 0x00, 0x08, 0x7c, 0x00, 0x20, 0x00, 0x7c, 0x04, 0x40, 0x00,
1322 0x28, 0x00, 0x00, 0x04, 0x28, 0x04, 0x00, 0x08, 0x7c, 0x00, 0x20, 0x40, 0x7c, 0x04, 0x40, 0x40,
1323 0x4c, 0x00, 0x02, 0x42, 0x4c, 0x00, 0x01, 0x82, 0x4c, 0x04, 0x23, 0x82, 0x4c, 0x04, 0x20, 0x42,
1324 0x7e, 0x00, 0x20, 0x08, 0x0e, 0x00, 0x00, 0x04, 0x7e, 0x80, 0x20, 0x08, 0x0e, 0x80, 0x00, 0x04,
1325 0x7c, 0x80, 0x20, 0x08, 0x0c, 0x80, 0x00, 0x04, 0x7d, 0x80, 0x20, 0x08, 0x0d, 0x80, 0x00, 0x04,
1326 0x7d, 0x00, 0x20, 0x08, 0x0d, 0x00, 0x00, 0x04, 0x7d, 0x80, 0x20, 0x08, 0x0d, 0x80, 0x00, 0x04,
1327 0x7f, 0x00, 0x20, 0x08, 0x0f, 0x00, 0x00, 0x04, 0x7e, 0x80, 0x20, 0x08, 0x0e, 0x80, 0x00, 0x04,
1328 0x7c, 0x40, 0x20, 0x08, 0x0c, 0x40, 0x00, 0x04, 0x7c, 0xc0, 0x20, 0x08, 0x0c, 0xc0, 0x00, 0x04,
1329 0x7c, 0xa0, 0x20, 0x08, 0x0c, 0xa0, 0x00, 0x04, 0x7c, 0x20, 0x20, 0x08, 0x0c, 0x20, 0x00, 0x04,
1330 0x7c, 0xa0, 0x20, 0x08, 0x0c, 0xa0, 0x00, 0x04, 0x7c, 0xc0, 0x20, 0x08, 0x0c, 0xc0, 0x00, 0x04,
1331 0x7f, 0xe0, 0x00, 0x08, 0x7c, 0x01, 0x03, 0xa6, 0x7c, 0x01, 0x02, 0xa6, 0x7c, 0x08, 0x03, 0xa6,
1332 0x7c, 0x08, 0x02, 0xa6, 0x7c, 0x09, 0x03, 0xa6, 0x7c, 0x09, 0x02, 0xa6, 0x7c, 0x12, 0x03, 0xa6,
1333 0x7c, 0x12, 0x02, 0xa6, 0x7c, 0x13, 0x03, 0xa6, 0x7c, 0x13, 0x02, 0xa6, 0x7c, 0x16, 0x03, 0xa6,
1334 0x7c, 0x16, 0x02, 0xa6, 0x7c, 0x19, 0x03, 0xa6, 0x7c, 0x19, 0x02, 0xa6, 0x7c, 0x1a, 0x03, 0xa6,
1335 0x7c, 0x1a, 0x02, 0xa6, 0x7c, 0x1b, 0x03, 0xa6, 0x7c, 0x1b, 0x02, 0xa6, 0x7c, 0x1a, 0x43, 0xa6,
1336 0x7c, 0x1a, 0x42, 0xa6, 0x7c, 0x1c, 0x43, 0xa6, 0x7c, 0x0c, 0x42, 0xe6, 0x7c, 0x1d, 0x43, 0xa6,
1337 0x7c, 0x0d, 0x42, 0xe6, 0x7c, 0x90, 0x43, 0xa6, 0x7c, 0x11, 0x42, 0xa6, 0x7c, 0x30, 0x83, 0xa6,
1338 0x7c, 0x12, 0x82, 0xa6, 0x7c, 0x31, 0x83, 0xa6, 0x7c, 0x13, 0x82, 0xa6, 0x7c, 0x38, 0x83, 0xa6,
1339 0x7c, 0x1a, 0x82, 0xa6, 0x7c, 0x39, 0x83, 0xa6, 0x7c, 0x1b, 0x82, 0xa6, 0x60, 0x00, 0x00, 0x00,
1340 0x38, 0x00, 0x00, 0x04, 0x3c, 0x00, 0x00, 0x04, 0x38, 0x08, 0x00, 0x04, 0x7c, 0x0f, 0xf1, 0x20,
1341 0x7c, 0x04, 0x02, 0xa6, 0x7c, 0x0c, 0x42, 0xe6, 0x7c, 0x80, 0x03, 0xa6, 0x7c, 0x08, 0x20, 0x50,
1342 0x7c, 0x08, 0x20, 0x51, 0x7c, 0x08, 0x24, 0x50, 0x7c, 0x08, 0x24, 0x51, 0x7c, 0x08, 0x20, 0x10,
1343 0x7c, 0x08, 0x20, 0x11, 0x7c, 0x08, 0x24, 0x10, 0x7c, 0x08, 0x24, 0x11, 0x54, 0x80, 0x60, 0x0e,
1344 0x54, 0x80, 0x60, 0x0f, 0x54, 0x80, 0xa6, 0x3e, 0x54, 0x80, 0xa6, 0x3f, 0x50, 0x80, 0xa3, 0x26,
1345 0x50, 0x80, 0xa3, 0x27, 0x50, 0x80, 0x63, 0x26, 0x50, 0x80, 0x63, 0x27, 0x54, 0x80, 0x40, 0x3e,
1346 0x54, 0x80, 0x40, 0x3f, 0x54, 0x80, 0xc0, 0x3e, 0x54, 0x80, 0xc0, 0x3f, 0x5c, 0x80, 0x40, 0x3e,
1347 0x5c, 0x80, 0x40, 0x3f, 0x54, 0x80, 0x40, 0x2e, 0x54, 0x80, 0x40, 0x2f, 0x54, 0x80, 0xc2, 0x3e,
1348 0x54, 0x80, 0xc2, 0x3f, 0x54, 0x80, 0x02, 0x3e, 0x54, 0x80, 0x02, 0x3f, 0x54, 0x80, 0x00, 0x2e,
1349 0x54, 0x80, 0x00, 0x2f, 0x54, 0x80, 0x41, 0x2e, 0x54, 0x80, 0x41, 0x2f, 0x7c, 0x80, 0x23, 0x78,
1350 0x7c, 0x80, 0x23, 0x79, 0x7c, 0x80, 0x20, 0xf8, 0x7c, 0x80, 0x20, 0xf9, 0x41, 0x80, 0x00, 0x04,
1351 0x41, 0x80, 0x00, 0x05, 0x41, 0x80, 0x00, 0x06, 0x41, 0x80, 0x00, 0x07, 0x41, 0x80, 0x00, 0x04,
1352 0x41, 0x80, 0x00, 0x05, 0x41, 0x80, 0x00, 0x06, 0x41, 0x80, 0x00, 0x07, 0x41, 0xa0, 0x00, 0x04,
1353 0x41, 0xa0, 0x00, 0x05, 0x41, 0xa0, 0x00, 0x06, 0x41, 0xa0, 0x00, 0x07, 0x40, 0x80, 0x00, 0x04,
1354 0x40, 0x80, 0x00, 0x05, 0x40, 0x80, 0x00, 0x06, 0x40, 0x80, 0x00, 0x07, 0x40, 0x80, 0x00, 0x04,
1355 0x40, 0x80, 0x00, 0x05, 0x40, 0x80, 0x00, 0x06, 0x40, 0x80, 0x00, 0x07, 0x40, 0xa0, 0x00, 0x04,
1356 0x40, 0xa0, 0x00, 0x05, 0x40, 0xa0, 0x00, 0x06, 0x40, 0xa0, 0x00, 0x07, 0x42, 0x00, 0x00, 0x00,
1357 0x42, 0x00, 0x00, 0x01, 0x42, 0x00, 0x00, 0x02, 0x42, 0x00, 0x00, 0x03, 0x42, 0x00, 0x00, 0x00,
1358 0x42, 0x00, 0x00, 0x01, 0x42, 0x00, 0x00, 0x02, 0x42, 0x00, 0x00, 0x03, 0x42, 0x20, 0x00, 0x00,
1359 0x42, 0x20, 0x00, 0x01, 0x42, 0x20, 0x00, 0x02, 0x42, 0x20, 0x00, 0x03, 0x41, 0x00, 0x00, 0x04,
1360 0x41, 0x00, 0x00, 0x05, 0x41, 0x00, 0x00, 0x06, 0x41, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x04,
1361 0x41, 0x00, 0x00, 0x05, 0x41, 0x00, 0x00, 0x06, 0x41, 0x00, 0x00, 0x07, 0x41, 0x20, 0x00, 0x04,
1362 0x41, 0x20, 0x00, 0x05, 0x41, 0x20, 0x00, 0x06, 0x41, 0x20, 0x00, 0x07, 0x40, 0x00, 0x00, 0x04,
1363 0x40, 0x00, 0x00, 0x05, 0x40, 0x00, 0x00, 0x06, 0x40, 0x00, 0x00, 0x07, 0x40, 0x00, 0x00, 0x04,
1364 0x40, 0x00, 0x00, 0x05, 0x40, 0x00, 0x00, 0x06, 0x40, 0x00, 0x00, 0x07, 0x40, 0x20, 0x00, 0x04,
1365 0x40, 0x20, 0x00, 0x05, 0x40, 0x20, 0x00, 0x06, 0x40, 0x20, 0x00, 0x07, 0x42, 0x40, 0x00, 0x00,
1366 0x42, 0x40, 0x00, 0x01, 0x42, 0x40, 0x00, 0x02, 0x42, 0x40, 0x00, 0x03, 0x42, 0x40, 0x00, 0x00,
1367 0x42, 0x40, 0x00, 0x01, 0x42, 0x40, 0x00, 0x02, 0x42, 0x40, 0x00, 0x03, 0x42, 0x60, 0x00, 0x00,
1368 0x42, 0x60, 0x00, 0x01, 0x42, 0x60, 0x00, 0x02, 0x42, 0x60, 0x00, 0x03, 0x41, 0x40, 0x00, 0x04,
1369 0x41, 0x40, 0x00, 0x05, 0x41, 0x40, 0x00, 0x06, 0x41, 0x40, 0x00, 0x07, 0x41, 0x40, 0x00, 0x04,
1370 0x41, 0x40, 0x00, 0x05, 0x41, 0x40, 0x00, 0x06, 0x41, 0x40, 0x00, 0x07, 0x41, 0x60, 0x00, 0x04,
1371 0x41, 0x60, 0x00, 0x05, 0x41, 0x60, 0x00, 0x06, 0x41, 0x60, 0x00, 0x07, 0x40, 0x40, 0x00, 0x04,
1372 0x40, 0x40, 0x00, 0x05, 0x40, 0x40, 0x00, 0x06, 0x40, 0x40, 0x00, 0x07, 0x40, 0x40, 0x00, 0x04,
1373 0x40, 0x40, 0x00, 0x05, 0x40, 0x40, 0x00, 0x06, 0x40, 0x40, 0x00, 0x07, 0x40, 0x60, 0x00, 0x04,
1374 0x40, 0x60, 0x00, 0x05, 0x40, 0x60, 0x00, 0x06, 0x40, 0x60, 0x00, 0x07, 0x41, 0x80, 0x00, 0x00,
1375 0x41, 0x80, 0x00, 0x04, 0x41, 0x80, 0x00, 0x01, 0x41, 0x80, 0x00, 0x05, 0x41, 0x80, 0x00, 0x02,
1376 0x41, 0x80, 0x00, 0x06, 0x41, 0x80, 0x00, 0x03, 0x41, 0x80, 0x00, 0x07, 0x41, 0x80, 0x00, 0x00,
1377 0x41, 0x80, 0x00, 0x04, 0x41, 0x80, 0x00, 0x01, 0x41, 0x80, 0x00, 0x05, 0x41, 0x80, 0x00, 0x02,
1378 0x41, 0x80, 0x00, 0x06, 0x41, 0x80, 0x00, 0x03, 0x41, 0x80, 0x00, 0x07, 0x41, 0xa0, 0x00, 0x00,
1379 0x41, 0xa0, 0x00, 0x04, 0x41, 0xa0, 0x00, 0x01, 0x41, 0xa0, 0x00, 0x05, 0x41, 0xa0, 0x00, 0x02,
1380 0x41, 0xa0, 0x00, 0x06, 0x41, 0xa0, 0x00, 0x03, 0x41, 0xa0, 0x00, 0x07, 0x40, 0x81, 0x00, 0x00,
1381 0x40, 0x81, 0x00, 0x04, 0x40, 0x81, 0x00, 0x01, 0x40, 0x81, 0x00, 0x05, 0x40, 0x81, 0x00, 0x02,
1382 0x40, 0x81, 0x00, 0x06, 0x40, 0x81, 0x00, 0x03, 0x40, 0x81, 0x00, 0x07, 0x40, 0x81, 0x00, 0x00,
1383 0x40, 0x81, 0x00, 0x04, 0x40, 0x81, 0x00, 0x01, 0x40, 0x81, 0x00, 0x05, 0x40, 0x81, 0x00, 0x02,
1384 0x40, 0x81, 0x00, 0x06, 0x40, 0x81, 0x00, 0x03, 0x40, 0x81, 0x00, 0x07, 0x40, 0xa1, 0x00, 0x00,
1385 0x40, 0xa1, 0x00, 0x04, 0x40, 0xa1, 0x00, 0x01, 0x40, 0xa1, 0x00, 0x05, 0x40, 0xa1, 0x00, 0x02,
1386 0x40, 0xa1, 0x00, 0x06, 0x40, 0xa1, 0x00, 0x03, 0x40, 0xa1, 0x00, 0x07, 0x41, 0x82, 0x00, 0x00,
1387 0x41, 0x82, 0x00, 0x04, 0x41, 0x82, 0x00, 0x01, 0x41, 0x82, 0x00, 0x05, 0x41, 0x82, 0x00, 0x02,
1388 0x41, 0x82, 0x00, 0x06, 0x41, 0x82, 0x00, 0x03, 0x41, 0x82, 0x00, 0x07, 0x41, 0x82, 0x00, 0x00,
1389 0x41, 0x82, 0x00, 0x04, 0x41, 0x82, 0x00, 0x01, 0x41, 0x82, 0x00, 0x05, 0x41, 0x82, 0x00, 0x02,
1390 0x41, 0x82, 0x00, 0x06, 0x41, 0x82, 0x00, 0x03, 0x41, 0x82, 0x00, 0x07, 0x41, 0xa2, 0x00, 0x00,
1391 0x41, 0xa2, 0x00, 0x04, 0x41, 0xa2, 0x00, 0x01, 0x41, 0xa2, 0x00, 0x05, 0x41, 0xa2, 0x00, 0x02,
1392 0x41, 0xa2, 0x00, 0x06, 0x41, 0xa2, 0x00, 0x03, 0x41, 0xa2, 0x00, 0x07, 0x40, 0x80, 0x00, 0x00,
1393 0x40, 0x80, 0x00, 0x04, 0x40, 0x80, 0x00, 0x01, 0x40, 0x80, 0x00, 0x05, 0x40, 0x80, 0x00, 0x02,
1394 0x40, 0x80, 0x00, 0x06, 0x40, 0x80, 0x00, 0x03, 0x40, 0x80, 0x00, 0x07, 0x40, 0x80, 0x00, 0x00,
1395 0x40, 0x80, 0x00, 0x04, 0x40, 0x80, 0x00, 0x01, 0x40, 0x80, 0x00, 0x05, 0x40, 0x80, 0x00, 0x02,
1396 0x40, 0x80, 0x00, 0x06, 0x40, 0x80, 0x00, 0x03, 0x40, 0x80, 0x00, 0x07, 0x40, 0xa0, 0x00, 0x00,
1397 0x40, 0xa0, 0x00, 0x04, 0x40, 0xa0, 0x00, 0x01, 0x40, 0xa0, 0x00, 0x05, 0x40, 0xa0, 0x00, 0x02,
1398 0x40, 0xa0, 0x00, 0x06, 0x40, 0xa0, 0x00, 0x03, 0x40, 0xa0, 0x00, 0x07, 0x41, 0x81, 0x00, 0x00,
1399 0x41, 0x81, 0x00, 0x04, 0x41, 0x81, 0x00, 0x01, 0x41, 0x81, 0x00, 0x05, 0x41, 0x81, 0x00, 0x02,
1400 0x41, 0x81, 0x00, 0x06, 0x41, 0x81, 0x00, 0x03, 0x41, 0x81, 0x00, 0x07, 0x41, 0x81, 0x00, 0x00,
1401 0x41, 0x81, 0x00, 0x04, 0x41, 0x81, 0x00, 0x01, 0x41, 0x81, 0x00, 0x05, 0x41, 0x81, 0x00, 0x02,
1402 0x41, 0x81, 0x00, 0x06, 0x41, 0x81, 0x00, 0x03, 0x41, 0x81, 0x00, 0x07, 0x41, 0xa1, 0x00, 0x00,
1403 0x41, 0xa1, 0x00, 0x04, 0x41, 0xa1, 0x00, 0x01, 0x41, 0xa1, 0x00, 0x05, 0x41, 0xa1, 0x00, 0x02,
1404 0x41, 0xa1, 0x00, 0x06, 0x41, 0xa1, 0x00, 0x03, 0x41, 0xa1, 0x00, 0x07, 0x40, 0x80, 0x00, 0x00,
1405 0x40, 0x80, 0x00, 0x04, 0x40, 0x80, 0x00, 0x01, 0x40, 0x80, 0x00, 0x05, 0x40, 0x80, 0x00, 0x02,
1406 0x40, 0x80, 0x00, 0x06, 0x40, 0x80, 0x00, 0x03, 0x40, 0x80, 0x00, 0x07, 0x40, 0x80, 0x00, 0x00,
1407 0x40, 0x80, 0x00, 0x04, 0x40, 0x80, 0x00, 0x01, 0x40, 0x80, 0x00, 0x05, 0x40, 0x80, 0x00, 0x02,
1408 0x40, 0x80, 0x00, 0x06, 0x40, 0x80, 0x00, 0x03, 0x40, 0x80, 0x00, 0x07, 0x40, 0xa0, 0x00, 0x00,
1409 0x40, 0xa0, 0x00, 0x04, 0x40, 0xa0, 0x00, 0x01, 0x40, 0xa0, 0x00, 0x05, 0x40, 0xa0, 0x00, 0x02,
1410 0x40, 0xa0, 0x00, 0x06, 0x40, 0xa0, 0x00, 0x03, 0x40, 0xa0, 0x00, 0x07, 0x40, 0x82, 0x00, 0x00,
1411 0x40, 0x82, 0x00, 0x04, 0x40, 0x82, 0x00, 0x01, 0x40, 0x82, 0x00, 0x05, 0x40, 0x82, 0x00, 0x02,
1412 0x40, 0x82, 0x00, 0x06, 0x40, 0x82, 0x00, 0x03, 0x40, 0x82, 0x00, 0x07, 0x40, 0x82, 0x00, 0x00,
1413 0x40, 0x82, 0x00, 0x04, 0x40, 0x82, 0x00, 0x01, 0x40, 0x82, 0x00, 0x05, 0x40, 0x82, 0x00, 0x02,
1414 0x40, 0x82, 0x00, 0x06, 0x40, 0x82, 0x00, 0x03, 0x40, 0x82, 0x00, 0x07, 0x40, 0xa2, 0x00, 0x00,
1415 0x40, 0xa2, 0x00, 0x04, 0x40, 0xa2, 0x00, 0x01, 0x40, 0xa2, 0x00, 0x05, 0x40, 0xa2, 0x00, 0x02,
1416 0x40, 0xa2, 0x00, 0x06, 0x40, 0xa2, 0x00, 0x03, 0x40, 0xa2, 0x00, 0x07, 0x40, 0x81, 0x00, 0x00,
1417 0x40, 0x81, 0x00, 0x04, 0x40, 0x81, 0x00, 0x01, 0x40, 0x81, 0x00, 0x05, 0x40, 0x81, 0x00, 0x02,
1418 0x40, 0x81, 0x00, 0x06, 0x40, 0x81, 0x00, 0x03, 0x40, 0x81, 0x00, 0x07, 0x40, 0x81, 0x00, 0x00,
1419 0x40, 0x81, 0x00, 0x04, 0x40, 0x81, 0x00, 0x01, 0x40, 0x81, 0x00, 0x05, 0x40, 0x81, 0x00, 0x02,
1420 0x40, 0x81, 0x00, 0x06, 0x40, 0x81, 0x00, 0x03, 0x40, 0x81, 0x00, 0x07, 0x40, 0xa1, 0x00, 0x00,
1421 0x40, 0xa1, 0x00, 0x04, 0x40, 0xa1, 0x00, 0x01, 0x40, 0xa1, 0x00, 0x05, 0x40, 0xa1, 0x00, 0x02,
1422 0x40, 0xa1, 0x00, 0x06, 0x40, 0xa1, 0x00, 0x03, 0x40, 0xa1, 0x00, 0x07, 0x41, 0x83, 0x00, 0x00,
1423 0x41, 0x83, 0x00, 0x04, 0x41, 0x83, 0x00, 0x01, 0x41, 0x83, 0x00, 0x05, 0x41, 0x83, 0x00, 0x02,
1424 0x41, 0x83, 0x00, 0x06, 0x41, 0x83, 0x00, 0x03, 0x41, 0x83, 0x00, 0x07, 0x41, 0x83, 0x00, 0x00,
1425 0x41, 0x83, 0x00, 0x04, 0x41, 0x83, 0x00, 0x01, 0x41, 0x83, 0x00, 0x05, 0x41, 0x83, 0x00, 0x02,
1426 0x41, 0x83, 0x00, 0x06, 0x41, 0x83, 0x00, 0x03, 0x41, 0x83, 0x00, 0x07, 0x41, 0xa3, 0x00, 0x00,
1427 0x41, 0xa3, 0x00, 0x04, 0x41, 0xa3, 0x00, 0x01, 0x41, 0xa3, 0x00, 0x05, 0x41, 0xa3, 0x00, 0x02,
1428 0x41, 0xa3, 0x00, 0x06, 0x41, 0xa3, 0x00, 0x03, 0x41, 0xa3, 0x00, 0x07, 0x40, 0x83, 0x00, 0x00,
1429 0x40, 0x83, 0x00, 0x04, 0x40, 0x83, 0x00, 0x01, 0x40, 0x83, 0x00, 0x05, 0x40, 0x83, 0x00, 0x02,
1430 0x40, 0x83, 0x00, 0x06, 0x40, 0x83, 0x00, 0x03, 0x40, 0x83, 0x00, 0x07, 0x40, 0x83, 0x00, 0x00,
1431 0x40, 0x83, 0x00, 0x04, 0x40, 0x83, 0x00, 0x01, 0x40, 0x83, 0x00, 0x05, 0x40, 0x83, 0x00, 0x02,
1432 0x40, 0x83, 0x00, 0x06, 0x40, 0x83, 0x00, 0x03, 0x40, 0x83, 0x00, 0x07, 0x40, 0xa3, 0x00, 0x00,
1433 0x40, 0xa3, 0x00, 0x04, 0x40, 0xa3, 0x00, 0x01, 0x40, 0xa3, 0x00, 0x05, 0x40, 0xa3, 0x00, 0x02,
1434 0x40, 0xa3, 0x00, 0x06, 0x40, 0xa3, 0x00, 0x03, 0x40, 0xa3, 0x00, 0x07, 0x41, 0x83, 0x00, 0x00,
1435 0x41, 0x83, 0x00, 0x04, 0x41, 0x83, 0x00, 0x01, 0x41, 0x83, 0x00, 0x05, 0x41, 0x83, 0x00, 0x02,
1436 0x41, 0x83, 0x00, 0x06, 0x41, 0x83, 0x00, 0x03, 0x41, 0x83, 0x00, 0x07, 0x41, 0x83, 0x00, 0x00,
1437 0x41, 0x83, 0x00, 0x04, 0x41, 0x83, 0x00, 0x01, 0x41, 0x83, 0x00, 0x05, 0x41, 0x83, 0x00, 0x02,
1438 0x41, 0x83, 0x00, 0x06, 0x41, 0x83, 0x00, 0x03, 0x41, 0x83, 0x00, 0x07, 0x41, 0xa3, 0x00, 0x00,
1439 0x41, 0xa3, 0x00, 0x04, 0x41, 0xa3, 0x00, 0x01, 0x41, 0xa3, 0x00, 0x05, 0x41, 0xa3, 0x00, 0x02,
1440 0x41, 0xa3, 0x00, 0x06, 0x41, 0xa3, 0x00, 0x03, 0x41, 0xa3, 0x00, 0x07, 0x40, 0x83, 0x00, 0x00,
1441 0x40, 0x83, 0x00, 0x04, 0x40, 0x83, 0x00, 0x01, 0x40, 0x83, 0x00, 0x05, 0x40, 0x83, 0x00, 0x02,
1442 0x40, 0x83, 0x00, 0x06, 0x40, 0x83, 0x00, 0x03, 0x40, 0x83, 0x00, 0x07, 0x40, 0x83, 0x00, 0x00,
1443 0x40, 0x83, 0x00, 0x04, 0x40, 0x83, 0x00, 0x01, 0x40, 0x83, 0x00, 0x05, 0x40, 0x83, 0x00, 0x02,
1444 0x40, 0x83, 0x00, 0x06, 0x40, 0x83, 0x00, 0x03, 0x40, 0x83, 0x00, 0x07, 0x40, 0xa3, 0x00, 0x00,
1445 0x40, 0xa3, 0x00, 0x04, 0x40, 0xa3, 0x00, 0x01, 0x40, 0xa3, 0x00, 0x05, 0x40, 0xa3, 0x00, 0x02,
1446 0x40, 0xa3, 0x00, 0x06, 0x40, 0xa3, 0x00, 0x03, 0x40, 0xa3, 0x00, 0x07, 0x4e, 0x80, 0x00, 0x20,
1447 0x4e, 0x80, 0x00, 0x21, 0x4e, 0x80, 0x04, 0x20, 0x4e, 0x80, 0x04, 0x21, 0x4d, 0x80, 0x00, 0x20,
1448 0x4d, 0x80, 0x00, 0x21, 0x4d, 0x80, 0x00, 0x20, 0x4d, 0x80, 0x00, 0x21, 0x4d, 0xa0, 0x00, 0x20,
1449 0x4d, 0xa0, 0x00, 0x21, 0x4d, 0x80, 0x04, 0x20, 0x4d, 0x80, 0x04, 0x21, 0x4d, 0x80, 0x04, 0x20,
1450 0x4d, 0x80, 0x04, 0x21, 0x4d, 0xa0, 0x04, 0x20, 0x4d, 0xa0, 0x04, 0x21, 0x4c, 0x80, 0x00, 0x20,
1451 0x4c, 0x80, 0x00, 0x21, 0x4c, 0x80, 0x00, 0x20, 0x4c, 0x80, 0x00, 0x21, 0x4c, 0xa0, 0x00, 0x20,
1452 0x4c, 0xa0, 0x00, 0x21, 0x4c, 0x80, 0x04, 0x20, 0x4c, 0x80, 0x04, 0x21, 0x4c, 0x80, 0x04, 0x20,
1453 0x4c, 0x80, 0x04, 0x21, 0x4c, 0xa0, 0x04, 0x20, 0x4c, 0xa0, 0x04, 0x21, 0x4e, 0x00, 0x00, 0x20,
1454 0x4e, 0x00, 0x00, 0x21, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x21, 0x4e, 0x20, 0x00, 0x20,
1455 0x4e, 0x20, 0x00, 0x21, 0x4d, 0x00, 0x00, 0x20, 0x4d, 0x00, 0x00, 0x21, 0x4d, 0x00, 0x00, 0x20,
1456 0x4d, 0x00, 0x00, 0x21, 0x4d, 0x20, 0x00, 0x20, 0x4d, 0x20, 0x00, 0x21, 0x4c, 0x00, 0x00, 0x20,
1457 0x4c, 0x00, 0x00, 0x21, 0x4c, 0x00, 0x00, 0x20, 0x4c, 0x00, 0x00, 0x21, 0x4c, 0x20, 0x00, 0x20,
1458 0x4c, 0x20, 0x00, 0x21, 0x4e, 0x40, 0x00, 0x20, 0x4e, 0x40, 0x00, 0x21, 0x4e, 0x40, 0x00, 0x20,
1459 0x4e, 0x40, 0x00, 0x21, 0x4e, 0x60, 0x00, 0x20, 0x4e, 0x60, 0x00, 0x21, 0x4d, 0x40, 0x00, 0x20,
1460 0x4d, 0x40, 0x00, 0x21, 0x4d, 0x40, 0x00, 0x20, 0x4d, 0x40, 0x00, 0x21, 0x4d, 0x60, 0x00, 0x20,
1461 0x4d, 0x60, 0x00, 0x21, 0x4c, 0x40, 0x00, 0x20, 0x4c, 0x40, 0x00, 0x21, 0x4c, 0x40, 0x00, 0x20,
1462 0x4c, 0x40, 0x00, 0x21, 0x4c, 0x60, 0x00, 0x20, 0x4c, 0x60, 0x00, 0x21, 0x4d, 0x80, 0x00, 0x20,
1463 0x4d, 0x80, 0x00, 0x20, 0x4d, 0x80, 0x00, 0x21, 0x4d, 0x80, 0x00, 0x21, 0x4d, 0x80, 0x00, 0x20,
1464 0x4d, 0x80, 0x00, 0x20, 0x4d, 0x80, 0x00, 0x21, 0x4d, 0x80, 0x00, 0x21, 0x4d, 0xa0, 0x00, 0x20,
1465 0x4d, 0xa0, 0x00, 0x20, 0x4d, 0xa0, 0x00, 0x21, 0x4d, 0xa0, 0x00, 0x21, 0x4d, 0x80, 0x04, 0x20,
1466 0x4d, 0x80, 0x04, 0x20, 0x4d, 0x80, 0x04, 0x21, 0x4d, 0x80, 0x04, 0x21, 0x4d, 0x80, 0x04, 0x20,
1467 0x4d, 0x80, 0x04, 0x20, 0x4d, 0x80, 0x04, 0x21, 0x4d, 0x80, 0x04, 0x21, 0x4d, 0xa0, 0x04, 0x20,
1468 0x4d, 0xa0, 0x04, 0x20, 0x4d, 0xa0, 0x04, 0x21, 0x4d, 0xa0, 0x04, 0x21, 0x4c, 0x81, 0x00, 0x20,
1469 0x4c, 0x81, 0x00, 0x20, 0x4c, 0x81, 0x00, 0x21, 0x4c, 0x81, 0x00, 0x21, 0x4c, 0x81, 0x00, 0x20,
1470 0x4c, 0x81, 0x00, 0x20, 0x4c, 0x81, 0x00, 0x21, 0x4c, 0x81, 0x00, 0x21, 0x4c, 0xa1, 0x00, 0x20,
1471 0x4c, 0xa1, 0x00, 0x20, 0x4c, 0xa1, 0x00, 0x21, 0x4c, 0xa1, 0x00, 0x21, 0x4c, 0x81, 0x04, 0x20,
1472 0x4c, 0x81, 0x04, 0x20, 0x4c, 0x81, 0x04, 0x21, 0x4c, 0x81, 0x04, 0x21, 0x4c, 0x81, 0x04, 0x20,
1473 0x4c, 0x81, 0x04, 0x20, 0x4c, 0x81, 0x04, 0x21, 0x4c, 0x81, 0x04, 0x21, 0x4c, 0xa1, 0x04, 0x20,
1474 0x4c, 0xa1, 0x04, 0x20, 0x4c, 0xa1, 0x04, 0x21, 0x4c, 0xa1, 0x04, 0x21, 0x4d, 0x82, 0x00, 0x20,
1475 0x4d, 0x82, 0x00, 0x20, 0x4d, 0x82, 0x00, 0x21, 0x4d, 0x82, 0x00, 0x21, 0x4d, 0x82, 0x00, 0x20,
1476 0x4d, 0x82, 0x00, 0x20, 0x4d, 0x82, 0x00, 0x21, 0x4d, 0x82, 0x00, 0x21, 0x4d, 0xa2, 0x00, 0x20,
1477 0x4d, 0xa2, 0x00, 0x20, 0x4d, 0xa2, 0x00, 0x21, 0x4d, 0xa2, 0x00, 0x21, 0x4d, 0x82, 0x04, 0x20,
1478 0x4d, 0x82, 0x04, 0x20, 0x4d, 0x82, 0x04, 0x21, 0x4d, 0x82, 0x04, 0x21, 0x4d, 0x82, 0x04, 0x20,
1479 0x4d, 0x82, 0x04, 0x20, 0x4d, 0x82, 0x04, 0x21, 0x4d, 0x82, 0x04, 0x21, 0x4d, 0xa2, 0x04, 0x20,
1480 0x4d, 0xa2, 0x04, 0x20, 0x4d, 0xa2, 0x04, 0x21, 0x4d, 0xa2, 0x04, 0x21, 0x4c, 0x80, 0x00, 0x20,
1481 0x4c, 0x80, 0x00, 0x20, 0x4c, 0x80, 0x00, 0x21, 0x4c, 0x80, 0x00, 0x21, 0x4c, 0x80, 0x00, 0x20,
1482 0x4c, 0x80, 0x00, 0x20, 0x4c, 0x80, 0x00, 0x21, 0x4c, 0x80, 0x00, 0x21, 0x4c, 0xa0, 0x00, 0x20,
1483 0x4c, 0xa0, 0x00, 0x20, 0x4c, 0xa0, 0x00, 0x21, 0x4c, 0xa0, 0x00, 0x21, 0x4c, 0x80, 0x04, 0x20,
1484 0x4c, 0x80, 0x04, 0x20, 0x4c, 0x80, 0x04, 0x21, 0x4c, 0x80, 0x04, 0x21, 0x4c, 0x80, 0x04, 0x20,
1485 0x4c, 0x80, 0x04, 0x20, 0x4c, 0x80, 0x04, 0x21, 0x4c, 0x80, 0x04, 0x21, 0x4c, 0xa0, 0x04, 0x20,
1486 0x4c, 0xa0, 0x04, 0x20, 0x4c, 0xa0, 0x04, 0x21, 0x4c, 0xa0, 0x04, 0x21, 0x4d, 0x81, 0x00, 0x20,
1487 0x4d, 0x81, 0x00, 0x20, 0x4d, 0x81, 0x00, 0x21, 0x4d, 0x81, 0x00, 0x21, 0x4d, 0x81, 0x00, 0x20,
1488 0x4d, 0x81, 0x00, 0x20, 0x4d, 0x81, 0x00, 0x21, 0x4d, 0x81, 0x00, 0x21, 0x4d, 0xa1, 0x00, 0x20,
1489 0x4d, 0xa1, 0x00, 0x20, 0x4d, 0xa1, 0x00, 0x21, 0x4d, 0xa1, 0x00, 0x21, 0x4d, 0x81, 0x04, 0x20,
1490 0x4d, 0x81, 0x04, 0x20, 0x4d, 0x81, 0x04, 0x21, 0x4d, 0x81, 0x04, 0x21, 0x4d, 0x81, 0x04, 0x20,
1491 0x4d, 0x81, 0x04, 0x20, 0x4d, 0x81, 0x04, 0x21, 0x4d, 0x81, 0x04, 0x21, 0x4d, 0xa1, 0x04, 0x20,
1492 0x4d, 0xa1, 0x04, 0x20, 0x4d, 0xa1, 0x04, 0x21, 0x4d, 0xa1, 0x04, 0x21, 0x4c, 0x80, 0x00, 0x20,
1493 0x4c, 0x80, 0x00, 0x20, 0x4c, 0x80, 0x00, 0x21, 0x4c, 0x80, 0x00, 0x21, 0x4c, 0x80, 0x00, 0x20,
1494 0x4c, 0x80, 0x00, 0x20, 0x4c, 0x80, 0x00, 0x21, 0x4c, 0x80, 0x00, 0x21, 0x4c, 0xa0, 0x00, 0x20,
1495 0x4c, 0xa0, 0x00, 0x20, 0x4c, 0xa0, 0x00, 0x21, 0x4c, 0xa0, 0x00, 0x21, 0x4c, 0x80, 0x04, 0x20,
1496 0x4c, 0x80, 0x04, 0x20, 0x4c, 0x80, 0x04, 0x21, 0x4c, 0x80, 0x04, 0x21, 0x4c, 0x80, 0x04, 0x20,
1497 0x4c, 0x80, 0x04, 0x20, 0x4c, 0x80, 0x04, 0x21, 0x4c, 0x80, 0x04, 0x21, 0x4c, 0xa0, 0x04, 0x20,
1498 0x4c, 0xa0, 0x04, 0x20, 0x4c, 0xa0, 0x04, 0x21, 0x4c, 0xa0, 0x04, 0x21, 0x4c, 0x82, 0x00, 0x20,
1499 0x4c, 0x82, 0x00, 0x20, 0x4c, 0x82, 0x00, 0x21, 0x4c, 0x82, 0x00, 0x21, 0x4c, 0x82, 0x00, 0x20,
1500 0x4c, 0x82, 0x00, 0x20, 0x4c, 0x82, 0x00, 0x21, 0x4c, 0x82, 0x00, 0x21, 0x4c, 0xa2, 0x00, 0x20,
1501 0x4c, 0xa2, 0x00, 0x20, 0x4c, 0xa2, 0x00, 0x21, 0x4c, 0xa2, 0x00, 0x21, 0x4c, 0x82, 0x04, 0x20,
1502 0x4c, 0x82, 0x04, 0x20, 0x4c, 0x82, 0x04, 0x21, 0x4c, 0x82, 0x04, 0x21, 0x4c, 0x82, 0x04, 0x20,
1503 0x4c, 0x82, 0x04, 0x20, 0x4c, 0x82, 0x04, 0x21, 0x4c, 0x82, 0x04, 0x21, 0x4c, 0xa2, 0x04, 0x20,
1504 0x4c, 0xa2, 0x04, 0x20, 0x4c, 0xa2, 0x04, 0x21, 0x4c, 0xa2, 0x04, 0x21, 0x4c, 0x81, 0x00, 0x20,
1505 0x4c, 0x81, 0x00, 0x20, 0x4c, 0x81, 0x00, 0x21, 0x4c, 0x81, 0x00, 0x21, 0x4c, 0x81, 0x00, 0x20,
1506 0x4c, 0x81, 0x00, 0x20, 0x4c, 0x81, 0x00, 0x21, 0x4c, 0x81, 0x00, 0x21, 0x4c, 0xa1, 0x00, 0x20,
1507 0x4c, 0xa1, 0x00, 0x20, 0x4c, 0xa1, 0x00, 0x21, 0x4c, 0xa1, 0x00, 0x21, 0x4c, 0x81, 0x04, 0x20,
1508 0x4c, 0x81, 0x04, 0x20, 0x4c, 0x81, 0x04, 0x21, 0x4c, 0x81, 0x04, 0x21, 0x4c, 0x81, 0x04, 0x20,
1509 0x4c, 0x81, 0x04, 0x20, 0x4c, 0x81, 0x04, 0x21, 0x4c, 0x81, 0x04, 0x21, 0x4c, 0xa1, 0x04, 0x20,
1510 0x4c, 0xa1, 0x04, 0x20, 0x4c, 0xa1, 0x04, 0x21, 0x4c, 0xa1, 0x04, 0x21, 0x4d, 0x83, 0x00, 0x20,
1511 0x4d, 0x83, 0x00, 0x20, 0x4d, 0x83, 0x00, 0x21, 0x4d, 0x83, 0x00, 0x21, 0x4d, 0x83, 0x00, 0x20,
1512 0x4d, 0x83, 0x00, 0x20, 0x4d, 0x83, 0x00, 0x21, 0x4d, 0x83, 0x00, 0x21, 0x4d, 0xa3, 0x00, 0x20,
1513 0x4d, 0xa3, 0x00, 0x20, 0x4d, 0xa3, 0x00, 0x21, 0x4d, 0xa3, 0x00, 0x21, 0x4d, 0x83, 0x04, 0x20,
1514 0x4d, 0x83, 0x04, 0x20, 0x4d, 0x83, 0x04, 0x21, 0x4d, 0x83, 0x04, 0x21, 0x4d, 0x83, 0x04, 0x20,
1515 0x4d, 0x83, 0x04, 0x20, 0x4d, 0x83, 0x04, 0x21, 0x4d, 0x83, 0x04, 0x21, 0x4d, 0xa3, 0x04, 0x20,
1516 0x4d, 0xa3, 0x04, 0x20, 0x4d, 0xa3, 0x04, 0x21, 0x4d, 0xa3, 0x04, 0x21, 0x4c, 0x83, 0x00, 0x20,
1517 0x4c, 0x83, 0x00, 0x20, 0x4c, 0x83, 0x00, 0x21, 0x4c, 0x83, 0x00, 0x21, 0x4c, 0x83, 0x00, 0x20,
1518 0x4c, 0x83, 0x00, 0x20, 0x4c, 0x83, 0x00, 0x21, 0x4c, 0x83, 0x00, 0x21, 0x4c, 0xa3, 0x00, 0x20,
1519 0x4c, 0xa3, 0x00, 0x20, 0x4c, 0xa3, 0x00, 0x21, 0x4c, 0xa3, 0x00, 0x21, 0x4c, 0x83, 0x04, 0x20,
1520 0x4c, 0x83, 0x04, 0x20, 0x4c, 0x83, 0x04, 0x21, 0x4c, 0x83, 0x04, 0x21, 0x4c, 0x83, 0x04, 0x20,
1521 0x4c, 0x83, 0x04, 0x20, 0x4c, 0x83, 0x04, 0x21, 0x4c, 0x83, 0x04, 0x21, 0x4c, 0xa3, 0x04, 0x20,
1522 0x4c, 0xa3, 0x04, 0x20, 0x4c, 0xa3, 0x04, 0x21, 0x4c, 0xa3, 0x04, 0x21, 0x4d, 0x83, 0x00, 0x20,
1523 0x4d, 0x83, 0x00, 0x20, 0x4d, 0x83, 0x00, 0x21, 0x4d, 0x83, 0x00, 0x21, 0x4d, 0x83, 0x00, 0x20,
1524 0x4d, 0x83, 0x00, 0x20, 0x4d, 0x83, 0x00, 0x21, 0x4d, 0x83, 0x00, 0x21, 0x4d, 0xa3, 0x00, 0x20,
1525 0x4d, 0xa3, 0x00, 0x20, 0x4d, 0xa3, 0x00, 0x21, 0x4d, 0xa3, 0x00, 0x21, 0x4d, 0x83, 0x04, 0x20,
1526 0x4d, 0x83, 0x04, 0x20, 0x4d, 0x83, 0x04, 0x21, 0x4d, 0x83, 0x04, 0x21, 0x4d, 0x83, 0x04, 0x20,
1527 0x4d, 0x83, 0x04, 0x20, 0x4d, 0x83, 0x04, 0x21, 0x4d, 0x83, 0x04, 0x21, 0x4d, 0xa3, 0x04, 0x20,
1528 0x4d, 0xa3, 0x04, 0x20, 0x4d, 0xa3, 0x04, 0x21, 0x4d, 0xa3, 0x04, 0x21, 0x4c, 0x83, 0x00, 0x20,
1529 0x4c, 0x83, 0x00, 0x20, 0x4c, 0x83, 0x00, 0x21, 0x4c, 0x83, 0x00, 0x21, 0x4c, 0x83, 0x00, 0x20,
1530 0x4c, 0x83, 0x00, 0x20, 0x4c, 0x83, 0x00, 0x21, 0x4c, 0x83, 0x00, 0x21, 0x4c, 0xa3, 0x00, 0x20,
1531 0x4c, 0xa3, 0x00, 0x20, 0x4c, 0xa3, 0x00, 0x21, 0x4c, 0xa3, 0x00, 0x21, 0x4c, 0x83, 0x04, 0x20,
1532 0x4c, 0x83, 0x04, 0x20, 0x4c, 0x83, 0x04, 0x21, 0x4c, 0x83, 0x04, 0x21, 0x4c, 0x83, 0x04, 0x20,
1533 0x4c, 0x83, 0x04, 0x20, 0x4c, 0x83, 0x04, 0x21, 0x4c, 0x83, 0x04, 0x21, 0x4c, 0xa3, 0x04, 0x20,
1534 0x4c, 0xa3, 0x04, 0x20, 0x4c, 0xa3, 0x04, 0x21, 0x4c, 0xa3, 0x04, 0x21,
1535 };
1536
1537 TEST(Assembler, AllExtendedInstructions)
1538 {
1539 auto res = Assemble(extended_instructions, 0);
1540 ASSERT_TRUE(!IsFailure(res));
1541 auto&& code_blocks = GetT(res);
1542 ASSERT_EQ(code_blocks.size(), 1);
1543 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(extended_expect));
1544
1545 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1546 {
1547 EXPECT_EQ(code_blocks[0].instructions[i], extended_expect[i]) << "->i=" << i;
1548 }
1549 }
1550
1551 TEST(Assembler, ByteDirectivesSimple)
1552 {
1553 constexpr char assembly[] = ".byte 0\n"
1554 ".Byte 0xff\n"
1555 ".bYte 0x100\n"
1556 ".2bYTe 0\n"
1557 ".2bytE 0xff\n"
1558 ".2BYte 0x100\n"
1559 ".2bYTe 0xffff\n"
1560 ".2byTE 0x10000\n"
1561 ".4BytE 0\n"
1562 ".4BYTe 0xff\n"
1563 ".4bYTE 0x100\n"
1564 ".4ByTE 0xffff\n"
1565 ".4BYtE 0x10000\n"
1566 ".4BYTE 0xffffffff\n"
1567 ".4ByTe 0x100000000\n"
1568 ".8bYtE 0\n"
1569 ".8byte 0xff\n"
1570 ".8byte 0x100\n"
1571 ".8byte 0xffff\n"
1572 ".8byte 0x10000\n"
1573 ".8byte 0xffffffff\n"
1574 ".8byte 0x100000000\n"
1575 ".8byte 0xffffffffffffffff\n"
1576 ".8byte 0x10000000000000000\n";
1577 constexpr u8 expect[] = {
1578 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
1579 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00,
1580 0x01, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1581 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
1582 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
1583 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
1584 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1585 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1586 };
1587
1588 auto res = Assemble(assembly, 0);
1589 ASSERT_TRUE(!IsFailure(res));
1590 auto&& code_blocks = GetT(res);
1591 ASSERT_EQ(code_blocks.size(), 1);
1592 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expect));
1593
1594 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1595 {
1596 EXPECT_EQ(code_blocks[0].instructions[i], expect[i]) << " -> i=" << i;
1597 }
1598 }
1599
1600 TEST(Assembler, MultiOperandDirectives)
1601 {
1602 constexpr char assembly[] = ".byte 0, 1, 2\n"
1603 ".2byte 3, 4, 5\n"
1604 ".4byte 6, 7, 8\n"
1605 ".8byte 9, 10, 11\n";
1606 constexpr u8 expect[] = {
1607 0, 1, 2, 0, 3, 0, 4, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0,
1608 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 11,
1609 };
1610 auto res = Assemble(assembly, 0);
1611 ASSERT_TRUE(!IsFailure(res));
1612 auto&& code_blocks = GetT(res);
1613 ASSERT_EQ(code_blocks.size(), 1);
1614 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expect));
1615
1616 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1617 {
1618 EXPECT_EQ(code_blocks[0].instructions[i], expect[i]) << " -> i=" << i;
1619 }
1620 }
1621
1622 TEST(Assembler, OperandExpressionDirectives)
1623 {
1624 constexpr char assembly[] = ".byte 0 + 1, 1 * 4, 2 * 8\n"
1625 ".2byte 3*6*9, 5*5*12, 81/9\n"
1626 ".4byte 1<<12, 5>>3, 8^8\n"
1627 ".8byte 0b1010 & 0b1101, 0b1010 | 0b0101, 0x12 + 010\n";
1628 constexpr u8 expect[] = {
1629 1, 4, 16, 0, 162, 1, 44, 0, 9, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1630 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0x12 + 010,
1631 };
1632 auto res = Assemble(assembly, 0);
1633 ASSERT_TRUE(!IsFailure(res));
1634 auto&& code_blocks = GetT(res);
1635 ASSERT_EQ(code_blocks.size(), 1);
1636 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expect));
1637
1638 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1639 {
1640 EXPECT_EQ(code_blocks[0].instructions[i], expect[i]) << " -> i=" << i;
1641 }
1642 }
1643
1644 TEST(Assembler, FloatDirectives)
1645 {
1646 constexpr char assembly[] = ".float 0\n"
1647 ".float 1, 2, 3.0\n"
1648 ".float 1.25, 1.5e6, -2e-5\n"
1649 ".double 0\n"
1650 ".double 1, 2, 3.0\n"
1651 ".double 1.0000001, 0.0000025, .000006e9\n";
1652 constexpr u8 expect[] = {
1653 0, 0, 0, 0, 0x3f, 0x80, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x40,
1654 0x00, 0x00, 0x3f, 0xa0, 0x00, 0x00, 0x49, 0xb7, 0x1b, 0x00, 0xb7, 0xa7, 0xc5, 0xac,
1655 0, 0, 0, 0, 0, 0, 0, 0, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00,
1656 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x08, 0x00, 0x00,
1657 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x00, 0x1a, 0xd7, 0xf2, 0x9b, 0x3e, 0xc4,
1658 0xf8, 0xb5, 0x88, 0xe3, 0x68, 0xf1, 0x40, 0xb7, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
1659 };
1660 auto res = Assemble(assembly, 0);
1661 ASSERT_TRUE(!IsFailure(res));
1662 auto&& code_blocks = GetT(res);
1663 ASSERT_EQ(code_blocks.size(), 1);
1664 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expect));
1665
1666 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1667 {
1668 EXPECT_EQ(code_blocks[0].instructions[i], expect[i]) << " -> i=" << i;
1669 }
1670 }
1671
1672 TEST(Assembler, ZeroDirectives)
1673 {
1674 constexpr char assembly[] = ".zeros 0\n"
1675 ".zeros 1\n"
1676 ".zeros 5 + 5\n";
1677 constexpr u8 expect[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1678 auto res = Assemble(assembly, 0);
1679 ASSERT_TRUE(!IsFailure(res));
1680 auto&& code_blocks = GetT(res);
1681 ASSERT_EQ(code_blocks.size(), 1);
1682 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expect));
1683
1684 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1685 {
1686 EXPECT_EQ(code_blocks[0].instructions[i], expect[i]) << " -> i=" << i;
1687 }
1688 }
1689
1690 TEST(Assembler, StringDirectives)
1691 {
1692 constexpr char assembly[] = ".ascii \"test string\"\n"
1693 ".ascii \"string with \\n escapes \\r\"\n"
1694 ".ascii \"string with octals \\123 \\0\"\n"
1695 ".ascii \"string with hex \\x12\\x45\\x9912\"\n"
1696 ".asciz \"null terminator\"\n";
1697 constexpr u8 expect[] = {
1698 't', 'e', 's', 't', ' ', 's', 't', 'r', 'i', 'n', 'g', 's', 't', 'r', 'i', 'n',
1699 'g', ' ', 'w', 'i', 't', 'h', ' ', '\n', ' ', 'e', 's', 'c', 'a', 'p', 'e', 's',
1700 ' ', '\r', 's', 't', 'r', 'i', 'n', 'g', ' ', 'w', 'i', 't', 'h', ' ', 'o', 'c',
1701 't', 'a', 'l', 's', ' ', '\123', ' ', '\0', 's', 't', 'r', 'i', 'n', 'g', ' ', 'w',
1702 'i', 't', 'h', ' ', 'h', 'e', 'x', ' ', '\x12', '\x45', '\x12', 'n', 'u', 'l', 'l', ' ',
1703 't', 'e', 'r', 'm', 'i', 'n', 'a', 't', 'o', 'r', '\0'};
1704 auto res = Assemble(assembly, 0);
1705 ASSERT_TRUE(!IsFailure(res));
1706 auto&& code_blocks = GetT(res);
1707 ASSERT_EQ(code_blocks.size(), 1);
1708 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expect));
1709
1710 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1711 {
1712 EXPECT_EQ(code_blocks[0].instructions[i], expect[i]) << " -> i=" << i;
1713 }
1714 }
1715
1716 TEST(Assembler, RelocateDirective)
1717 {
1718 constexpr char assembly[] = ".zeros 5\n"
1719 ".locate 100\n"
1720 ".zeros 9\n"
1721 ".locate 110\n"
1722 ".zeros 10\n"
1723 ".locate 120\n"
1724 ".zeros 29\n"
1725 ".locate 120 + 5*5+4 + 1\n"
1726 ".zeros 1\n";
1727 constexpr u32 expect_addr[] = {0, 100, 110, 120, 150};
1728 constexpr size_t expect_size[] = {5, 9, 10, 29, 1};
1729
1730 auto res = Assemble(assembly, 0);
1731 ASSERT_TRUE(!IsFailure(res));
1732 auto&& code_blocks = GetT(res);
1733 ASSERT_EQ(code_blocks.size(), std::size(expect_size));
1734 for (size_t i = 0; i < code_blocks.size(); i++)
1735 {
1736 EXPECT_EQ(code_blocks[i].instructions.size(), expect_size[i]) << " -> i=" << i;
1737 EXPECT_EQ(code_blocks[i].block_address, expect_addr[i]) << " -> i=" << i;
1738 }
1739 }
1740
1741 TEST(Assembler, AlignmentDirectives)
1742 {
1743 constexpr char assembly_align[] = ".zeros 1\n"
1744 ".align 0\n"
1745 ".zeros 1\n"
1746 ".align 1\n"
1747 ".zeros 1\n"
1748 ".align 2\n"
1749 ".zeros 1\n"
1750 ".align 4\n"
1751 ".zeros 1\n"
1752 ".align 4\n"
1753 ".zeros 1\n"
1754 ".align 10\n"
1755 ".byte 1\n"
1756 ".padalign 0\n"
1757 ".byte 1\n"
1758 ".padalign 1\n"
1759 ".byte 1\n"
1760 ".padalign 2\n"
1761 ".byte 1\n"
1762 ".padalign 4\n"
1763 ".byte 1\n"
1764 ".padalign 4\n"
1765 ".byte 1\n"
1766 ".padalign 10\n";
1767 constexpr u32 expect_addr[] = {0, 4, 16, 32, 1024};
1768
1769 auto res = Assemble(assembly_align, 0);
1770 ASSERT_TRUE(!IsFailure(res));
1771 auto&& code_blocks = GetT(res);
1772 ASSERT_EQ(code_blocks.size(), std::size(expect_addr));
1773 for (size_t i = 0; i < code_blocks.size(); i++)
1774 {
1775 EXPECT_EQ(code_blocks[i].block_address, expect_addr[i]) << " -> i=" << i;
1776 }
1777
1778 auto&& last_block = code_blocks.back().instructions;
1779 ASSERT_EQ(last_block.size(), 1024);
1780 for (size_t i = 0; i < 3; i++)
1781 {
1782 EXPECT_EQ(last_block[i], 1) << " -> i=" << i;
1783 }
1784 EXPECT_EQ(last_block[3], 0) << " -> i=4";
1785 EXPECT_EQ(last_block[4], 1) << " -> i=4";
1786 for (size_t i = 5; i < 16; i++)
1787 {
1788 EXPECT_EQ(last_block[i], 0) << " -> i=" << i;
1789 }
1790 EXPECT_EQ(last_block[16], 1) << " -> i=16";
1791 for (size_t i = 17; i < 32; i++)
1792 {
1793 EXPECT_EQ(last_block[i], 0) << " -> i=" << i;
1794 }
1795 EXPECT_EQ(last_block[32], 1) << " -> i=32";
1796 for (size_t i = 33; i < last_block.size(); i++)
1797 {
1798 EXPECT_EQ(last_block[i], 0) << " -> i=" << i;
1799 }
1800 }
1801
1802 TEST(Assembler, SkipDirective)
1803 {
1804 constexpr char assembly_align[] = ".byte 5\n"
1805 ".skip 0\n"
1806 ".byte 6\n"
1807 ".skip 1\n"
1808 ".byte 7\n"
1809 ".skip 10 * 10\n"
1810 ".byte 8\n";
1811 constexpr u32 expect_addr[] = {0, 3, 104};
1812
1813 auto res = Assemble(assembly_align, 0);
1814 ASSERT_TRUE(!IsFailure(res));
1815 auto&& code_blocks = GetT(res);
1816 ASSERT_EQ(code_blocks.size(), std::size(expect_addr));
1817
1818 EXPECT_EQ(code_blocks[0].block_address, expect_addr[0]) << " -> i=0";
1819 ASSERT_EQ(code_blocks[0].instructions.size(), 2);
1820 EXPECT_EQ(code_blocks[0].instructions[0], 5) << " -> i=0";
1821 EXPECT_EQ(code_blocks[0].instructions[1], 6) << " -> i=0";
1822
1823 EXPECT_EQ(code_blocks[1].block_address, expect_addr[1]) << " -> i=1";
1824 ASSERT_EQ(code_blocks[1].instructions.size(), 1);
1825 EXPECT_EQ(code_blocks[1].instructions[0], 7) << " -> i=1";
1826
1827 EXPECT_EQ(code_blocks[2].block_address, expect_addr[2]) << " -> i=2";
1828 ASSERT_EQ(code_blocks[2].instructions.size(), 1);
1829 EXPECT_EQ(code_blocks[2].instructions[0], 8) << " -> i=2";
1830 }
1831
1832 TEST(Assembler, DefvarDirective)
1833 {
1834 constexpr char assembly[] = ".defvar NewVar, 0\n"
1835 ".defvar NewVar2, 123\n"
1836 ".defvar __Name, 1*2+3+4\n"
1837 ".defvar AB_cd00, 5*5+__Name\n"
1838 ".2byte NewVar\n"
1839 ".2byte NewVar2\n"
1840 ".4byte __Name\n"
1841 ".4byte AB_cd00\n"
1842 ".4byte AB_cd00 + NewVar2\n";
1843 constexpr u8 expect[] = {
1844 0, 0, 0, 123, 0, 0, 0, 9, 0, 0, 0, 34, 0, 0, 0, 157,
1845 };
1846
1847 auto res = Assemble(assembly, 0);
1848 ASSERT_TRUE(!IsFailure(res));
1849 auto&& code_blocks = GetT(res);
1850 ASSERT_EQ(code_blocks.size(), 1);
1851 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1852 {
1853 EXPECT_EQ(code_blocks[0].instructions[i], expect[i]) << " -> i=" << i;
1854 }
1855 }
1856
1857 TEST(Assembler, VariousOperandExpressions)
1858 {
1859 constexpr char assembly[] = ".locate 0x400\n"
1860 "b .\n"
1861 "b .\n"
1862 ".locate 0x800\n"
1863 "post_locate:\n"
1864 "b `0x900`\n"
1865 "b `0x800`\n"
1866 "b `. + 0x10`\n"
1867 "b post_locate\n"
1868 "lis r0, post_locate_2@ha\n"
1869 "ori r0, r0, post_locate_2@l\n"
1870 "li r0, TestValue\n"
1871 ".defvar TestValue, 1234\n"
1872 "li r0, TestValue\n"
1873 ".locate 0x80001234\n"
1874 "post_locate_2:\n";
1875 constexpr u8 expect_0[] = {
1876 0x48, 0x00, 0x04, 0x00, 0x48, 0x00, 0x04, 0x04,
1877 };
1878 constexpr u8 expect_1[] = {
1879 0x48, 0x00, 0x01, 0x00, 0x4b, 0xff, 0xff, 0xfc, 0x48, 0x00, 0x00,
1880 0x10, 0x4b, 0xff, 0xff, 0xf4, 0x3c, 0x00, 0x80, 0x00, 0x60, 0x00,
1881 0x12, 0x34, 0x38, 0x00, 0x04, 0xd2, 0x38, 0x00, 0x04, 0xd2,
1882 };
1883
1884 auto res = Assemble(assembly, 0);
1885 ASSERT_TRUE(!IsFailure(res));
1886 auto&& code_blocks = GetT(res);
1887 ASSERT_EQ(code_blocks.size(), 2);
1888
1889 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expect_0));
1890 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1891 {
1892 EXPECT_EQ(code_blocks[0].instructions[i], expect_0[i]) << " -> i=" << i;
1893 }
1894
1895 ASSERT_EQ(code_blocks[1].instructions.size(), sizeof(expect_1));
1896 for (size_t i = 0; i < code_blocks[1].instructions.size(); i++)
1897 {
1898 EXPECT_EQ(code_blocks[1].instructions[i], expect_1[i]) << " -> i=" << i;
1899 }
1900 }
1901
1902 TEST(Assembler, AbsRel)
1903 {
1904 constexpr char assembly[] = ".locate 0x80001234\n"
1905 "lbl0:\n"
1906 ".defvar abs_loc, lbl0\n"
1907 ".4byte lbl0\n"
1908 ".2byte lbl0@ha\n"
1909 ".2byte lbl0@l\n"
1910 ".4byte .\n"
1911 "b lbl0\n"
1912 "b `abs_loc`\n";
1913 constexpr u8 expect[] = {
1914 0x80, 0x00, 0x12, 0x34, 0x80, 0x00, 0x12, 0x34, 0x80, 0x00,
1915 0x12, 0x3c, 0x4b, 0xff, 0xff, 0xf4, 0x4b, 0xff, 0xff, 0xf0,
1916 };
1917
1918 auto res = Assemble(assembly, 0);
1919 ASSERT_TRUE(!IsFailure(res));
1920 auto&& code_blocks = GetT(res);
1921 ASSERT_EQ(code_blocks.size(), 1);
1922
1923 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expect));
1924 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
1925 {
1926 EXPECT_EQ(code_blocks[0].instructions[i], expect[i]) << " -> i=" << i;
1927 }
1928 }
1929
1930 TEST(Assembler, BadTokens)
1931 {
1932 constexpr char unterminated_str[] = ".ascii \"no terminator";
1933 constexpr char bad_hex_in_str[] = ".ascii \"\\xnot hex\"";
1934 constexpr char newline_in_str[] = ".ascii \"abc\nd\"";
1935 constexpr char bad_float_0[] = ".float";
1936 constexpr char bad_float_1[] = ".float 1.";
1937 constexpr char bad_float_2[] = ".float .";
1938 constexpr char bad_float_3[] = ".float -.5e";
1939 constexpr char bad_float_4[] = ".float -.6e+";
1940
1941 EXPECT_TRUE(IsFailure(Assemble(unterminated_str, 0)));
1942 EXPECT_TRUE(IsFailure(Assemble(bad_hex_in_str, 0)));
1943 EXPECT_TRUE(IsFailure(Assemble(newline_in_str, 0)));
1944 EXPECT_TRUE(IsFailure(Assemble(bad_float_0, 0)));
1945 EXPECT_TRUE(IsFailure(Assemble(bad_float_1, 0)));
1946 EXPECT_TRUE(IsFailure(Assemble(bad_float_2, 0)));
1947 EXPECT_TRUE(IsFailure(Assemble(bad_float_3, 0)));
1948 EXPECT_TRUE(IsFailure(Assemble(bad_float_4, 0)));
1949 }
1950
1951 TEST(Assembler, RangeTest)
1952 {
1953 constexpr char gpr_range_0[] = "mr r3, -1";
1954 constexpr char gpr_range_1[] = "mr r3, 0";
1955 constexpr char gpr_range_2[] = "mr r3, 32";
1956 constexpr char gpr_range_3[] = "mr r3, 31";
1957 constexpr char crf_range_0[] = "cmpw -1, 0, 0";
1958 constexpr char crf_range_1[] = "cmpw 0, 0, 0";
1959 constexpr char crf_range_2[] = "cmpw 8, 0, 0";
1960 constexpr char crf_range_3[] = "cmpw 7, 0, 0";
1961 constexpr char bc_range_0[] = "beq 1 << 15";
1962 constexpr char bc_range_1[] = "beq (1 << 15) - 4";
1963 constexpr char bc_range_2[] = "beq -(1 << 15) - 4";
1964 constexpr char bc_range_3[] = "beq -(1 << 15)";
1965 constexpr char b_range_0[] = "b 1 << 25";
1966 constexpr char b_range_1[] = "b (1 << 25) - 4";
1967 constexpr char b_range_2[] = "b -(1 << 25) - 4";
1968 constexpr char b_range_3[] = "b -(1 << 25)";
1969 constexpr char crb_range_0[] = "cror -1, -1, -1";
1970 constexpr char crb_range_1[] = "cror 0, 0, 0";
1971 constexpr char crb_range_2[] = "cror 32, 32, 32";
1972 constexpr char crb_range_3[] = "cror 31, 31, 31";
1973 constexpr char off_range_0[] = "lwz r0, 1 << 15(r3)";
1974 constexpr char off_range_1[] = "lwz r0, (1 << 15) - 1(r3)";
1975 constexpr char off_range_2[] = "lwz r0, -(1 << 15) - 1(r3)";
1976 constexpr char off_range_3[] = "lwz r0, -(1 << 15)(r3)";
1977 constexpr char psoff_range_0[] = "psq_l f0, 1 << 11(r3), 0, 0";
1978 constexpr char psoff_range_1[] = "psq_l f0, (1 << 11) - 1(r3), 0, 0";
1979 constexpr char psoff_range_2[] = "psq_l f0, -(1 << 11) - 1(r3), 0, 0";
1980 constexpr char psoff_range_3[] = "psq_l f0, -(1 << 11)(r3), 0, 0";
1981 constexpr char simm_range_0[] = "addi r0, r1, 0x8000";
1982 constexpr char simm_range_1[] = "addi r0, r1, 0x7fff";
1983 constexpr char simm_range_2[] = "addi r0, r1, -0x8001";
1984 constexpr char simm_range_3[] = "addi r0, r1, -0x8000";
1985 constexpr char uimm_range_0[] = "andi. r0, r1, 0x10000";
1986 constexpr char uimm_range_1[] = "andi. r0, r1, 0xffff";
1987 constexpr char uimm_range_2[] = "andi. r0, r1, -1";
1988 constexpr char uimm_range_3[] = "andi. r0, r1, 0";
1989
1990 EXPECT_TRUE(IsFailure(Assemble(gpr_range_0, 0)));
1991 EXPECT_TRUE(!IsFailure(Assemble(gpr_range_1, 0)));
1992 EXPECT_TRUE(IsFailure(Assemble(gpr_range_2, 0)));
1993 EXPECT_TRUE(!IsFailure(Assemble(gpr_range_3, 0)));
1994 EXPECT_TRUE(IsFailure(Assemble(crf_range_0, 0)));
1995 EXPECT_TRUE(!IsFailure(Assemble(crf_range_1, 0)));
1996 EXPECT_TRUE(IsFailure(Assemble(crf_range_2, 0)));
1997 EXPECT_TRUE(!IsFailure(Assemble(crf_range_3, 0)));
1998 EXPECT_TRUE(IsFailure(Assemble(bc_range_0, 0)));
1999 EXPECT_TRUE(!IsFailure(Assemble(bc_range_1, 0)));
2000 EXPECT_TRUE(IsFailure(Assemble(bc_range_2, 0)));
2001 EXPECT_TRUE(!IsFailure(Assemble(bc_range_3, 0)));
2002 EXPECT_TRUE(IsFailure(Assemble(b_range_0, 0)));
2003 EXPECT_TRUE(!IsFailure(Assemble(b_range_1, 0)));
2004 EXPECT_TRUE(IsFailure(Assemble(b_range_2, 0)));
2005 EXPECT_TRUE(!IsFailure(Assemble(b_range_3, 0)));
2006 EXPECT_TRUE(IsFailure(Assemble(crb_range_0, 0)));
2007 EXPECT_TRUE(!IsFailure(Assemble(crb_range_1, 0)));
2008 EXPECT_TRUE(IsFailure(Assemble(crb_range_2, 0)));
2009 EXPECT_TRUE(!IsFailure(Assemble(crb_range_3, 0)));
2010 EXPECT_TRUE(IsFailure(Assemble(off_range_0, 0)));
2011 EXPECT_TRUE(!IsFailure(Assemble(off_range_1, 0)));
2012 EXPECT_TRUE(IsFailure(Assemble(off_range_2, 0)));
2013 EXPECT_TRUE(!IsFailure(Assemble(off_range_3, 0)));
2014 EXPECT_TRUE(IsFailure(Assemble(psoff_range_0, 0)));
2015 EXPECT_TRUE(!IsFailure(Assemble(psoff_range_1, 0)));
2016 EXPECT_TRUE(IsFailure(Assemble(psoff_range_2, 0)));
2017 EXPECT_TRUE(!IsFailure(Assemble(psoff_range_3, 0)));
2018 EXPECT_TRUE(IsFailure(Assemble(psoff_range_0, 0)));
2019 EXPECT_TRUE(!IsFailure(Assemble(psoff_range_1, 0)));
2020 EXPECT_TRUE(IsFailure(Assemble(psoff_range_2, 0)));
2021 EXPECT_TRUE(!IsFailure(Assemble(psoff_range_3, 0)));
2022 EXPECT_TRUE(IsFailure(Assemble(simm_range_0, 0)));
2023 EXPECT_TRUE(!IsFailure(Assemble(simm_range_1, 0)));
2024 EXPECT_TRUE(IsFailure(Assemble(simm_range_2, 0)));
2025 EXPECT_TRUE(!IsFailure(Assemble(simm_range_3, 0)));
2026 EXPECT_TRUE(IsFailure(Assemble(uimm_range_0, 0)));
2027 EXPECT_TRUE(!IsFailure(Assemble(uimm_range_1, 0)));
2028 EXPECT_TRUE(IsFailure(Assemble(uimm_range_2, 0)));
2029 EXPECT_TRUE(!IsFailure(Assemble(uimm_range_3, 0)));
2030 }
2031
2032 TEST(Assembler, MalformedExpressions)
2033 {
2034 constexpr char missing_arg[] = "add 0, 1";
2035 constexpr char missing_paren_0[] = ".4byte (1 + 2), ((3 * 6) + 7";
2036 constexpr char missing_paren_1[] = ".4byte (1 + 2), `(3 * 6) + 7";
2037 constexpr char mismatched_paren[] = ".4byte (1 + 2), (`3 * 6) + 7`";
2038 constexpr char wrong_arg_format[] = "lwz r3, 100, r4";
2039 constexpr char no_operator[] = "b . .";
2040 constexpr char no_operand[] = "b 4 + +";
2041
2042 auto res = Assemble(missing_arg, 0);
2043 EXPECT_TRUE(IsFailure(res) && GetFailure(res).message == "Expected ',' but found '<EOF>'")
2044 << GetFailure(res).message;
2045 res = Assemble(missing_paren_0, 0);
2046 EXPECT_TRUE(IsFailure(res) && GetFailure(res).message == "Expected ')' but found '<EOF>'")
2047 << GetFailure(res).message;
2048 res = Assemble(missing_paren_1, 0);
2049 EXPECT_TRUE(IsFailure(res) && GetFailure(res).message == "Expected '`' but found '<EOF>'")
2050 << GetFailure(res).message;
2051 res = Assemble(mismatched_paren, 0);
2052 EXPECT_TRUE(IsFailure(res) && GetFailure(res).message == "Expected '`' but found ')'")
2053 << GetFailure(res).message;
2054 res = Assemble(wrong_arg_format, 0);
2055 EXPECT_TRUE(IsFailure(res) && GetFailure(res).message == "Expected '(' but found ','")
2056 << GetFailure(res).message;
2057 res = Assemble(no_operator, 0);
2058 EXPECT_TRUE(IsFailure(res) &&
2059 GetFailure(res).message == "Unexpected token '.' where line should have ended")
2060 << GetFailure(res).message;
2061 res = Assemble(no_operand, 0);
2062 EXPECT_TRUE(IsFailure(res) && GetFailure(res).message == "Unexpected token '+' in expression")
2063 << GetFailure(res).message;
2064 }
2065
2066 // Modified listing of a subroutine, listing generated by IDA
2067 // Expect bytes are based on disc contents
2068 TEST(Assembler, RealAssembly)
2069 {
2070 constexpr char real_assembly[] = ".locate 0x8046A690\n"
2071 ".defvar back_chain, -0x30\n"
2072 ".defvar var_28, -0x28\n"
2073 ".defvar pre_back_chain, 0\n"
2074 ".defvar sender_lr, 4\n"
2075 "stwu r1, back_chain(r1)\n"
2076 "mfspr r0, LR\n"
2077 "stw r0, 0x30+sender_lr(r1)\n"
2078 "addi r11, r1, 0x30+pre_back_chain\n"
2079 "bl `0x802BCA84`\n"
2080 "li r0, 0\n"
2081 "mr r28, r7\n"
2082 "stw r0, 0(r8)\n"
2083 "mr r24, r3\n"
2084 "mr r25, r4\n"
2085 "mr r26, r5\n"
2086 "mr r27, r6\n"
2087 "mr r29, r8\n"
2088 "mr r30, r9\n"
2089 "mr r31, r10\n"
2090 "mr r3, r28\n"
2091 "bl `0x80468140`\n"
2092 "cmplwi r3, 0x1A\n"
2093 "bge loc_8046A6F0\n"
2094 "mulli r0, r3, 0x14\n"
2095 "lis r3, -0x7FA4\n"
2096 "addi r3, r3, 0x870\n"
2097 "add r3, r3, r0\n"
2098 "b loc_8046A6F4\n"
2099 "loc_8046A6F0:\n"
2100 "li r3, 0\n"
2101 "loc_8046A6F4:\n"
2102 "cmpwi r3, 0\n"
2103 "beq loc_8046A704\n"
2104 "lwz r0, 0xC(r3)\n"
2105 "b loc_8046A708\n"
2106 "loc_8046A704:\n"
2107 "li r0, 0\n"
2108 "loc_8046A708:\n"
2109 "cmplw r26, r0\n"
2110 "bge loc_8046A7EC\n"
2111 "cmpwi r26, 0\n"
2112 "bne loc_8046A758\n"
2113 "mr r12, r30\n"
2114 "mr r3, r28\n"
2115 "mr r4, r25\n"
2116 "addi r5, r1, 0x30+var_28\n"
2117 "mtspr CTR, r12\n"
2118 "bctrl\n"
2119 "cmpwi r3, 0\n"
2120 "stw r3, 0(r29)\n"
2121 "beq loc_8046A744\n"
2122 "li r3, 0\n"
2123 "b loc_8046A7F0\n"
2124 "loc_8046A744:\n"
2125 "stw r24, 0(r27)\n"
2126 "li r0, 0\n"
2127 "li r3, 0\n"
2128 "stw r0, 0(r29)\n"
2129 "b loc_8046A7F0\n"
2130 "loc_8046A758:\n"
2131 "cmplwi r26, 1\n"
2132 "bne loc_8046A7DC\n"
2133 "mr r3, r28\n"
2134 "bl `0x80468140`\n"
2135 "cmplwi r3, 0x1A\n"
2136 "bge loc_8046A784\n"
2137 "mulli r0, r3, 0x14\n"
2138 "lis r3, -0x7FA4\n"
2139 "addi r3, r3, 0x870\n"
2140 "add r3, r3, r0\n"
2141 "b loc_8046A788\n"
2142 "loc_8046A784:\n"
2143 "li r3, 0\n"
2144 "loc_8046A788:\n"
2145 "cmpwi r3, 0\n"
2146 "beq loc_8046A798\n"
2147 "lwz r0, 8(r3)\n"
2148 "b loc_8046A79C\n"
2149 "loc_8046A798:\n"
2150 "li r0, 1\n"
2151 "loc_8046A79C:\n"
2152 "cmplwi r0, 2\n"
2153 "bne loc_8046A7DC\n"
2154 "mr r12, r31\n"
2155 "mr r3, r25\n"
2156 "mtspr CTR, r12\n"
2157 "bctrl\n"
2158 "cmpwi r3, 0\n"
2159 "stw r3, 0(r29)\n"
2160 "beq loc_8046A7C8\n"
2161 "li r3, 0\n"
2162 "b loc_8046A7F0\n"
2163 "loc_8046A7C8:\n"
2164 "stw r24, 0(r27)\n"
2165 "li r0, 0\n"
2166 "li r3, 0\n"
2167 "stw r0, 0(r29)\n"
2168 "b loc_8046A7F0\n"
2169 "loc_8046A7DC:\n"
2170 "li r0, -0x16\n"
2171 "li r3, 0\n"
2172 "stw r0, 0(r29)\n"
2173 "b loc_8046A7F0\n"
2174 "loc_8046A7EC:\n"
2175 "li r3, 1\n"
2176 "loc_8046A7F0:\n"
2177 "addi r11, r1, 0x30+pre_back_chain\n"
2178 "bl `0x802BCAD0`\n"
2179 "lwz r0, 0x30+sender_lr(r1)\n"
2180 "mtspr LR, r0\n"
2181 "addi r1, r1, 0x30\n"
2182 "blr\n"
2183 "loc_8046A804:\n";
2184
2185 constexpr u8 real_expect[] = {
2186 0x94, 0x21, 0xff, 0xd0, 0x7c, 0x08, 0x02, 0xa6, 0x90, 0x01, 0x00, 0x34, 0x39, 0x61, 0x00,
2187 0x30, 0x4b, 0xe5, 0x23, 0xe5, 0x38, 0x00, 0x00, 0x00, 0x7c, 0xfc, 0x3b, 0x78, 0x90, 0x08,
2188 0x00, 0x00, 0x7c, 0x78, 0x1b, 0x78, 0x7c, 0x99, 0x23, 0x78, 0x7c, 0xba, 0x2b, 0x78, 0x7c,
2189 0xdb, 0x33, 0x78, 0x7d, 0x1d, 0x43, 0x78, 0x7d, 0x3e, 0x4b, 0x78, 0x7d, 0x5f, 0x53, 0x78,
2190 0x7f, 0x83, 0xe3, 0x78, 0x4b, 0xff, 0xda, 0x71, 0x28, 0x03, 0x00, 0x1a, 0x40, 0x80, 0x00,
2191 0x18, 0x1c, 0x03, 0x00, 0x14, 0x3c, 0x60, 0x80, 0x5c, 0x38, 0x63, 0x08, 0x70, 0x7c, 0x63,
2192 0x02, 0x14, 0x48, 0x00, 0x00, 0x08, 0x38, 0x60, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0x41,
2193 0x82, 0x00, 0x0c, 0x80, 0x03, 0x00, 0x0c, 0x48, 0x00, 0x00, 0x08, 0x38, 0x00, 0x00, 0x00,
2194 0x7c, 0x1a, 0x00, 0x40, 0x40, 0x80, 0x00, 0xe0, 0x2c, 0x1a, 0x00, 0x00, 0x40, 0x82, 0x00,
2195 0x44, 0x7f, 0xcc, 0xf3, 0x78, 0x7f, 0x83, 0xe3, 0x78, 0x7f, 0x24, 0xcb, 0x78, 0x38, 0xa1,
2196 0x00, 0x08, 0x7d, 0x89, 0x03, 0xa6, 0x4e, 0x80, 0x04, 0x21, 0x2c, 0x03, 0x00, 0x00, 0x90,
2197 0x7d, 0x00, 0x00, 0x41, 0x82, 0x00, 0x0c, 0x38, 0x60, 0x00, 0x00, 0x48, 0x00, 0x00, 0xb0,
2198 0x93, 0x1b, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x60, 0x00, 0x00, 0x90, 0x1d, 0x00,
2199 0x00, 0x48, 0x00, 0x00, 0x9c, 0x28, 0x1a, 0x00, 0x01, 0x40, 0x82, 0x00, 0x80, 0x7f, 0x83,
2200 0xe3, 0x78, 0x4b, 0xff, 0xd9, 0xdd, 0x28, 0x03, 0x00, 0x1a, 0x40, 0x80, 0x00, 0x18, 0x1c,
2201 0x03, 0x00, 0x14, 0x3c, 0x60, 0x80, 0x5c, 0x38, 0x63, 0x08, 0x70, 0x7c, 0x63, 0x02, 0x14,
2202 0x48, 0x00, 0x00, 0x08, 0x38, 0x60, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0x41, 0x82, 0x00,
2203 0x0c, 0x80, 0x03, 0x00, 0x08, 0x48, 0x00, 0x00, 0x08, 0x38, 0x00, 0x00, 0x01, 0x28, 0x00,
2204 0x00, 0x02, 0x40, 0x82, 0x00, 0x3c, 0x7f, 0xec, 0xfb, 0x78, 0x7f, 0x23, 0xcb, 0x78, 0x7d,
2205 0x89, 0x03, 0xa6, 0x4e, 0x80, 0x04, 0x21, 0x2c, 0x03, 0x00, 0x00, 0x90, 0x7d, 0x00, 0x00,
2206 0x41, 0x82, 0x00, 0x0c, 0x38, 0x60, 0x00, 0x00, 0x48, 0x00, 0x00, 0x2c, 0x93, 0x1b, 0x00,
2207 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x60, 0x00, 0x00, 0x90, 0x1d, 0x00, 0x00, 0x48, 0x00,
2208 0x00, 0x18, 0x38, 0x00, 0xff, 0xea, 0x38, 0x60, 0x00, 0x00, 0x90, 0x1d, 0x00, 0x00, 0x48,
2209 0x00, 0x00, 0x08, 0x38, 0x60, 0x00, 0x01, 0x39, 0x61, 0x00, 0x30, 0x4b, 0xe5, 0x22, 0xdd,
2210 0x80, 0x01, 0x00, 0x34, 0x7c, 0x08, 0x03, 0xa6, 0x38, 0x21, 0x00, 0x30, 0x4e, 0x80, 0x00,
2211 0x20,
2212 };
2213
2214 auto res = Assemble(real_assembly, 0);
2215 ASSERT_TRUE(!IsFailure(res));
2216 auto&& code_blocks = GetT(res);
2217 ASSERT_EQ(code_blocks.size(), 1);
2218 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(real_expect));
2219
2220 EXPECT_EQ(code_blocks[0].block_address, 0x8046a690);
2221 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
2222 {
2223 EXPECT_EQ(code_blocks[0].instructions[i], real_expect[i]) << " -> i=" << i;
2224 }
2225 }
2226
2227 TEST(Assembler, NumericLabels)
2228 {
2229 constexpr char assembly[] = "0:b 0b\nb 0f\n0:.4byte 0\n0:\n1:.4byte 1b";
2230 constexpr u8 expect[] = {0x48, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x04,
2231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c};
2232
2233 auto res = Assemble(assembly, 0);
2234 ASSERT_TRUE(!IsFailure(res));
2235 auto&& code_blocks = GetT(res);
2236 ASSERT_EQ(code_blocks.size(), 1);
2237
2238 ASSERT_EQ(code_blocks[0].instructions.size(), sizeof(expect));
2239 for (size_t i = 0; i < code_blocks[0].instructions.size(); i++)
2240 {
2241 EXPECT_EQ(code_blocks[0].instructions[i], expect[i]) << " -> i=" << i;
2242 }
2243 }
2244
2245 TEST(Assembler, InvalidNumericLabels)
2246 {
2247 constexpr char missing_forward[] = "0:b 0f";
2248 constexpr char missing_backward[] = "b 0b\n0:";
2249 constexpr char forward_directive[] = ".4byte 0f\n0:";
2250 constexpr char missing_backward_directive[] = ".4byte 0b\n0:";
2251
2252 auto res = Assemble(missing_forward, 0);
2253 EXPECT_TRUE(IsFailure(res) && GetFailure(res).message == "No numeric label '0' found below here")
2254 << GetFailure(res).message;
2255 res = Assemble(missing_backward, 0);
2256 EXPECT_TRUE(IsFailure(res) && GetFailure(res).message == "No numeric label '0' found above here")
2257 << GetFailure(res).message;
2258 res = Assemble(forward_directive, 0);
2259 EXPECT_TRUE(IsFailure(res) &&
2260 GetFailure(res).message ==
2261 "Forward label references not supported in fully resolved expressions")
2262 << GetFailure(res).message;
2263 res = Assemble(missing_backward_directive, 0);
2264 EXPECT_TRUE(IsFailure(res) && GetFailure(res).message == "No numeric label '0' found above here")
2265 << GetFailure(res).message;
2266 }