about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-17 15:49:08 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:50 -0700
commitf02cfedaf4fcadfe4a0acaab3c42936480290a6c (patch)
tree452d99ff867b88ca1d9a57d80e99aaddf73a799a /apps
parent17860047f29c18ed0d9ce31e7e400f8e2ca6e51d (diff)
downloadmu-f02cfedaf4fcadfe4a0acaab3c42936480290a6c.tar.gz
mu.subx: test-add-mem-to-reg
Diffstat (limited to 'apps')
-rw-r--r--apps/mu.subx79
1 files changed, 61 insertions, 18 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index 0dc8084d..c34dad1a 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -13335,42 +13335,85 @@ test-add-mem-to-reg:
     # 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-mem-to-reg:initialize-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-mem-to-reg:initialize-var:
+    # var var1/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 var-var2/edx: var
-    68/push 0/imm32/no-register
+$test-add-mem-to-reg:initialize-var-name:
+    # var1->name = "foo"
+    8d/copy-address *(ecx+4) 0/r32/eax  # Var-name + 4
+    (copy-array Heap "var1" %eax)
+$test-add-mem-to-reg:initialize-var-register:
+    # var1->register = "eax"
+    8d/copy-address *(ecx+0x1c) 0/r32/eax  # Var-register + 4
+    (copy-array Heap "eax" %eax)
+$test-add-mem-to-reg:initialize-var2:
+    # var var2/edx: (payload var)
+    68/push 0/imm32/register
+    68/push 0/imm32/register
     68/push 8/imm32/stack-offset
     68/push 1/imm32/block-depth
-    ff 6/subop/push *(ecx+4)  # Var-type
-    68/push "var2"/imm32
+    ff 6/subop/push *(ecx+0x10)
+    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-mem-to-reg:initialize-var2-name:
+    # var2->name = "var2"
+    8d/copy-address *(edx+4) 0/r32/eax  # Var-name + 4
+    (copy-array Heap "var2" %eax)
+$test-add-mem-to-reg:initialize-inouts:
+    # var inouts/esi: (payload stmt-var) = [var2]
     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/var2
+    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-mem-to-reg:initialize-outputs:
+    # var outputs/edi: (payload stmt-var) = [var1]
     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/var1
+    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-mem-to-reg: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-mem-to-reg: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)