about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-05 15:11:04 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:48 -0700
commit397966f615c1a206e071d0a24120ff0311d3cb5a (patch)
tree21f1d1cc098c0c7b3d516b5c776fdbf3ec2bf77c
parentc2c5ce566c64817436682fd109f63548c78b84c7 (diff)
downloadmu-397966f615c1a206e071d0a24120ff0311d3cb5a.tar.gz
mu.subx: lookup-or-define-var
-rw-r--r--apps/mu.subx18
1 files changed, 9 insertions, 9 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index 20b9c906..91a3393c 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -5666,31 +5666,31 @@ $lookup-var-helper:error1:
     cd/syscall  0x80/imm8
     # never gets here
 
-# TODO
 # return first 'name' from the top (back) of 'vars' and create a new var for a fn output if not found
 lookup-or-define-var:  # name: (addr slice), vars: (addr stack (handle var)), fn: (addr function), out: (addr handle var)
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
     # . save registers
-    51/push-ecx
+    50/push-eax
     #
-    (lookup-var-helper *(ebp+8) *(ebp+0xc))  # => eax
+    (lookup-var-helper *(ebp+8) *(ebp+0xc) *(ebp+0x14))
     {
-      # if (result != 0) return
-      3d/compare-eax-and 0/imm32
+      # if (out != 0) return
+      8b/-> *(ebp+0x14) 0/r32/eax
+      81 7/subop/compare *eax 0/imm32
       75/jump-if-!= break/disp8
       # if name is one of fn's outputs, return it
       {
-        (find-in-function-outputs *(ebp+0x10) *(ebp+8))  # => eax
-        3d/compare-eax-and 0/imm32
+        (find-in-function-outputs *(ebp+0x10) *(ebp+8) *(ebp+0x14))
+        81 7/subop/compare *eax 0/imm32
         # otherwise abort
-        0f 84/jump-if-!= $lookup-var:abort/disp32
+        0f 84/jump-if-= $lookup-var:abort/disp32
       }
     }
 $lookup-or-define-var:end:
     # . restore registers
-    59/pop-to-ecx
+    58/pop-to-eax
     # . epilogue
     89/<- %esp 5/r32/ebp
     5d/pop-to-ebp