Add T instruction.
Chris Pressey
5 years ago
238 | 238 |
= > 0:[3,2]
|
239 | 239 |
|
240 | 240 |
But if the first value is zero, the second value is added to the
|
241 | |
position of the tape cell (negative values go left, positive values
|
242 | |
go right).
|
|
241 |
tape position (negative values go left, positive values go right).
|
243 | 242 |
|
244 | 243 |
| 0^^0^0Y0^^^
|
245 | 244 |
= 0:[2]
|
|
248 | 247 |
| 0^^0v0Y0^^^
|
249 | 248 |
= >-1:[3]
|
250 | 249 |
= 0:[2]
|
|
250 |
|
|
251 |
The instruction `T` pops a first value off the stack, then a second
|
|
252 |
value. It then sets the tape position to the first value, and pushes
|
|
253 |
the second value back on the (probably newly current) stack.
|
|
254 |
|
|
255 |
| <0^^^0^^^^^0^T
|
|
256 |
= -1:[3]
|
|
257 |
= > 1:[5]
|
251 | 258 |
|
252 | 259 |
### Operations involving continuations
|
253 | 260 |
|
|
404 | 411 |
* duplicate
|
405 | 412 |
* decrement
|
406 | 413 |
* duplicate
|
407 | |
* transfer right (this is the test value)
|
|
414 |
* transfer right (this is the test value - ah, but it needs to always get to the main stack somehow!)
|
408 | 415 |
* reset to the main stack
|
409 | 416 |
* continue conditionally
|
410 | 417 |
|
63 | 63 |
case (n, v) of
|
64 | 64 |
(0, (Num d)) -> k (shift (fromIntegral d) st'')
|
65 | 65 |
(_, _) -> k st''
|
|
66 |
tele st k =
|
|
67 |
let
|
|
68 |
(Just (Num n), st') = pop st
|
|
69 |
(Just v, st'') = pop st'
|
|
70 |
st''' = moveTo (fromIntegral n) st''
|
|
71 |
in
|
|
72 |
k $ push v st'''
|
66 | 73 |
|
67 | 74 |
save st k = k $ push (Cont k) st
|
68 | 75 |
rsr st k =
|
|
103 | 110 |
m' ')' = cright
|
104 | 111 |
m' '\'' = reset
|
105 | 112 |
m' 'Y' = swch
|
|
113 |
m' 'T' = tele
|
106 | 114 |
|
107 | 115 |
m' 'S' = save
|
108 | 116 |
m' '%' = rsr
|