about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--apps/mu.subx95
1 files changed, 72 insertions, 23 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index c34dad1a..1a36e6b2 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -11779,12 +11779,13 @@ emit-subx-imm32:  # out: (addr buffered-file), l: arg-location, stmt: (addr stmt
     51/push-ecx
     # if (l == 0) return
     81 7/subop/compare *(ebp+0xc) 0/imm32
-    74/jump-if-= $emit-subx-imm32:end/disp8
+    0f 84/jump-if-= $emit-subx-imm32:end/disp32
     # var v/eax: (handle var)
     (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))  # => eax
-    8b/-> *eax 0/r32/eax  # Stmt-var-value
+    (lookup *eax *(eax+4))  # Stmt-var-value Stmt-var-value => eax
+    (lookup *eax *(eax+4))  # Var-name Var-name => eax
     (write-buffered *(ebp+8) Space)
-    (write-buffered *(ebp+8) *eax)  # Var-name
+    (write-buffered *(ebp+8) %eax)
     (write-buffered *(ebp+8) "/imm32")
 $emit-subx-imm32:end:
     # . restore registers
@@ -13442,46 +13443,94 @@ test-add-literal-to-eax:
     # setup
     (clear-stream _test-output-stream)
     (clear-stream $_test-output-buffered-file->buffer)
-    # var type/ecx: (handle tree type-id) = int
-    68/push 0/imm32/right/null
-    68/push 1/imm32/left/int
-    68/push 1/imm32/is-atom
+$test-add-literal-to-eax:initialize-var-type:
+    # var type/ecx: (payload tree type-id) = int
+    68/push 0/imm32/right:null
+    68/push 0/imm32/right:null
+    68/push 0/imm32/left:unused
+    68/push 1/imm32/value:int
+    68/push 1/imm32/is-atom?:true
+    68/push 0x11/imm32/alloc-id:fake:payload
     89/<- %ecx 4/r32/esp
-    # var var-var1/ecx: var in eax
-    68/push "eax"/imm32/register
+$test-add-literal-to-eax:initialize-var:
+    # var v/ecx: (payload var)
+    68/push 0/imm32/register
+    68/push 0/imm32/register
     68/push 0/imm32/no-stack-offset
     68/push 1/imm32/block-depth
     51/push-ecx
-    68/push "var1"/imm32
+    68/push 0x11/imm32/alloc-id:fake
+    68/push 0/imm32/name
+    68/push 0/imm32/name
+    68/push 0x11/imm32/alloc-id:fake:payload
     89/<- %ecx 4/r32/esp
-    # var type/edx: (handle tree type-id) = literal
-    68/push 0/imm32/right/null
-    68/push 0/imm32/left/literal
+$test-add-literal-to-eax:initialize-var-name:
+    # v->name = "v"
+    8d/copy-address *(ecx+4) 0/r32/eax  # Var-name + 4
+    (copy-array Heap "v" %eax)
+$test-add-literal-to-eax:initialize-var-register:
+    # v->register = "eax"
+    8d/copy-address *(ecx+0x1c) 0/r32/eax  # Var-register + 4
+    (copy-array Heap "eax" %eax)
+$test-add-literal-to-eax:initialize-literal-type:
+    # var type/edx: (payload tree type-id) = literal
+    68/push 0/imm32/right:null
+    68/push 0/imm32/right:null
+    68/push 0/imm32/left:unused
+    68/push 0/imm32/value:literal
+    68/push 1/imm32/is-atom?:true
+    68/push 0x11/imm32/alloc-id:fake:payload
     89/<- %edx 4/r32/esp
-    # var var-var2/edx: var literal
-    68/push 0/imm32/no-register
+$test-add-literal-to-eax:initialize-literal:
+    # var l/edx: (payload var)
+    68/push 0/imm32/register
+    68/push 0/imm32/register
     68/push 0/imm32/no-stack-offset
     68/push 1/imm32/block-depth
     52/push-edx
-    68/push "0x34"/imm32
+    68/push 0x11/imm32/alloc-id:fake
+    68/push 0/imm32/name
+    68/push 0/imm32/name
+    68/push 0x11/imm32/alloc-id:fake:payload
     89/<- %edx 4/r32/esp
-    # var inouts/esi: (handle stmt-var) = [var2]
+$test-add-literal-to-eax:initialize-literal-value:
+    # l->name = "0x34"
+    8d/copy-address *(edx+4) 0/r32/eax  # Var-name + 4
+    (copy-array Heap "0x34" %eax)
+$test-add-literal-to-eax:initialize-inouts:
+    # var inouts/esi: (payload stmt-var) = [l]
     68/push 0/imm32/is-deref:false
     68/push 0/imm32/next
-    52/push-edx/var-var2
+    68/push 0/imm32/next
+    52/push-edx/l
+    68/push 0x11/imm32/alloc-id:fake
+    68/push 0x11/imm32/alloc-id:fake:payload
     89/<- %esi 4/r32/esp
-    # var outputs/edi: (handle stmt-var) = [var1]
+$test-add-literal-to-eax:initialize-outputs:
+    # var outputs/edi: (payload stmt-var) = [v]
     68/push 0/imm32/is-deref:false
     68/push 0/imm32/next
-    51/push-ecx/var-var1
+    68/push 0/imm32/next
+    51/push-ecx/v
+    68/push 0x11/imm32/alloc-id:fake
+    68/push 0x11/imm32/alloc-id:fake:payload
     89/<- %edi 4/r32/esp
-    # var stmt/esi: statement
+$test-add-literal-to-eax:initialize-stmt:
+    # var stmt/esi: (addr statement)
+    68/push 0/imm32/next
     68/push 0/imm32/next
     57/push-edi/outputs
+    68/push 0x11/imm32/alloc-id:fake
     56/push-esi/inouts
-    68/push "add"/imm32/operation
-    68/push 1/imm32
+    68/push 0x11/imm32/alloc-id:fake
+    68/push 0/imm32/operation
+    68/push 0/imm32/operation
+    68/push 1/imm32/tag:stmt1
     89/<- %esi 4/r32/esp
+$test-add-literal-to-eax:initialize-stmt-operation:
+    # stmt->operation = "add"
+    8d/copy-address *(esi+4) 0/r32/eax  # Stmt1-operation
+    (copy-array Heap "add" %eax)
     # convert
     c7 0/subop/copy *Curr-block-depth 0/imm32
     (emit-subx-stmt _test-output-buffered-file %esi Primitives)