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-19 23:53:45 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-19 23:53:45 -0700
commit0cdbfff25664d2bd3257220ca1509e7bfbd84c75 (patch)
tree30a2a54b5231161e869ce08f204d1c8ade9db79e /apps/tile/word.mu
parente28b949f1826b5351e1bd5e5cad92774c72ad4c0 (diff)
downloadmu-0cdbfff25664d2bd3257220ca1509e7bfbd84c75.tar.gz
7079
Diffstat (limited to 'apps/tile/word.mu')
-rw-r--r--apps/tile/word.mu26
1 files changed, 26 insertions, 0 deletions
diff --git a/apps/tile/word.mu b/apps/tile/word.mu
index d630b176..e9101eb2 100644
--- a/apps/tile/word.mu
+++ b/apps/tile/word.mu
@@ -264,6 +264,32 @@ fn print-words-in-reverse screen: (addr screen), _words-ah: (addr handle word) {
   print-string screen, " "
 }
 
+fn copy-words _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
+  compare src-a, 0
+  break-if-=
+  # copy
+  var dest-ah/edi: (addr handle word) <- copy _dest-ah
+  copy-word src-a, dest-ah
+  # recurse
+  var next-src-ah/esi: (addr handle word) <- get src-a, next
+  var dest-a/eax: (addr word) <- lookup *dest-ah
+  var next-dest-ah/eax: (addr handle word) <- get dest-a, next
+  copy-words next-src-ah, next-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
+  var _dest-a/eax: (addr word) <- lookup *dest-ah
+  var dest-a/eax: (addr word) <- copy _dest-a
+  var dest/edi: (addr handle gap-buffer) <- get dest-a, scalar-data
+  var src-a/eax: (addr word) <- copy _src-a
+  var src/eax: (addr handle gap-buffer) <- get src-a, scalar-data
+  copy-gap-buffer src, dest
+}
+
 # one implication of handles: append must take a handle
 fn append-word _self-ah: (addr handle word) {
   var self-ah/esi: (addr handle word) <- copy _self-ah