about summary refs log tree commit diff stats
path: root/070new-stream.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-04-03 00:19:31 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:46 -0700
commitca358b17a3fc36adcfbbb565675998de2d3e3576 (patch)
tree32c1d8726f4593521e1bc67b8e2d1ae4633c2d40 /070new-stream.subx
parent546a92985f7da2491077d641a2c118b4af7f6913 (diff)
downloadmu-ca358b17a3fc36adcfbbb565675998de2d3e3576.tar.gz
table primitives working
  $ ./translate_subx init.linux 0*.subx  &&  ./a.elf test
Diffstat (limited to '070new-stream.subx')
-rw-r--r--070new-stream.subx8
1 files changed, 4 insertions, 4 deletions
diff --git a/070new-stream.subx b/070new-stream.subx
index b4326096..a219c347 100644
--- a/070new-stream.subx
+++ b/070new-stream.subx
@@ -5,14 +5,14 @@
 # . op          subop               mod             rm32          base        index         scale       r32
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
-new-stream:  # ad: (addr allocation-descriptor), length: int, elemsize: int, out: (handle stream _)
+new-stream:  # ad: (addr allocation-descriptor), length: int, elemsize: int, out: (addr handle stream _)
     # . prologue
     55/push-ebp
     89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
     # . save registers
     50/push-eax
     52/push-edx
-    # var n/eax: int = elemsize * length + 12 (for read, write and size)
+    # var size/edx: int = elemsize*length (clobbering eax)
     # . eax = elemsize
     8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           0/r32/eax   0x10/disp8      .                 # copy *(ebp+16) to eax
     # . eax *= length
@@ -23,7 +23,7 @@ new-stream:  # ad: (addr allocation-descriptor), length: int, elemsize: int, out
     75/jump-if-!=  $new-stream:abort/disp8
     # . edx = elemsize*length
     89/copy                         3/mod/direct    2/rm32/edx    .           .             .           0/r32/eax   .               .                 # copy eax to edx
-    # . eax += 12
+    # var n/eax: int = size + 12 (for read, write and size)
     05/add-to-eax  0xc/imm32
     # allocate(ad, n, out)
     # . . push args
@@ -39,7 +39,7 @@ new-stream:  # ad: (addr allocation-descriptor), length: int, elemsize: int, out
     8b/copy                         1/mod/*+disp8   0/rm32/eax    .           .             .           0/r32/eax   4/disp8         .                 # copy *(eax+4) to eax
     # skip payload->allocid
     05/add-to-eax  4/imm32
-    # eax->size = elemsize*length
+    # eax->size = size
     89/copy                         1/mod/*+disp8   0/rm32/eax    .           .             .           2/r32/edx   8/disp8         .                 # copy edx to *(eax+8)
     # clear-stream(eax)
     # . . push args