about summary refs log tree commit diff stats
path: root/054string-equal.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-12-08 13:56:46 -0800
committerKartik Agaram <vc@akkartik.com>2019-12-08 23:31:05 -0800
commit2a2a5b1e43b6aa650a41ab1ec68d9778c14cb649 (patch)
tree734619639755cf5b95490bdc4362bbef0a504881 /054string-equal.subx
parenta93cd189c95fc82a8f1db4e42e5f278bc642bb0c (diff)
downloadmu-2a2a5b1e43b6aa650a41ab1ec68d9778c14cb649.tar.gz
5804
Try to make the comments consistent with the type system we'll eventually
have.
Diffstat (limited to '054string-equal.subx')
-rw-r--r--054string-equal.subx17
1 files changed, 9 insertions, 8 deletions
diff --git a/054string-equal.subx b/054string-equal.subx
index 484844d9..c63688a1 100644
--- a/054string-equal.subx
+++ b/054string-equal.subx
@@ -13,12 +13,12 @@ Entry:  # run all tests
     b8/copy-to-eax  1/imm32/exit
     cd/syscall  0x80/imm8
 
-string-equal?:  # s : (address string), benchmark : (address string) -> eax : boolean
+string-equal?:  # s : (address array byte), benchmark : (address array byte) -> eax : boolean
     # pseudocode:
     #   if (s->length != benchmark->length) return false
     #   currs = s->data
     #   currb = benchmark->data
-    #   maxs = s->data + s->length
+    #   maxs = &s->data[s->length]
     #   while currs < maxs
     #     c1 = *currs
     #     c2 = *currb
@@ -51,14 +51,15 @@ $string-equal?:lengths:
     # if (ecx != benchmark->length) return false
     39/compare                      0/mod/indirect  7/rm32/edi    .           .             .           1/r32/ecx   .               .                 # compare *edi and ecx
     75/jump-if-not-equal  $string-equal?:false/disp8
-    # currs/esi = s->data
+    # var currs/esi : (address byte) = s->data
     81          0/subop/add         3/mod/direct    6/rm32/esi    .           .             .           .           .               4/imm32           # add to esi
-    # maxs/ecx = s->data + s->length
+    # var maxs/ecx : (address byte) = &s->data[s->length]
     01/add                          3/mod/direct    1/rm32/ecx    .           .             .           6/r32/esi   .               .                 # add esi to ecx
-    # currb/edi = benchmark->data
+    # var currb/edi : (address byte) = benchmark->data
     81          0/subop/add         3/mod/direct    7/rm32/edi    .           .             .           .           .               4/imm32           # add to edi
-    # c1/eax = c2/edx = 0
+    # var c1/eax : byte = 0
     31/xor                          3/mod/direct    0/rm32/eax    .           .             .           0/r32/eax   .               .                 # clear eax
+    # var c2/edx : byte = 0
     31/xor                          3/mod/direct    2/rm32/edx    .           .             .           2/r32/edx   .               .                 # clear edx
 $string-equal?:loop:
     # if (currs >= maxs) return true
@@ -175,13 +176,13 @@ test-compare-inequal-strings-equal-lengths:
     c3/return
 
 # helper for later tests
-check-strings-equal:  # s : (address string), expected : (address string), msg : (address string)
+check-strings-equal:  # s : (address array byte), expected : (address array byte), msg : (address array byte)
     # . prologue
     55/push-ebp
     89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
     # . save registers
     50/push-eax
-    # eax = string-equal?(s, expected)
+    # var eax : boolean = string-equal?(s, expected)
     # . . push args
     ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           0xc/disp8       .                 # push *(ebp+12)
     ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           8/disp8         .                 # push *(ebp+8)