about summary refs log tree commit diff stats
path: root/apps/tile/word.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-20 09:33:13 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-20 09:33:13 -0700
commit5bdcb85f67c295c6967d8e1931d1cef95b29fab9 (patch)
tree591a5036343a8c88c8688592c90a5957e812fd5f /apps/tile/word.mu
parentc2d537c46b234f03d683f967aafbca20914a72e1 (diff)
downloadmu-5bdcb85f67c295c6967d8e1931d1cef95b29fab9.tar.gz
7081
Defining new functions seems to be working. _However_, we aren't yet detecting
duplicates. `x x *` leads to a declaration of `x x f`.
Diffstat (limited to 'apps/tile/word.mu')
-rw-r--r--apps/tile/word.mu21
1 files changed, 21 insertions, 0 deletions
diff --git a/apps/tile/word.mu b/apps/tile/word.mu
index e6167820..80fd6f3e 100644
--- a/apps/tile/word.mu
+++ b/apps/tile/word.mu
@@ -279,6 +279,27 @@ fn copy-words _src-ah: (addr handle word), _dest-ah: (addr handle word) {
   copy-words next-src-ah, next-dest-ah
 }
 
+fn copy-words-in-reverse _src-ah: (addr handle word), _dest-ah: (addr handle word) {
+  var src-ah/eax: (addr handle word) <- copy _src-ah
+  var _src-a/eax: (addr word) <- lookup *src-ah
+  var src-a/esi: (addr word) <- copy _src-a
+  compare src-a, 0
+  break-if-=
+  # recurse
+  var next-src-ah/ecx: (addr handle word) <- get src-a, next
+  var dest-ah/edi: (addr handle word) <- copy _dest-ah
+  copy-words-in-reverse next-src-ah, dest-ah
+  # copy at end
+  {
+    var dest-a/eax: (addr word) <- lookup *dest-ah
+    compare dest-a, 0
+    break-if-=
+    dest-ah <- get dest-a, next
+    loop
+  }
+  copy-word src-a, dest-ah
+}
+
 fn copy-word _src-a: (addr word), _dest-ah: (addr handle word) {
   var dest-ah/eax: (addr handle word) <- copy _dest-ah
   allocate dest-ah