]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RL78_E2Studio_GCC/src/RegTest.S
4ef4110fcd7a758763c04038423aa0ad7c8790c7
[freertos] / FreeRTOS / Demo / RL78_E2Studio_GCC / src / RegTest.S
1 /*\r
2  * FreeRTOS Kernel V10.1.0\r
3  * Copyright (C) 2018 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 /*\r
29  * This file defines the RegTest tasks as described at the top of main.c\r
30  */\r
31 \r
32         .global _vRegTest1Task\r
33         .short  _vRegTest1Task\r
34         .global _vRegTest2Task\r
35         .short  _vRegTest2Task\r
36 \r
37         .extern _vRegTestError\r
38         .extern _usRegTest1LoopCounter\r
39         .extern _usRegTest2LoopCounter\r
40 \r
41         .text\r
42 /*\r
43  * Fill all the registers with known values, then check that the registers\r
44  * contain the expected value.  An incorrect value being indicative of an\r
45  * error in the context switch mechanism.\r
46  */\r
47 _vRegTest1Task:\r
48 \r
49         /* First fill the registers. */\r
50         SEL             RB0\r
51         MOVW    AX, #0x1122\r
52         MOVW    BC, #0x3344\r
53         MOVW    DE, #0x5566\r
54         MOVW    HL, #0x7788\r
55         SEL             RB1\r
56         MOVW    AX, #0x1111\r
57         MOVW    BC, #0x2222\r
58         MOVW    DE, #0x3333\r
59         MOVW    HL, #0x4444\r
60         SEL             RB2\r
61         MOVW    AX, #0x5555\r
62         MOVW    BC, #0x6666\r
63         MOVW    DE, #0x7777\r
64         MOVW    HL, #0x8888\r
65 \r
66         /* Register bank 3 is not used outside of interrupts so is not saved as part\r
67         of the task context. */\r
68         SEL             RB0\r
69 \r
70 _loop1:\r
71 \r
72         /* Continuously check that the register values remain at their expected\r
73         values.  The BRK is to test the yield.  This task runs at low priority\r
74         so will also regularly get preempted. */\r
75         BRK\r
76 \r
77         /* Compare with the expected value. */\r
78         CMPW    AX, #0x1122\r
79         BZ              $.+5\r
80 \r
81         /* Jump over the branch to vRegTestError() if the register contained the\r
82         expected value - otherwise flag an error by executing vRegTestError(). */\r
83         BR              !!_vRegTestError\r
84 \r
85         /* Repeat for all the registers. */\r
86         MOVW    AX, BC\r
87         CMPW    AX, #0x3344\r
88         BZ              $.+5\r
89         BR              !!_vRegTestError\r
90         MOVW    AX, DE\r
91         CMPW    AX, #0x5566\r
92         BZ              $.+5\r
93         BR              !!_vRegTestError\r
94         MOVW    AX, HL\r
95         CMPW    AX, #0x7788\r
96         BZ              $.+5\r
97         BR              !!_vRegTestError\r
98 \r
99         /* Set AX back to its initial value. */\r
100         MOVW    AX, #0x1122\r
101 \r
102         SEL             RB1\r
103         CMPW    AX, #0x1111\r
104         BZ              $.+5\r
105         BR              !!_vRegTestError\r
106         MOVW    AX, BC\r
107         CMPW    AX, #0x2222\r
108         BZ              $.+5\r
109         BR              !!_vRegTestError\r
110         MOVW    AX, DE\r
111         CMPW    AX, #0x3333\r
112         BZ              $.+5\r
113         BR              !!_vRegTestError\r
114         MOVW    AX, HL\r
115         CMPW    AX, #0x4444\r
116         BZ              $.+5\r
117         BR              !!_vRegTestError\r
118         MOVW    AX, #0x1111\r
119 \r
120 \r
121         SEL             RB2\r
122         CMPW    AX, #0x5555\r
123         BZ              $.+5\r
124         BR              !!_vRegTestError\r
125         MOVW    AX, BC\r
126         CMPW    AX, #0x6666\r
127         BZ              $.+5\r
128         BR              !!_vRegTestError\r
129         MOVW    AX, DE\r
130         CMPW    AX, #0x7777\r
131         BZ              $.+5\r
132         BR              !!_vRegTestError\r
133         MOVW    AX, HL\r
134         CMPW    AX, #0x8888\r
135         BZ              $.+5\r
136         BR              !!_vRegTestError\r
137         MOVW    AX, #0x5555\r
138 \r
139 \r
140         /* Register bank 3 is not used outside of interrupts so is not saved as\r
141         part of the task context. */\r
142 \r
143         SEL     RB0\r
144 \r
145         /* Indicate that this task is still cycling. */\r
146         INCW    !_usRegTest1LoopCounter\r
147 \r
148         BR              !!_loop1\r
149 \r
150 \r
151 /*\r
152  * Fill all the registers with known values, then check that the registers\r
153  * contain the expected value.  An incorrect value being indicative of an\r
154  * error in the context switch mechanism.\r
155  */\r
156 _vRegTest2Task:\r
157 \r
158         SEL             RB0\r
159         MOVW    AX, #0x99aa\r
160         MOVW    BC, #0xbbcc\r
161         MOVW    DE, #0xddee\r
162         MOVW    HL, #0xff12\r
163         SEL             RB1\r
164         MOVW    AX, #0x0110\r
165         MOVW    BC, #0x0220\r
166         MOVW    DE, #0x0330\r
167         MOVW    HL, #0x0440\r
168         SEL             RB2\r
169         MOVW    AX, #0x0550\r
170         MOVW    BC, #0x0660\r
171         MOVW    DE, #0x0770\r
172         MOVW    HL, #0x0880\r
173 \r
174         /* Register bank 3 is not used outside of interrupts so is not saved as\r
175         part of the task context. */\r
176         SEL             RB0\r
177 \r
178 _loop2:\r
179         CMPW    AX, #0x99aa\r
180         BZ              $.+5\r
181         BR              !!_vRegTestError\r
182         MOVW    AX, BC\r
183         CMPW    AX, #0xbbcc\r
184         BZ              $.+5\r
185         BR              !!_vRegTestError\r
186         MOVW    AX, DE\r
187         CMPW    AX, #0xddee\r
188         BZ              $.+5\r
189         BR              !!_vRegTestError\r
190         MOVW    AX, HL\r
191         CMPW    AX, #0xff12\r
192         BZ              $.+5\r
193         BR              !!_vRegTestError\r
194         MOVW    AX, #0x99aa\r
195 \r
196         SEL             RB1\r
197         CMPW    AX, #0x0110\r
198         BZ              $.+5\r
199         BR              !!_vRegTestError\r
200         MOVW    AX, BC\r
201         CMPW    AX, #0x0220\r
202         BZ              $.+5\r
203         BR              !!_vRegTestError\r
204         MOVW    AX, DE\r
205         CMPW    AX, #0x0330\r
206         BZ              $.+5\r
207         BR              !!_vRegTestError\r
208         MOVW    AX, HL\r
209         CMPW    AX, #0x0440\r
210         BZ              $.+5\r
211         BR              !!_vRegTestError\r
212         MOVW    AX, #0x0110\r
213 \r
214         SEL             RB2\r
215         CMPW    AX, #0x0550\r
216         BZ              $.+5\r
217         BR              !!_vRegTestError\r
218         MOVW    AX, BC\r
219         CMPW    AX, #0x0660\r
220         BZ              $.+5\r
221         BR              !!_vRegTestError\r
222         MOVW    AX, DE\r
223         CMPW    AX, #0x0770\r
224         BZ              $.+5\r
225         BR              !!_vRegTestError\r
226         MOVW    AX, HL\r
227         CMPW    AX, #0x0880\r
228         BZ              $.+5\r
229         BR              !!_vRegTestError\r
230         MOVW    AX, #0x0550\r
231 \r
232         /* Register bank 3 is not used outside of interrupts so is not saved as\r
233         part of the task context. */\r
234 \r
235         SEL     RB0\r
236 \r
237         /* Indicate that this task is still cycling. */\r
238         INCW    !_usRegTest2LoopCounter\r
239 \r
240         BR              !!_loop2\r
241 \r
242         .end\r
243 \r