about summary refs log tree commit diff stats
path: root/057write.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-04-03 12:35:53 -0700
committerKartik Agaram <vc@akkartik.com>2020-04-03 12:35:53 -0700
commitbfcc0f858aa324739ad645e2056d73a47ab66f82 (patch)
tree24a22e364b2c1d535013c604b7a9620a31606e71 /057write.subx
parentf730f2f2c7934f52091a848b71f9031ea99e2377 (diff)
downloadmu-bfcc0f858aa324739ad645e2056d73a47ab66f82.tar.gz
6182 - start of support for safe handles
So far it's unclear how to do this in a series of small commits. Still
nibbling around the edges. In this commit we standardize some terminology:

The length of an array or stream is denominated in the high-level elements.
The _size_ is denominated in bytes.

The thing we encode into the type is always the size, not the length.

There's still an open question of what to do about the Mu `length` operator.
I'd like to modify it to provide the length. Currently it provides the
size. If I can't fix that I'll rename it.
Diffstat (limited to '057write.subx')
-rw-r--r--057write.subx10
1 files changed, 5 insertions, 5 deletions
diff --git a/057write.subx b/057write.subx
index da369a0a..988e21db 100644
--- a/057write.subx
+++ b/057write.subx
@@ -13,7 +13,7 @@
 # A stream looks like this:
 #   read: int  # index at which to read next
 #   write: int  # index at which writes go
-#   data: (array byte)  # prefixed by length as usual
+#   data: (array byte)  # prefixed by size as usual
 
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
@@ -47,12 +47,12 @@ $write:fake:
     8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .                         1/r32/ecx   8/disp8         .                 # copy *(ebp+8) to ecx
     # edx = f->write
     8b/copy                         0/mod/indirect  1/rm32/ecx    .           .             .           2/r32/edx   .               .                 # copy *ecx to edx
-    # ebx = f->length
+    # ebx = f->size
     8b/copy                         1/mod/*+disp8   1/rm32/ecx    .           .             .           3/r32/ebx   8/disp8         .                 # copy *(ecx+8) to ebx
-    # eax = _append-3(&f->data[f->write], &f->data[f->length], s)
+    # eax = _append-3(&f->data[f->write], &f->data[f->size], s)
     # . . push s
     ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           0xc/disp8       .                 # push *(ebp+12)
-    # . . push &f->data[f->length]
+    # . . push &f->data[f->size]
     8d/copy-address                 1/mod/*+disp8   4/rm32/sib    1/base/ecx  3/index/ebx   .           3/r32/ebx   0xc/disp8       .                 # copy ecx+ebx+12 to ebx
     53/push-ebx
     # . . push &f->data[f->write]
@@ -150,7 +150,7 @@ _test-stream:  # (stream byte)
     0/imm32
     # current read index
     0/imm32
-    # length
+    # size
     0x10/imm32
     # data (2 lines x 8 bytes/line)
     00 00 00 00 00 00 00 00