git @ Cat's Eye Technologies Oxcart / 8687dbd
Add T instruction. Chris Pressey 5 years ago
2 changed file(s) with 18 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
238238 = > 0:[3,2]
239239
240240 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).
243242
244243 | 0^^0^0Y0^^^
245244 = 0:[2]
248247 | 0^^0v0Y0^^^
249248 = >-1:[3]
250249 = 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]
251258
252259 ### Operations involving continuations
253260
404411 * duplicate
405412 * decrement
406413 * 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!)
408415 * reset to the main stack
409416 * continue conditionally
410417
6363 case (n, v) of
6464 (0, (Num d)) -> k (shift (fromIntegral d) st'')
6565 (_, _) -> 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'''
6673
6774 save st k = k $ push (Cont k) st
6875 rsr st k =
103110 m' ')' = cright
104111 m' '\'' = reset
105112 m' 'Y' = swch
113 m' 'T' = tele
106114
107115 m' 'S' = save
108116 m' '%' = rsr