From 2a2a5b1e43b6aa650a41ab1ec68d9778c14cb649 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 8 Dec 2019 13:56:46 -0800 Subject: 5804 Try to make the comments consistent with the type system we'll eventually have. --- 054string-equal.subx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to '054string-equal.subx') 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) -- cgit 1.4.1-2-gfad0