about summary refs log tree commit diff stats
path: root/apps/tile/rpn.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-19 16:48:16 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-19 16:49:17 -0700
commitabfd0bad29b2a481583207d17f7bd1ebe2ffc2f5 (patch)
treea231b5c8c1cb938a5fd1ac047436d1ea086c2ec8 /apps/tile/rpn.mu
parenta83cde9663a639593334ef8220db4428e7a047c7 (diff)
downloadmu-abfd0bad29b2a481583207d17f7bd1ebe2ffc2f5.tar.gz
6803 - RPN: typing a single word now works
Diffstat (limited to 'apps/tile/rpn.mu')
-rw-r--r--apps/tile/rpn.mu13
1 files changed, 8 insertions, 5 deletions
diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu
index a70d9fd5..696912fd 100644
--- a/apps/tile/rpn.mu
+++ b/apps/tile/rpn.mu
@@ -51,11 +51,7 @@ fn simplify in: (addr stream byte), out: (addr int-stack) {
 # Copy of 'simplify' that just tracks the maximum stack depth needed
 # Doesn't actually need to simulate the stack, since every word has a predictable effect.
 fn max-stack-depth first-word: (addr word), final-word: (addr word) -> result/edi: int {
-  var a/eax: int <- copy first-word
-  print-string-to-real-screen "inside max-stack-depth: "
-  print-int32-hex-to-real-screen a
-  print-string-to-real-screen "\n"
-  var curr-word/esi: (addr word) <- copy first-word
+  var curr-word/eax: (addr word) <- copy first-word
   var curr-depth/ecx: int <- copy 0
   result <- copy 0
   $max-stack-depth:word-loop: {
@@ -89,6 +85,13 @@ fn max-stack-depth first-word: (addr word), final-word: (addr word) -> result/ed
       break-if-<=
       result <- copy curr-depth
     }
+    # if curr-word == final-word break
+    compare curr-word, final-word
+    break-if-=
+    # curr-word = curr-word->next
+    var next-word-ah/edx: (addr handle word) <- get curr-word, next
+    curr-word <- lookup *next-word-ah
+    #
     loop
   }
 }