Commit ed9fcd1
committed
reader: add
Add a reader token that will swap the top two
elements on the stack, which means we can do things
like this:
wrsmn # . setbits 1,4 0b101 . rdsmn @0x1230_0000
Which will,
1. Push 0x12300000 onto the stack
2. Duplicate it so that the stack has two copies
of 0x12300000
3. Call `rdsmn` which will pop the first copy and read whatever
is at that SMN address (this is just an example; assume it is
a valid SMN address) and push it onto the stack. The stack
now contains the value it read via SMN, as well as the
`0x1230_000` pushed earlier
4. Push 0b101, 1,4 and invoke setbits, which will pop the first
three values (1,4, 0b101 and the contents of the SMN register
read a moment ago). Set bits will set bits 1..=3 in the SMN
value to `101` and push that onto the stack. The stack now
contains the modified SMN value and 0x12300000.
5. Swap the top two elements of the stack, so that it now
contains the SMN address at the top, then the modified value
6. Invoke `wrsmn` which will pop the address and value, and
write the value to that SMN address.
And we're done. This may be clearer using the `|` syntax:
rdsmn @0x1230_0000 | setbits 1,4 0b101 | wrsmn #
Signed-off-by: Dan Cross <cross@oxidecomputer.com># for "swap" command1 parent 48abd2a commit ed9fcd1
3 files changed
Lines changed: 59 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| 99 | + | |
| 100 | + | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
| |||
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
279 | 289 | | |
280 | 290 | | |
281 | 291 | | |
282 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
283 | 298 | | |
284 | 299 | | |
285 | 300 | | |
286 | 301 | | |
287 | 302 | | |
288 | 303 | | |
289 | 304 | | |
| 305 | + | |
290 | 306 | | |
291 | 307 | | |
292 | 308 | | |
293 | 309 | | |
294 | 310 | | |
295 | 311 | | |
296 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
297 | 316 | | |
298 | 317 | | |
299 | 318 | | |
| |||
304 | 323 | | |
305 | 324 | | |
306 | 325 | | |
307 | | - | |
308 | | - | |
309 | | - | |
| 326 | + | |
310 | 327 | | |
311 | 328 | | |
312 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
162 | | - | |
163 | | - | |
164 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
165 | 177 | | |
166 | 178 | | |
167 | 179 | | |
168 | 180 | | |
169 | 181 | | |
170 | 182 | | |
171 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
172 | 189 | | |
173 | 190 | | |
174 | 191 | | |
175 | 192 | | |
176 | | - | |
| 193 | + | |
177 | 194 | | |
178 | 195 | | |
179 | 196 | | |
| |||
225 | 242 | | |
226 | 243 | | |
227 | 244 | | |
228 | | - | |
| 245 | + | |
| 246 | + | |
229 | 247 | | |
230 | 248 | | |
231 | 249 | | |
| |||
265 | 283 | | |
266 | 284 | | |
267 | 285 | | |
| 286 | + | |
| 287 | + | |
268 | 288 | | |
269 | 289 | | |
270 | 290 | | |
| |||
296 | 316 | | |
297 | 317 | | |
298 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
299 | 323 | | |
300 | 324 | | |
301 | 325 | | |
| |||
0 commit comments