about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rwxr-xr-xapps/mubin163635 -> 163671 bytes
-rw-r--r--apps/mu.subx39
2 files changed, 28 insertions, 11 deletions
diff --git a/apps/mu b/apps/mu
index e1c87899..6f514b30 100755
--- a/apps/mu
+++ b/apps/mu
Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx
index 9b59b6ef..4004aa69 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -5685,17 +5685,7 @@ $emit-subx-stmt-list:check-for-reg-var-def:
         0f 85/jump-if-!= break/disp32
 $emit-subx-stmt-list:reg-var-def:
         # TODO: ensure that there's exactly one output
-        # var output/eax: (handle var) = curr-stmt->outputs->value
-        8b/-> *(ecx+0xc) 0/r32/eax
-        8b/-> *eax 0/r32/eax
-        # ensure that output is in a register
-        81 7/subop/compare *(eax+0x10) 0/imm32  # Var-register
-        0f 84/jump-if-= $emit-subx-stmt-list:abort-reg-var-def-without-register/disp32
-        # emit spill
-        (emit-indent *(ebp+8) *Curr-block-depth)
-        (write-buffered *(ebp+8) "ff 6/subop/push %")
-        (write-buffered *(ebp+8) *(eax+0x10))
-        (write-buffered *(ebp+8) Newline)
+        (emit-subx-reg-var-spill *(ebp+8) %ecx)
         # register variable definition
         (push *(ebp+0x10) %eax)
         # emit the instruction as usual
@@ -5736,6 +5726,33 @@ $emit-subx-stmt-list:abort-reg-var-def-without-register:
     cd/syscall  0x80/imm8
     # never gets here
 
+emit-subx-reg-var-spill:  # out: (addr buffered-file), stmt: (handle stmt)
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    # . save registers
+    51/push-ecx
+    # ecx = stmt
+    8b/-> *(ebp+0xc) 1/r32/ecx
+    # var output/eax: (handle var) = curr-stmt->outputs->value
+    8b/-> *(ecx+0xc) 0/r32/eax
+    8b/-> *eax 0/r32/eax
+    # ensure that output is in a register
+    81 7/subop/compare *(eax+0x10) 0/imm32  # Var-register
+    0f 84/jump-if-= $emit-subx-stmt-list:abort-reg-var-def-without-register/disp32
+    # emit spill
+    (emit-indent *(ebp+8) *Curr-block-depth)
+    (write-buffered *(ebp+8) "ff 6/subop/push %")
+    (write-buffered *(ebp+8) *(eax+0x10))
+    (write-buffered *(ebp+8) Newline)
+$emit-subx-reg-var-spill:end:
+    # . restore registers
+    59/pop-to-ecx
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
 emit-subx-cleanup-and-unconditional-nonlocal-branch:  # out: (addr buffered-file), stmt: (addr stmt1), vars: (addr stack (handle var))
     # . prologue
     55/push-ebp