1 /* Tests the load and store instructions.
3 Copyright (C) 2017-2022 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 # output: report(0xdeadbeef);\n
20 # output: report(0x00000000);\n
21 # output: report(0x7fffffff);\n
22 # output: report(0x80000000);\n
23 # output: report(0xffffffff);\n
24 # output: report(0x00000000);\n
25 # output: report(0x7fffffff);\n
26 # output: report(0x80000000);\n
27 # output: report(0xffffffff);\n
28 # output: report(0xdeadbeef);\n
29 # output: report(0x00000000);\n
30 # output: report(0x7fffffff);\n
31 # output: report(0x80000000);\n
32 # output: report(0xdeadbeef);\n
33 # output: report(0x00000000);\n
34 # output: report(0x7fffffff);\n
35 # output: report(0x80000000);\n
36 # output: report(0xffffffff);\n
37 # output: report(0x00000000);\n
38 # output: report(0x7fffffff);\n
39 # output: report(0x80000000);\n
40 # output: report(0xffffffff);\n
41 # output: report(0xdeadbeef);\n
42 # output: report(0x00000000);\n
43 # output: report(0x7fffffff);\n
44 # output: report(0x80000000);\n
45 # output: report(0x000000de);\n
46 # output: report(0x000000ad);\n
47 # output: report(0x000000be);\n
48 # output: report(0x000000ef);\n
49 # output: report(0x000000ef);\n
50 # output: report(0x000000be);\n
51 # output: report(0x000000ad);\n
52 # output: report(0x000000de);\n
53 # output: report(0xffffffde);\n
54 # output: report(0xffffffad);\n
55 # output: report(0xffffffbe);\n
56 # output: report(0xffffffef);\n
57 # output: report(0xffffffef);\n
58 # output: report(0xffffffbe);\n
59 # output: report(0xffffffad);\n
60 # output: report(0xffffffde);\n
61 # output: report(0x0000dead);\n
62 # output: report(0x0000beef);\n
63 # output: report(0x0000beef);\n
64 # output: report(0x0000dead);\n
65 # output: report(0xffffdead);\n
66 # output: report(0xffffbeef);\n
67 # output: report(0xffffbeef);\n
68 # output: report(0xffffdead);\n
69 # output: report(0xa1a2a3a4);\n
70 # output: report(0xb4b3b2b1);\n
71 # output: report(0x81828384);\n
72 # output: report(0x53545152);\n
73 # output: report(0xa0b0c0d0);\n
74 # output: report(0xa1b1c1d1);\n
75 # output: report(0xa3b3c3d3);\n
76 # output: report(0xa2b2c2d2);\n
79 #include "or1k-asm-test-helpers.h"
81 .macro TEST_LW opcode, label, offset
82 LOAD_IMMEDIATE r5, \label
83 \opcode r4, \offset(r5)
84 REPORT_REG_TO_CONSOLE r4
87 STANDARD_TEST_ENVIRONMENT
101 buffer1: .word 0x00000000
102 buffer2: .word 0x00000000
103 buffer3: .word 0x00000000
104 buffer4: .word 0x00000000
109 PUSH LINK_REGISTER_R9
111 /* Test instruction l.lws */
113 /* Load with zero offset. */
120 /* Load with positive offset. */
123 TEST_LW l.lws 50b, 12
124 TEST_LW l.lws 50b, 16
126 /* Load with negative offset. */
127 TEST_LW l.lws 54b, -16
128 TEST_LW l.lws 54b, -12
129 TEST_LW l.lws 54b, -8
130 TEST_LW l.lws 54b, -4
132 /* TODO: add here test cases to cover unaligned memory accesses
135 /* Test instruction l.lwz */
137 /* Load with zero offset. */
144 /* Load with positive offset. */
147 TEST_LW l.lwz 50b, 12
148 TEST_LW l.lwz 50b, 16
150 /* Load with negative offset. */
151 TEST_LW l.lwz 54b, -16
152 TEST_LW l.lwz 54b, -12
153 TEST_LW l.lwz 54b, -8
154 TEST_LW l.lwz 54b, -4
156 /* TODO: add here test cases to cover unaligned memory accesses
159 /* Test instruction l.lbz */
161 /* Read data at label 50, forwards, byte by byte. */
162 LOAD_IMMEDIATE r5, 50b
165 REPORT_REG_TO_CONSOLE r4
168 REPORT_REG_TO_CONSOLE r4
171 REPORT_REG_TO_CONSOLE r4
174 REPORT_REG_TO_CONSOLE r4
176 /* Read data at label 50, backwards, byte by byte. */
177 LOAD_IMMEDIATE r31, 51b
180 REPORT_REG_TO_CONSOLE r3
183 REPORT_REG_TO_CONSOLE r3
186 REPORT_REG_TO_CONSOLE r3
189 REPORT_REG_TO_CONSOLE r3
191 /* Test instruction l.lbs */
193 /* Read data at label 50, forwards, byte by byte. */
194 LOAD_IMMEDIATE r5, 50b
197 REPORT_REG_TO_CONSOLE r4
200 REPORT_REG_TO_CONSOLE r4
203 REPORT_REG_TO_CONSOLE r4
206 REPORT_REG_TO_CONSOLE r4
208 /* Read data at label 50, backwards, byte by byte. */
209 LOAD_IMMEDIATE r31, 51b
212 REPORT_REG_TO_CONSOLE r3
215 REPORT_REG_TO_CONSOLE r3
218 REPORT_REG_TO_CONSOLE r3
221 REPORT_REG_TO_CONSOLE r3
223 /* Test instruction l.lhz */
225 /* Read data at label 50, forwards, half-word by half-word. */
226 LOAD_IMMEDIATE r5, 50b
229 REPORT_REG_TO_CONSOLE r4
232 REPORT_REG_TO_CONSOLE r4
234 /* Read data at label 50, backwards, half-word by half-word. */
235 LOAD_IMMEDIATE r31, 51b
238 REPORT_REG_TO_CONSOLE r3
241 REPORT_REG_TO_CONSOLE r3
243 /* TODO: add here test cases to cover unaligned memory accesses
246 /* Test instruction l.lhs */
248 /* Read data at label 50, forwards, half-word by half-word. */
249 LOAD_IMMEDIATE r5, 50b
252 REPORT_REG_TO_CONSOLE r4
255 REPORT_REG_TO_CONSOLE r4
257 /* Read data at label 50, backwards, half-word by half-word. */
258 LOAD_IMMEDIATE r31, 51b
261 REPORT_REG_TO_CONSOLE r3
264 REPORT_REG_TO_CONSOLE r3
266 /* TODO: add here test cases to cover unaligned memory accesses
269 /* Test instruction l.sb */
271 /* Write 32-bits forwards, byte-to-byte. */
272 LOAD_IMMEDIATE r5, buffer1
274 LOAD_IMMEDIATE r10, 0xA1
275 LOAD_IMMEDIATE r11, 0xA2
276 LOAD_IMMEDIATE r12, 0xA3
277 LOAD_IMMEDIATE r13, 0xA4
285 REPORT_REG_TO_CONSOLE r3
287 /* Write 32-bits backwards, byte-to-byte. */
288 LOAD_IMMEDIATE r6, buffer2
290 LOAD_IMMEDIATE r10, 0xB1
291 LOAD_IMMEDIATE r11, 0xB2
292 LOAD_IMMEDIATE r12, 0xB3
293 LOAD_IMMEDIATE r13, 0xB4
301 REPORT_REG_TO_CONSOLE r3
303 /* TODO: add here test cases to cover unaligned memory accesses
306 /* Test instruction l.sh */
308 /* Write 32-bits forwards, one half-word at a time. */
309 LOAD_IMMEDIATE r5, buffer1
311 LOAD_IMMEDIATE r10, 0x8182
312 LOAD_IMMEDIATE r11, 0x8384
318 REPORT_REG_TO_CONSOLE r3
320 /* Write 32-bits backwards, one half-word at a time. */
321 LOAD_IMMEDIATE r6, buffer2
323 LOAD_IMMEDIATE r10, 0x5152
324 LOAD_IMMEDIATE r11, 0x5354
330 REPORT_REG_TO_CONSOLE r3
332 /* TODO: add here test cases to cover unaligned memory accesses
335 /* Test instruction l.sw */
336 LOAD_IMMEDIATE r5, buffer1
337 LOAD_IMMEDIATE r6, buffer5
339 LOAD_IMMEDIATE r10, 0xA0B0C0D0
340 LOAD_IMMEDIATE r11, 0xA1B1C1D1
341 LOAD_IMMEDIATE r12, 0xA2B2C2D2
342 LOAD_IMMEDIATE r13, 0xA3B3C3D3
349 TEST_LW l.lwz buffer1, 0
350 TEST_LW l.lwz buffer2, 0
351 TEST_LW l.lwz buffer3, 0
352 TEST_LW l.lwz buffer4, 0
354 /* TODO: add here test cases to cover unaligned memory accesses
358 RETURN_TO_LINK_REGISTER_R9