diff options
Diffstat (limited to '058stream-equal.subx')
-rw-r--r-- | 058stream-equal.subx | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/058stream-equal.subx b/058stream-equal.subx index 3bd6a3b3..b3bd9b95 100644 --- a/058stream-equal.subx +++ b/058stream-equal.subx @@ -25,8 +25,8 @@ stream-data-equal?: # f: (addr stream byte), s: (addr array byte) -> 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 -$stream-data-equal?:compare-lengths: - # if (f->write != s->length) return false +$stream-data-equal?:compare-sizes: + # if (f->write != s->size) return false 39/compare 0/mod/indirect 7/rm32/edi . . . 0/r32/eax . . # compare *edi and eax 75/jump-if-!= $stream-data-equal?:false/disp8 # var currs/edi: (addr byte) = s->data @@ -149,7 +149,7 @@ test-stream-data-equal-2: 5d/pop-to-ebp c3/return -test-stream-data-equal-length-check: +test-stream-data-equal-size-check: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -178,7 +178,7 @@ test-stream-data-equal-length-check: 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp # check-ints-equal(eax, 0, msg) # . . push args - 68/push "F - test-stream-data-equal-length-check"/imm32 + 68/push "F - test-stream-data-equal-size-check"/imm32 68/push 0/imm32 50/push-eax # . . call @@ -230,30 +230,30 @@ $check-stream-equal:end: next-stream-line-equal?: # f: (addr stream byte), s: (addr array byte) -> eax: boolean # pseudocode: # currf = f->read # bound: f->write - # currs = 0 # bound: s->length + # currs = 0 # bound: s->size # while true # if currf >= f->write - # return currs >= s->length + # return currs >= s->size # 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 + # return currs >= s->size + # if (currs >= s->size) 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 + # currs = 0 # bound: s->size # 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 (currs >= s->size) return false # the current line of f still has data to match # if (f[currf] != s[currs]) return false # ++currf # ++currs # ++currf # skip '\n' - # return currs >= s->length + # return currs >= s->size # Here the final `++currf` is sometimes unnecessary (if we're already at the end of the stream) # # registers: @@ -293,7 +293,7 @@ $next-stream-line-equal?:loop: # if (c1 == '\n') break 3d/compare-eax-and 0xa/imm32/newline 74/jump-if-= $next-stream-line-equal?:break/disp8 - # if (currs >= s->length) return false + # if (currs >= s->size) return false 3b/compare 0/mod/indirect 7/rm32/edi . . . 2/r32/edx . . # compare edx with *edi 7d/jump-if->= $next-stream-line-equal?:false/disp8 # c2 = s->data[currs] @@ -309,7 +309,7 @@ $next-stream-line-equal?:loop: $next-stream-line-equal?:break: # ++currf 41/increment-ecx - # if (currs >= s->length) return true + # if (currs >= s->size) return true 3b/compare 0/mod/indirect 7/rm32/edi . . . 2/r32/edx . . # compare edx with *edi 7c/jump-if-< $next-stream-line-equal?:false/disp8 $next-stream-line-equal?:true: |