]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_R4F_RZ_T_GCC_IAR/src/Full_Demo/reg_test_IAR.asm
0b8b98057a139f11c00822607174fca449fe7da1
[freertos] / FreeRTOS / Demo / CORTEX_R4F_RZ_T_GCC_IAR / src / Full_Demo / reg_test_IAR.asm
1 /*\r
2  * FreeRTOS Kernel V10.2.1\r
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28         PUBLIC vRegTest1Implementation\r
29         PUBLIC vRegTest2Implementation\r
30         EXTERN ulRegTest1LoopCounter\r
31         EXTERN ulRegTest2LoopCounter\r
32 \r
33         SECTION intvec:CODE:ROOT(2)\r
34     ARM\r
35 \r
36         /* This function is explained in the comments at the top of main-full.c. */\r
37 vRegTest1Implementation:\r
38 \r
39         /* Fill each general purpose register with a known value. */\r
40         mov             r0,  #0xFF\r
41         mov             r1,  #0x11\r
42         mov             r2,  #0x22\r
43         mov             r3,  #0x33\r
44         mov     r4,  #0x44\r
45         mov     r5,  #0x55\r
46         mov     r6,  #0x66\r
47         mov     r7,  #0x77\r
48         mov     r8,  #0x88\r
49         mov     r9,  #0x99\r
50         mov     r10, #0xAA\r
51         mov     r11, #0xBB\r
52         mov     r12, #0xCC\r
53         mov             r14, #0xEE\r
54 \r
55 \r
56         /* Fill each FPU register with a known value. */\r
57         vmov    d0, r0, r1\r
58         vmov    d1, r2, r3\r
59         vmov    d2, r4, r5\r
60         vmov    d3, r6, r7\r
61         vmov    d4, r8, r9\r
62         vmov    d5, r10, r11\r
63         vmov    d6, r0, r1\r
64         vmov    d7, r2, r3\r
65         vmov    d8, r4, r5\r
66         vmov    d9, r6, r7\r
67         vmov    d10, r8, r9\r
68         vmov    d11, r10, r11\r
69         vmov    d12, r0, r1\r
70         vmov    d13, r2, r3\r
71         vmov    d14, r4, r5\r
72         vmov    d15, r6, r7\r
73 \r
74         /* Loop, checking each iteration that each register still contains the\r
75         expected value. */\r
76 reg1_loop:\r
77         /* Yield to increase test coverage */\r
78         svc 0\r
79 \r
80         /* Check all the VFP registers still contain the values set above.\r
81         First save registers that are clobbered by the test. */\r
82         push { r0-r1 }\r
83 \r
84         vmov    r0, r1, d0\r
85         cmp     r0, #0xFF\r
86         bne     reg1_error_loopf\r
87         cmp     r1, #0x11\r
88         bne     reg1_error_loopf\r
89         vmov    r0, r1, d1\r
90         cmp     r0, #0x22\r
91         bne     reg1_error_loopf\r
92         cmp     r1, #0x33\r
93         bne     reg1_error_loopf\r
94         vmov    r0, r1, d2\r
95         cmp     r0, #0x44\r
96         bne     reg1_error_loopf\r
97         cmp     r1, #0x55\r
98         bne     reg1_error_loopf\r
99         vmov    r0, r1, d3\r
100         cmp     r0, #0x66\r
101         bne     reg1_error_loopf\r
102         cmp     r1, #0x77\r
103         bne     reg1_error_loopf\r
104         vmov    r0, r1, d4\r
105         cmp     r0, #0x88\r
106         bne     reg1_error_loopf\r
107         cmp     r1, #0x99\r
108         bne     reg1_error_loopf\r
109         vmov    r0, r1, d5\r
110         cmp     r0, #0xAA\r
111         bne     reg1_error_loopf\r
112         cmp     r1, #0xBB\r
113         bne     reg1_error_loopf\r
114         vmov    r0, r1, d6\r
115         cmp     r0, #0xFF\r
116         bne     reg1_error_loopf\r
117         cmp     r1, #0x11\r
118         bne     reg1_error_loopf\r
119         vmov    r0, r1, d7\r
120         cmp     r0, #0x22\r
121         bne     reg1_error_loopf\r
122         cmp     r1, #0x33\r
123         bne     reg1_error_loopf\r
124         vmov    r0, r1, d8\r
125         cmp     r0, #0x44\r
126         bne     reg1_error_loopf\r
127         cmp     r1, #0x55\r
128         bne     reg1_error_loopf\r
129         vmov    r0, r1, d9\r
130         cmp     r0, #0x66\r
131         bne     reg1_error_loopf\r
132         cmp     r1, #0x77\r
133         bne     reg1_error_loopf\r
134         vmov    r0, r1, d10\r
135         cmp     r0, #0x88\r
136         bne     reg1_error_loopf\r
137         cmp     r1, #0x99\r
138         bne     reg1_error_loopf\r
139         vmov    r0, r1, d11\r
140         cmp     r0, #0xAA\r
141         bne     reg1_error_loopf\r
142         cmp     r1, #0xBB\r
143         bne     reg1_error_loopf\r
144         vmov    r0, r1, d12\r
145         cmp     r0, #0xFF\r
146         bne     reg1_error_loopf\r
147         cmp     r1, #0x11\r
148         bne     reg1_error_loopf\r
149         vmov    r0, r1, d13\r
150         cmp     r0, #0x22\r
151         bne     reg1_error_loopf\r
152         cmp     r1, #0x33\r
153         bne     reg1_error_loopf\r
154         vmov    r0, r1, d14\r
155         cmp     r0, #0x44\r
156         bne     reg1_error_loopf\r
157         cmp     r1, #0x55\r
158         bne     reg1_error_loopf\r
159         vmov    r0, r1, d15\r
160         cmp     r0, #0x66\r
161         bne     reg1_error_loopf\r
162         cmp     r1, #0x77\r
163         bne     reg1_error_loopf\r
164 \r
165 \r
166         /* Restore the registers that were clobbered by the test. */\r
167         pop     {r0-r1}\r
168 \r
169         /* VFP register test passed.  Jump to the core register test. */\r
170         b               reg1_loopf_pass\r
171 \r
172 reg1_error_loopf:\r
173         /* If this line is hit then a VFP register value was found to be\r
174         incorrect. */\r
175         b reg1_error_loopf\r
176 \r
177 reg1_loopf_pass:\r
178 \r
179         /* Test each general purpose register to check that it still contains the\r
180         expected known value, jumping to reg1_error_loop if any register contains\r
181         an unexpected value. */\r
182         cmp             r0, #0xFF\r
183         bne             reg1_error_loop\r
184         cmp             r1, #0x11\r
185         bne             reg1_error_loop\r
186         cmp             r2, #0x22\r
187         bne             reg1_error_loop\r
188         cmp             r3, #0x33\r
189         bne             reg1_error_loop\r
190         cmp             r4, #0x44\r
191         bne             reg1_error_loop\r
192         cmp             r5, #0x55\r
193         bne             reg1_error_loop\r
194         cmp             r6, #0x66\r
195         bne             reg1_error_loop\r
196         cmp             r7, #0x77\r
197         bne             reg1_error_loop\r
198         cmp             r8, #0x88\r
199         bne             reg1_error_loop\r
200         cmp             r9, #0x99\r
201         bne             reg1_error_loop\r
202         cmp             r10, #0xAA\r
203         bne             reg1_error_loop\r
204         cmp             r11, #0xBB\r
205         bne             reg1_error_loop\r
206         cmp             r12, #0xCC\r
207         bne             reg1_error_loop\r
208         cmp             r14, #0xEE\r
209         bne             reg1_error_loop\r
210 \r
211         /* Everything passed, increment the loop counter. */\r
212         push { r0-r1 }\r
213         ldr     r0, =ulRegTest1LoopCounter\r
214         ldr r1, [r0]\r
215         adds r1, r1, #1\r
216         str r1, [r0]\r
217         pop { r0-r1 }\r
218 \r
219         /* Start again. */\r
220         b reg1_loop\r
221 \r
222 reg1_error_loop:\r
223         /* If this line is hit then there was an error in a core register value.\r
224         The loop ensures the loop counter stops incrementing. */\r
225         b reg1_error_loop\r
226         nop\r
227 \r
228 /*-----------------------------------------------------------*/\r
229 \r
230 vRegTest2Implementation:\r
231 \r
232         /* Put a known value in each register. */\r
233         mov             r0,  #0xFF000000\r
234         mov             r1,  #0x11000000\r
235         mov             r2,  #0x22000000\r
236         mov             r3,  #0x33000000\r
237         mov     r4,  #0x44000000\r
238         mov     r5,  #0x55000000\r
239         mov     r6,  #0x66000000\r
240         mov     r7,  #0x77000000\r
241         mov     r8,  #0x88000000\r
242         mov     r9,  #0x99000000\r
243         mov     r10, #0xAA000000\r
244         mov     r11, #0xBB000000\r
245         mov     r12, #0xCC000000\r
246         mov     r14, #0xEE000000\r
247 \r
248         /* Likewise the floating point registers */\r
249         vmov    d0, r0, r1\r
250         vmov    d1, r2, r3\r
251         vmov    d2, r4, r5\r
252         vmov    d3, r6, r7\r
253         vmov    d4, r8, r9\r
254         vmov    d5, r10, r11\r
255         vmov    d6, r0, r1\r
256         vmov    d7, r2, r3\r
257         vmov    d8, r4, r5\r
258         vmov    d9, r6, r7\r
259         vmov    d10, r8, r9\r
260         vmov    d11, r10, r11\r
261         vmov    d12, r0, r1\r
262         vmov    d13, r2, r3\r
263         vmov    d14, r4, r5\r
264         vmov    d15, r6, r7\r
265 \r
266         /* Loop, checking each iteration that each register still contains the\r
267         expected value. */\r
268 reg2_loop:\r
269         /* Check all the VFP registers still contain the values set above.\r
270         First save registers that are clobbered by the test. */\r
271         push    { r0-r1 }\r
272 \r
273         vmov    r0, r1, d0\r
274         cmp     r0, #0xFF000000\r
275         bne     reg2_error_loopf\r
276         cmp     r1, #0x11000000\r
277         bne     reg2_error_loopf\r
278         vmov    r0, r1, d1\r
279         cmp     r0, #0x22000000\r
280         bne     reg2_error_loopf\r
281         cmp     r1, #0x33000000\r
282         bne     reg2_error_loopf\r
283         vmov    r0, r1, d2\r
284         cmp     r0, #0x44000000\r
285         bne     reg2_error_loopf\r
286         cmp     r1, #0x55000000\r
287         bne     reg2_error_loopf\r
288         vmov    r0, r1, d3\r
289         cmp     r0, #0x66000000\r
290         bne     reg2_error_loopf\r
291         cmp     r1, #0x77000000\r
292         bne     reg2_error_loopf\r
293         vmov    r0, r1, d4\r
294         cmp     r0, #0x88000000\r
295         bne     reg2_error_loopf\r
296         cmp     r1, #0x99000000\r
297         bne     reg2_error_loopf\r
298         vmov    r0, r1, d5\r
299         cmp     r0, #0xAA000000\r
300         bne     reg2_error_loopf\r
301         cmp     r1, #0xBB000000\r
302         bne     reg2_error_loopf\r
303         vmov    r0, r1, d6\r
304         cmp     r0, #0xFF000000\r
305         bne     reg2_error_loopf\r
306         cmp     r1, #0x11000000\r
307         bne     reg2_error_loopf\r
308         vmov    r0, r1, d7\r
309         cmp     r0, #0x22000000\r
310         bne     reg2_error_loopf\r
311         cmp     r1, #0x33000000\r
312         bne     reg2_error_loopf\r
313         vmov    r0, r1, d8\r
314         cmp     r0, #0x44000000\r
315         bne     reg2_error_loopf\r
316         cmp     r1, #0x55000000\r
317         bne     reg2_error_loopf\r
318         vmov    r0, r1, d9\r
319         cmp     r0, #0x66000000\r
320         bne     reg2_error_loopf\r
321         cmp     r1, #0x77000000\r
322         bne     reg2_error_loopf\r
323         vmov    r0, r1, d10\r
324         cmp     r0, #0x88000000\r
325         bne     reg2_error_loopf\r
326         cmp     r1, #0x99000000\r
327         bne     reg2_error_loopf\r
328         vmov    r0, r1, d11\r
329         cmp     r0, #0xAA000000\r
330         bne     reg2_error_loopf\r
331         cmp     r1, #0xBB000000\r
332         bne     reg2_error_loopf\r
333         vmov    r0, r1, d12\r
334         cmp     r0, #0xFF000000\r
335         bne     reg2_error_loopf\r
336         cmp     r1, #0x11000000\r
337         bne     reg2_error_loopf\r
338         vmov    r0, r1, d13\r
339         cmp     r0, #0x22000000\r
340         bne     reg2_error_loopf\r
341         cmp     r1, #0x33000000\r
342         bne     reg2_error_loopf\r
343         vmov    r0, r1, d14\r
344         cmp     r0, #0x44000000\r
345         bne     reg2_error_loopf\r
346         cmp     r1, #0x55000000\r
347         bne     reg2_error_loopf\r
348         vmov    r0, r1, d15\r
349         cmp     r0, #0x66000000\r
350         bne     reg2_error_loopf\r
351         cmp     r1, #0x77000000\r
352         bne     reg2_error_loopf\r
353 \r
354         /* Restore the registers that were clobbered by the test. */\r
355         pop     {r0-r1}\r
356 \r
357         /* VFP register test passed.  Jump to the core register test. */\r
358         b               reg2_loopf_pass\r
359 \r
360 reg2_error_loopf:\r
361         /* If this line is hit then a VFP register value was found to be\r
362         incorrect. */\r
363         b               reg2_error_loopf\r
364 \r
365 reg2_loopf_pass:\r
366 \r
367         cmp             r0, #0xFF000000\r
368         bne             reg2_error_loop\r
369         cmp             r1, #0x11000000\r
370         bne             reg2_error_loop\r
371         cmp             r2, #0x22000000\r
372         bne             reg2_error_loop\r
373         cmp             r3, #0x33000000\r
374         bne             reg2_error_loop\r
375         cmp             r4, #0x44000000\r
376         bne             reg2_error_loop\r
377         cmp             r5, #0x55000000\r
378         bne             reg2_error_loop\r
379         cmp             r6, #0x66000000\r
380         bne             reg2_error_loop\r
381         cmp             r7, #0x77000000\r
382         bne             reg2_error_loop\r
383         cmp             r8, #0x88000000\r
384         bne             reg2_error_loop\r
385         cmp             r9, #0x99000000\r
386         bne             reg2_error_loop\r
387         cmp             r10, #0xAA000000\r
388         bne             reg2_error_loop\r
389         cmp             r11, #0xBB000000\r
390         bne             reg2_error_loop\r
391         cmp             r12, #0xCC000000\r
392         bne             reg2_error_loop\r
393         cmp     r14, #0xEE000000\r
394         bne             reg2_error_loop\r
395 \r
396         /* Everything passed, increment the loop counter. */\r
397         push    { r0-r1 }\r
398         ldr             r0, =ulRegTest2LoopCounter\r
399         ldr     r1, [r0]\r
400         adds    r1, r1, #1\r
401         str     r1, [r0]\r
402         pop     { r0-r1 }\r
403 \r
404         /* Start again. */\r
405         b               reg2_loop\r
406 \r
407 reg2_error_loop:\r
408         /* If this line is hit then there was an error in a core register value.\r
409         The loop ensures the loop counter stops incrementing. */\r
410         b               reg2_error_loop\r
411         nop\r
412 \r
413 \r
414         END\r
415 \r