about summary refs log tree commit diff stats
path: root/subx/058stream-equal.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-02-14 16:24:20 -0800
committerKartik Agaram <vc@akkartik.com>2019-02-14 16:24:20 -0800
commit1639687ba098aa81b0584f7dd609cb9690dc5a04 (patch)
tree1a5ee40c30bf906c6ba5e55b8c5138a467022105 /subx/058stream-equal.subx
parent1ab48a69ccfa4ddaa2e1fa803ea6fe568b890abc (diff)
downloadmu-1639687ba098aa81b0584f7dd609cb9690dc5a04.tar.gz
4961
Diffstat (limited to 'subx/058stream-equal.subx')
-rw-r--r--subx/058stream-equal.subx36
1 files changed, 18 insertions, 18 deletions
diff --git a/subx/058stream-equal.subx b/subx/058stream-equal.subx
index e4c1962e..203e5415 100644
--- a/subx/058stream-equal.subx
+++ b/subx/058stream-equal.subx
@@ -32,7 +32,7 @@ stream-data-equal?:  # f : (address stream), s : (address string) -> EAX : boole
     81          0/subop/add         3/mod/direct    6/rm32/ESI    .           .             .           .           .               0xc/imm32         # add to ESI
     # EDI = s
     8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .             .           7/r32/EDI   0xc/disp8       .                 # copy *(EBP+12) to EDI
-    # if (f->write != s->length) return false;
+    # if (f->write != s->length) return false
     39/compare                      0/mod/indirect  7/rm32/EDI    .           .             .           0/r32/EAX   .               .                 # compare *EDI and EAX
     75/jump-if-not-equal  $stream-data-equal?:false/disp8
     # currs/EDI = s->data
@@ -235,25 +235,25 @@ next-stream-line-equal?:  # f : (address stream), s : (address string) -> EAX :
     # pseudocode:
     #   currf = f->read  # bound: f->write
     #   currs = 0  # bound : s->length
-    #   while true
-    #     if currf >= f->write
+    #   while true:
+    #     if (currf >= f->write)
     #       return currs >= s->length
-    #     if f[currf] == '\n'
+    #     if (f[currf] == '\n')
     #       ++currf
     #       return currs >= s->length
-    #     if currs >= s->length return false  # the current line of f still has data to match
-    #     if f[currf] != s[currs] return false
+    #     if (currs >= s->length) return false  # the current line of f still has data to match
+    #     if (f[currf] != s[currs]) return false
     #     ++currf
     #     ++currs
     #
     # collapsing the two branches that can return true:
     #   currf = f->read  # bound: f->write
     #   currs = 0  # bound : s->length
-    #   while true
-    #     if currf >= f->write break
-    #     if f[currf] == '\n' break
-    #     if currs >= s->length return false  # the current line of f still has data to match
-    #     if f[currf] != s[currs] return false
+    #   while true:
+    #     if (currf >= f->write) break
+    #     if (f[currf] == '\n') break
+    #     if (currs >= s->length) return false  # the current line of f still has data to match
+    #     if (f[currf] != s[currs]) return false
     #     ++currf
     #     ++currs
     #   ++currf  # skip '\n'
@@ -261,12 +261,12 @@ next-stream-line-equal?:  # f : (address stream), s : (address string) -> EAX :
     # Here the final `++currf` is sometimes unnecessary (if we're already at the end of the stream)
     #
     # registers:
-    #   f : ESI
-    #   s : EDI
-    #   currf : ECX
-    #   currs : EDX
-    #   f[currf] : EAX
-    #   s[currs] : EBX
+    #   f: ESI
+    #   s: EDI
+    #   currf: ECX
+    #   currs: EDX
+    #   f[currf]: EAX
+    #   s[currs]: EBX
     #
     # . prolog
     55/push-EBP
@@ -312,7 +312,7 @@ $next-stream-line-equal?:loop:
 $next-stream-line-equal?:break:
     # ++currf
     41/increment-ECX
-    # if currs >= s->length return true
+    # if (currs >= s->length) return true
     3b/compare                      0/mod/indirect  7/rm32/EDI    .           .             .           2/r32/EDX   .               .                 # compare EDX with *EDI
     7c/jump-if-lesser  $next-stream-line-equal?:false/disp8
 $next-stream-line-equal?:true: