about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/tile/environment.mu8
-rw-r--r--apps/tile/rpn.mu116
2 files changed, 121 insertions, 3 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index 77949e21..1e4ae762 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -1477,15 +1477,17 @@ fn clear-canvas _env: (addr environment) {
   move-cursor screen, 3, start-col
   print-string screen, "open read slurp lines"
   move-cursor screen, 4, start-col
-  print-string screen, "fake-screen"
+  print-string screen, "fake-screen print move"
   move-cursor screen, 5, start-col
+  print-string screen, "up down left right"
+  move-cursor screen, 6, start-col
   print-string screen, "dup swap"
   # currently defined functions
   start-col <- subtract 2
-  move-cursor screen, 6, start-col
+  move-cursor screen, 8, start-col
   print-string screen, "functions:"
   start-col <- add 2
-  var row/ebx: int <- copy 7
+  var row/ebx: int <- copy 9
   var functions/esi: (addr handle function) <- get env, functions
   {
     var curr/eax: (addr function) <- lookup *functions
diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu
index 71562eaf..0f6e16fa 100644
--- a/apps/tile/rpn.mu
+++ b/apps/tile/rpn.mu
@@ -357,6 +357,122 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         move-cursor target, r, c
         break $evaluate:process-word
       }
+      {
+        var is-up?/eax: boolean <- stream-data-equal? curr-stream, "up"
+        compare is-up?, 0
+        break-if-=
+        var out2/esi: (addr value-stack) <- copy out
+        # select screen from top of out (but don't pop it)
+        var top-addr/ebx: (addr int) <- get out2, top
+        compare *top-addr, 0
+        break-if-<=
+        var data-ah/eax: (addr handle array value) <- get out2, data
+        var _data/eax: (addr array value) <- lookup *data-ah
+        var data/edi: (addr array value) <- copy _data
+        var top/eax: int <- copy *top-addr
+        top <- decrement
+        var target-offset/eax: (offset value) <- compute-offset data, top
+        var target-val/ebx: (addr value) <- index data, target-offset
+        var type/eax: (addr int) <- get target-val, type
+        compare *type, 4  # screen
+        break-if-!=
+        var target-ah/eax: (addr handle screen) <- get target-val, screen-data
+        var _target/eax: (addr screen) <- lookup *target-ah
+        var target/edi: (addr screen) <- copy _target
+        var dest/eax: (addr int) <- get target, cursor-row
+        compare *dest, 1
+        break-if-<= $evaluate:process-word
+        decrement *dest
+        break $evaluate:process-word
+      }
+      {
+        var is-down?/eax: boolean <- stream-data-equal? curr-stream, "down"
+        compare is-down?, 0
+        break-if-=
+        var out2/esi: (addr value-stack) <- copy out
+        # select screen from top of out (but don't pop it)
+        var top-addr/ebx: (addr int) <- get out2, top
+        compare *top-addr, 0
+        break-if-<=
+        var data-ah/eax: (addr handle array value) <- get out2, data
+        var _data/eax: (addr array value) <- lookup *data-ah
+        var data/edi: (addr array value) <- copy _data
+        var top/eax: int <- copy *top-addr
+        top <- decrement
+        var target-offset/eax: (offset value) <- compute-offset data, top
+        var target-val/ebx: (addr value) <- index data, target-offset
+        var type/eax: (addr int) <- get target-val, type
+        compare *type, 4  # screen
+        break-if-!=
+        var target-ah/eax: (addr handle screen) <- get target-val, screen-data
+        var _target/eax: (addr screen) <- lookup *target-ah
+        var target/edi: (addr screen) <- copy _target
+        var bound-a/ecx: (addr int) <- get target, num-rows
+        var bound/ecx: int <- copy *bound-a
+        var dest/eax: (addr int) <- get target, cursor-row
+        compare *dest, bound
+        break-if->= $evaluate:process-word
+        increment *dest
+        break $evaluate:process-word
+      }
+      {
+        var is-left?/eax: boolean <- stream-data-equal? curr-stream, "left"
+        compare is-left?, 0
+        break-if-=
+        var out2/esi: (addr value-stack) <- copy out
+        # select screen from top of out (but don't pop it)
+        var top-addr/ebx: (addr int) <- get out2, top
+        compare *top-addr, 0
+        break-if-<=
+        var data-ah/eax: (addr handle array value) <- get out2, data
+        var _data/eax: (addr array value) <- lookup *data-ah
+        var data/edi: (addr array value) <- copy _data
+        var top/eax: int <- copy *top-addr
+        top <- decrement
+        var target-offset/eax: (offset value) <- compute-offset data, top
+        var target-val/ebx: (addr value) <- index data, target-offset
+        var type/eax: (addr int) <- get target-val, type
+        compare *type, 4  # screen
+        break-if-!=
+        var target-ah/eax: (addr handle screen) <- get target-val, screen-data
+        var _target/eax: (addr screen) <- lookup *target-ah
+        var target/edi: (addr screen) <- copy _target
+        var dest/eax: (addr int) <- get target, cursor-col
+        compare *dest, 1
+        break-if-<= $evaluate:process-word
+        decrement *dest
+        break $evaluate:process-word
+      }
+      {
+        var is-right?/eax: boolean <- stream-data-equal? curr-stream, "right"
+        compare is-right?, 0
+        break-if-=
+        var out2/esi: (addr value-stack) <- copy out
+        # select screen from top of out (but don't pop it)
+        var top-addr/ebx: (addr int) <- get out2, top
+        compare *top-addr, 0
+        break-if-<=
+        var data-ah/eax: (addr handle array value) <- get out2, data
+        var _data/eax: (addr array value) <- lookup *data-ah
+        var data/edi: (addr array value) <- copy _data
+        var top/eax: int <- copy *top-addr
+        top <- decrement
+        var target-offset/eax: (offset value) <- compute-offset data, top
+        var target-val/ebx: (addr value) <- index data, target-offset
+        var type/eax: (addr int) <- get target-val, type
+        compare *type, 4  # screen
+        break-if-!=
+        var target-ah/eax: (addr handle screen) <- get target-val, screen-data
+        var _target/eax: (addr screen) <- lookup *target-ah
+        var target/edi: (addr screen) <- copy _target
+        var bound-a/ecx: (addr int) <- get target, num-cols
+        var bound/ecx: int <- copy *bound-a
+        var dest/eax: (addr int) <- get target, cursor-col
+        compare *dest, bound
+        break-if->= $evaluate:process-word
+        increment *dest
+        break $evaluate:process-word
+      }
       ## HACKS: we're trying to avoid turning this into Forth
       {
         var is-dup?/eax: boolean <- stream-data-equal? curr-stream, "dup"
d=8fa458323058c8998408f88b80d07c687fccd521'>8fa4583 ^
661e3ec ^

7160f98 ^
ecd803a ^

7160f98 ^



ecd803a ^











661e3ec ^
5685a17 ^
661e3ec ^

1418e1b ^
8fa4583 ^
661e3ec ^

1170893 ^
8fa4583 ^
661e3ec ^

80e891a ^



cc639a1 ^
8635c70 ^
72e4b5e ^
8635c70 ^
ecd803a ^
8635c70 ^





80e891a ^
72e4b5e ^
8635c70 ^
ecd803a ^
8fa4583 ^

661e3ec ^



ecd803a ^




6838c23 ^
ecd803a ^








6838c23 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112