about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-06 14:29:21 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:48 -0700
commit21c6424962b4fbcfc98772656e2915b7fed01c61 (patch)
tree4ed73483fe4af41ffb06d7f0c128dd7566c2b66f
parented91d9b0950109cbe69139ebf025f06410e10580 (diff)
downloadmu-21c6424962b4fbcfc98772656e2915b7fed01c61.tar.gz
mu.subx: new-block
-rw-r--r--apps/mu.subx16
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index 2840b124..3ac723ce 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -6001,21 +6001,31 @@ $new-var-from-slice:end:
     5d/pop-to-ebp
     c3/return
 
-# TODO
-new-block:  # ad: (addr allocation-descriptor), data: (addr list stmt), out: (addr handle stmt)
+new-block:  # ad: (addr allocation-descriptor), data: (handle list stmt), out: (addr handle stmt)
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
     # . save registers
+    50/push-eax
     51/push-ecx
     #
-    (allocate *(ebp+8) *Stmt-size)  # => eax
+    (allocate *(ebp+8) *Stmt-size *(ebp+0x10))
+    # var out-addr/eax: (addr stmt) = lookup(out)
+    8b/-> *(ebp+0x10) 0/r32/eax
+    (lookup *eax *(eax+4))  # => eax
+    # out-addr->tag = block
     c7 0/subop/copy *eax 0/imm32/tag/block  # Stmt-tag
+    # out-addr->stmts = data
     8b/-> *(ebp+0xc) 1/r32/ecx
+    8b/-> *ecx 1/r32/ecx
     89/<- *(eax+4) 1/r32/ecx  # Block-stmts
+    8b/-> *(ebp+0xc) 1/r32/ecx
+    8b/-> *(ecx+4) 1/r32/ecx
+    89/<- *(eax+8) 1/r32/ecx  # Block-stmts
 $new-block:end:
     # . restore registers
     59/pop-to-ecx
+    58/pop-to-eax
     # . epilogue
     89/<- %esp 5/r32/ebp
     5d/pop-to-ebp