From 5bdcb85f67c295c6967d8e1931d1cef95b29fab9 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 20 Oct 2020 09:33:13 -0700 Subject: 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`. --- apps/tile/word.mu | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'apps/tile/word.mu') 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 -- cgit 1.4.1-2-gfad0