diff options
-rw-r--r-- | 118parse-hex-int.subx | 142 | ||||
-rw-r--r-- | 126write-int-decimal.subx | 40 | ||||
-rw-r--r-- | 311decimal-int.subx | 4 | ||||
-rw-r--r-- | 400.mu | 6 | ||||
-rw-r--r-- | shell/eval.mu | 60 | ||||
-rw-r--r-- | shell/grapheme-stack.mu | 2 | ||||
-rw-r--r-- | shell/parse.mu | 20 | ||||
-rw-r--r-- | shell/print.mu | 10 | ||||
-rw-r--r-- | shell/tokenize.mu | 34 | ||||
-rw-r--r-- | shell/trace.mu | 12 |
10 files changed, 165 insertions, 165 deletions
diff --git a/118parse-hex-int.subx b/118parse-hex-int.subx index 153def3c..0e5cd65f 100644 --- a/118parse-hex-int.subx +++ b/118parse-hex-int.subx @@ -6,7 +6,7 @@ # . op subop mod rm32 base index scale r32 # . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes -is-hex-int?: # in: (addr slice) -> result/eax: boolean +hex-int?: # in: (addr slice) -> result/eax: boolean # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -23,58 +23,58 @@ is-hex-int?: # in: (addr slice) -> result/eax: boolean # if s is empty return false b8/copy-to-eax 0/imm32/false 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx - 73/jump-if-addr>= $is-hex-int?:end/disp8 + 73/jump-if-addr>= $hex-int?:end/disp8 # skip past leading '-' # . if (*curr == '-') ++curr 31/xor 3/mod/direct 3/rm32/ebx . . . 3/r32/ebx . . # clear ebx 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 3/r32/BL . . # copy byte at *ecx to BL 81 7/subop/compare 3/mod/direct 3/rm32/ebx . . . . . 0x2d/imm32/- # compare ebx - 75/jump-if-!= $is-hex-int?:initial-0/disp8 + 75/jump-if-!= $hex-int?:initial-0/disp8 # . ++curr 41/increment-ecx # skip past leading '0x' -$is-hex-int?:initial-0: +$hex-int?:initial-0: # . if (*curr != '0') jump to loop 31/xor 3/mod/direct 3/rm32/ebx . . . 3/r32/ebx . . # clear ebx 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 3/r32/BL . . # copy byte at *ecx to BL 81 7/subop/compare 3/mod/direct 3/rm32/ebx . . . . . 0x30/imm32/0 # compare ebx - 75/jump-if-!= $is-hex-int?:loop/disp8 + 75/jump-if-!= $hex-int?:loop/disp8 # . ++curr 41/increment-ecx -$is-hex-int?:initial-0x: +$hex-int?:initial-0x: # . if (curr >= in->end) return true 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx - 73/jump-if-addr>= $is-hex-int?:true/disp8 + 73/jump-if-addr>= $hex-int?:true/disp8 # . if (*curr != 'x') jump to loop # the previous '0' is still valid so doesn't need to be checked again 31/xor 3/mod/direct 3/rm32/ebx . . . 3/r32/ebx . . # clear ebx 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 3/r32/BL . . # copy byte at *ecx to BL 81 7/subop/compare 3/mod/direct 3/rm32/ebx . . . . . 0x78/imm32/x # compare ebx - 75/jump-if-!= $is-hex-int?:loop/disp8 + 75/jump-if-!= $hex-int?:loop/disp8 # . ++curr 41/increment-ecx -$is-hex-int?:loop: +$hex-int?:loop: # if (curr >= in->end) return true 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx - 73/jump-if-addr>= $is-hex-int?:true/disp8 - # var eax: boolean = is-hex-digit?(*curr) + 73/jump-if-addr>= $hex-int?:true/disp8 + # var eax: boolean = hex-digit?(*curr) # . . push args 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . . # copy byte at *ecx to AL 50/push-eax # . . call - e8/call is-hex-digit?/disp32 + e8/call hex-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # if (eax == false) return false 3d/compare-eax-and 0/imm32/false - 74/jump-if-= $is-hex-int?:end/disp8 + 74/jump-if-= $hex-int?:end/disp8 # ++curr 41/increment-ecx # loop - eb/jump $is-hex-int?:loop/disp8 -$is-hex-int?:true: + eb/jump $hex-int?:loop/disp8 +$hex-int?:true: # return true b8/copy-to-eax 1/imm32/true -$is-hex-int?:end: +$hex-int?:end: # . restore registers 5b/pop-to-ebx 5a/pop-to-edx @@ -84,7 +84,7 @@ $is-hex-int?:end: 5d/pop-to-ebp c3/return -test-is-hex-int: +test-hex-int: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -97,16 +97,16 @@ test-is-hex-int: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = is-hex-int?(slice) + # eax = hex-int?(slice) # . . push args 51/push-ecx # . . call - e8/call is-hex-int?/disp32 + e8/call hex-int?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) # . . push args - 68/push "F - test-is-hex-int"/imm32 + 68/push "F - test-hex-int"/imm32 68/push 1/imm32/true 50/push-eax # . . call @@ -118,7 +118,7 @@ test-is-hex-int: 5d/pop-to-ebp c3/return -test-is-hex-int-handles-letters: +test-hex-int-handles-letters: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -131,16 +131,16 @@ test-is-hex-int-handles-letters: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = is-hex-int?(slice) + # eax = hex-int?(slice) # . . push args 51/push-ecx # . . call - e8/call is-hex-int?/disp32 + e8/call hex-int?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) # . . push args - 68/push "F - test-is-hex-int-handles-letters"/imm32 + 68/push "F - test-hex-int-handles-letters"/imm32 68/push 1/imm32/true 50/push-eax # . . call @@ -152,7 +152,7 @@ test-is-hex-int-handles-letters: 5d/pop-to-ebp c3/return -test-is-hex-int-with-trailing-char: +test-hex-int-with-trailing-char: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -165,16 +165,16 @@ test-is-hex-int-with-trailing-char: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = is-hex-int?(slice) + # eax = hex-int?(slice) # . . push args 51/push-ecx # . . call - e8/call is-hex-int?/disp32 + e8/call hex-int?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0, msg) # . . push args - 68/push "F - test-is-hex-int-with-trailing-char"/imm32 + 68/push "F - test-hex-int-with-trailing-char"/imm32 68/push 0/imm32/false 50/push-eax # . . call @@ -186,7 +186,7 @@ test-is-hex-int-with-trailing-char: 5d/pop-to-ebp c3/return -test-is-hex-int-with-leading-char: +test-hex-int-with-leading-char: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -199,16 +199,16 @@ test-is-hex-int-with-leading-char: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = is-hex-int?(slice) + # eax = hex-int?(slice) # . . push args 51/push-ecx # . . call - e8/call is-hex-int?/disp32 + e8/call hex-int?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0, msg) # . . push args - 68/push "F - test-is-hex-int-with-leading-char"/imm32 + 68/push "F - test-hex-int-with-leading-char"/imm32 68/push 0/imm32/false 50/push-eax # . . call @@ -220,7 +220,7 @@ test-is-hex-int-with-leading-char: 5d/pop-to-ebp c3/return -test-is-hex-int-empty: +test-hex-int-empty: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -228,16 +228,16 @@ test-is-hex-int-empty: 68/push 0/imm32 68/push 0/imm32 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = is-hex-int?(slice) + # eax = hex-int?(slice) # . . push args 51/push-ecx # . . call - e8/call is-hex-int?/disp32 + e8/call hex-int?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0, msg) # . . push args - 68/push "F - test-is-hex-int-empty"/imm32 + 68/push "F - test-hex-int-empty"/imm32 68/push 0/imm32/false 50/push-eax # . . call @@ -249,7 +249,7 @@ test-is-hex-int-empty: 5d/pop-to-ebp c3/return -test-is-hex-int-handles-0x-prefix: +test-hex-int-handles-0x-prefix: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -262,16 +262,16 @@ test-is-hex-int-handles-0x-prefix: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = is-hex-int?(slice) + # eax = hex-int?(slice) # . . push args 51/push-ecx # . . call - e8/call is-hex-int?/disp32 + e8/call hex-int?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) # . . push args - 68/push "F - test-is-hex-int-handles-0x-prefix"/imm32 + 68/push "F - test-hex-int-handles-0x-prefix"/imm32 68/push 1/imm32/true 50/push-eax # . . call @@ -283,7 +283,7 @@ test-is-hex-int-handles-0x-prefix: 5d/pop-to-ebp c3/return -test-is-hex-int-handles-negative: +test-hex-int-handles-negative: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -296,16 +296,16 @@ test-is-hex-int-handles-negative: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = is-hex-int?(slice) + # eax = hex-int?(slice) # . . push args 51/push-ecx # . . call - e8/call is-hex-int?/disp32 + e8/call hex-int?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) # . . push args - 68/push "F - test-is-hex-int-handles-negative"/imm32 + 68/push "F - test-hex-int-handles-negative"/imm32 68/push 1/imm32/true 50/push-eax # . . call @@ -317,7 +317,7 @@ test-is-hex-int-handles-negative: 5d/pop-to-ebp c3/return -test-is-hex-int-handles-negative-0x-prefix: +test-hex-int-handles-negative-0x-prefix: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -330,16 +330,16 @@ test-is-hex-int-handles-negative-0x-prefix: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = is-hex-int?(slice) + # eax = hex-int?(slice) # . . push args 51/push-ecx # . . call - e8/call is-hex-int?/disp32 + e8/call hex-int?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) # . . push args - 68/push "F - test-is-hex-int-handles-negative-0x-prefix"/imm32 + 68/push "F - test-hex-int-handles-negative-0x-prefix"/imm32 68/push 1/imm32/true 50/push-eax # . . call @@ -698,7 +698,7 @@ test-parse-hex-int-from-slice-negative: 5d/pop-to-ebp c3/return -is-hex-digit?: # c: byte -> result/eax: boolean +hex-digit?: # c: byte -> result/eax: boolean # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -708,25 +708,25 @@ is-hex-digit?: # c: byte -> result/eax: boolean 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 . # copy *(ebp+8) to ecx # return false if c < '0' 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x30/imm32 # compare ecx - 7c/jump-if-< $is-hex-digit?:false/disp8 + 7c/jump-if-< $hex-digit?:false/disp8 # return true if c <= '9' 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x39/imm32 # compare ecx - 7e/jump-if-<= $is-hex-digit?:true/disp8 + 7e/jump-if-<= $hex-digit?:true/disp8 # drop case 25/and-eax-with 0x5f/imm32 # return false if c > 'f' 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x66/imm32 # compare ecx - 7f/jump-if-> $is-hex-digit?:false/disp8 + 7f/jump-if-> $hex-digit?:false/disp8 # return true if c >= 'a' 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x61/imm32 # compare ecx - 7d/jump-if->= $is-hex-digit?:true/disp8 + 7d/jump-if->= $hex-digit?:true/disp8 # otherwise return false -$is-hex-digit?:false: +$hex-digit?:false: b8/copy-to-eax 0/imm32/false - eb/jump $is-hex-digit?:end/disp8 -$is-hex-digit?:true: + eb/jump $hex-digit?:end/disp8 +$hex-digit?:true: b8/copy-to-eax 1/imm32/true -$is-hex-digit?:end: +$hex-digit?:end: # . restore registers 59/pop-to-ecx # . epilogue @@ -735,11 +735,11 @@ $is-hex-digit?:end: c3/return test-hex-below-0: - # eax = is-hex-digit?(0x2f) + # eax = hex-digit?(0x2f) # . . push args 68/push 0x2f/imm32 # . . call - e8/call is-hex-digit?/disp32 + e8/call hex-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0, msg) @@ -754,11 +754,11 @@ test-hex-below-0: c3/return test-hex-0-to-9: - # eax = is-hex-digit?(0x30) + # eax = hex-digit?(0x30) # . . push args 68/push 0x30/imm32 # . . call - e8/call is-hex-digit?/disp32 + e8/call hex-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) @@ -770,11 +770,11 @@ test-hex-0-to-9: e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp - # eax = is-hex-digit?(0x39) + # eax = hex-digit?(0x39) # . . push args 68/push 0x39/imm32 # . . call - e8/call is-hex-digit?/disp32 + e8/call hex-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) @@ -789,11 +789,11 @@ test-hex-0-to-9: c3/return test-hex-above-9-to-a: - # eax = is-hex-digit?(0x3a) + # eax = hex-digit?(0x3a) # . . push args 68/push 0x3a/imm32 # . . call - e8/call is-hex-digit?/disp32 + e8/call hex-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0, msg) @@ -808,11 +808,11 @@ test-hex-above-9-to-a: c3/return test-hex-a-to-f: - # eax = is-hex-digit?(0x61) + # eax = hex-digit?(0x61) # . . push args 68/push 0x61/imm32 # . . call - e8/call is-hex-digit?/disp32 + e8/call hex-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) @@ -824,11 +824,11 @@ test-hex-a-to-f: e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp - # eax = is-hex-digit?(0x66) + # eax = hex-digit?(0x66) # . . push args 68/push 0x66/imm32 # . . call - e8/call is-hex-digit?/disp32 + e8/call hex-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) @@ -843,11 +843,11 @@ test-hex-a-to-f: c3/return test-hex-above-f: - # eax = is-hex-digit?(0x67) + # eax = hex-digit?(0x67) # . . push args 68/push 0x67/imm32 # . . call - e8/call is-hex-digit?/disp32 + e8/call hex-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0, msg) diff --git a/126write-int-decimal.subx b/126write-int-decimal.subx index 9f148248..bc4a510e 100644 --- a/126write-int-decimal.subx +++ b/126write-int-decimal.subx @@ -296,7 +296,7 @@ test-write-int32-decimal-negative-multiple-digits: # . end c3/return -is-decimal-digit?: # c: grapheme -> result/eax: boolean +decimal-digit?: # c: grapheme -> result/eax: boolean # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -308,13 +308,13 @@ is-decimal-digit?: # c: grapheme -> result/eax: boolean b8/copy-to-eax 0/imm32/false # return false if c < '0' 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x30/imm32 # compare ecx - 7c/jump-if-< $is-decimal-digit?:end/disp8 + 7c/jump-if-< $decimal-digit?:end/disp8 # return (c <= '9') 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x39/imm32 # compare ecx - 7f/jump-if-> $is-decimal-digit?:end/disp8 -$is-decimal-digit?:true: + 7f/jump-if-> $decimal-digit?:end/disp8 +$decimal-digit?:true: b8/copy-to-eax 1/imm32/true -$is-decimal-digit?:end: +$decimal-digit?:end: # . restore registers 59/pop-to-ecx # . epilogue @@ -322,17 +322,17 @@ $is-decimal-digit?:end: 5d/pop-to-ebp c3/return -test-is-decimal-digit-below-0: - # eax = is-decimal-digit?(0x2f) +test-decimal-digit-below-0: + # eax = decimal-digit?(0x2f) # . . push args 68/push 0x2f/imm32 # . . call - e8/call is-decimal-digit?/disp32 + e8/call decimal-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0, msg) # . . push args - 68/push "F - test-is-decimal-digit-below-0"/imm32 + 68/push "F - test-decimal-digit-below-0"/imm32 68/push 0/imm32/false 50/push-eax # . . call @@ -341,33 +341,33 @@ test-is-decimal-digit-below-0: 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp c3/return -test-is-decimal-digit-0-to-9: - # eax = is-decimal-digit?(0x30) +test-decimal-digit-0-to-9: + # eax = decimal-digit?(0x30) # . . push args 68/push 0x30/imm32 # . . call - e8/call is-decimal-digit?/disp32 + e8/call decimal-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) # . . push args - 68/push "F - test-is-decimal-digit-at-0"/imm32 + 68/push "F - test-decimal-digit-at-0"/imm32 68/push 1/imm32/true 50/push-eax # . . call e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp - # eax = is-decimal-digit?(0x39) + # eax = decimal-digit?(0x39) # . . push args 68/push 0x39/imm32 # . . call - e8/call is-decimal-digit?/disp32 + e8/call decimal-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 1, msg) # . . push args - 68/push "F - test-is-decimal-digit-at-9"/imm32 + 68/push "F - test-decimal-digit-at-9"/imm32 68/push 1/imm32/true 50/push-eax # . . call @@ -376,17 +376,17 @@ test-is-decimal-digit-0-to-9: 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp c3/return -test-is-decimal-digit-above-9: - # eax = is-decimal-digit?(0x3a) +test-decimal-digit-above-9: + # eax = decimal-digit?(0x3a) # . . push args 68/push 0x3a/imm32 # . . call - e8/call is-decimal-digit?/disp32 + e8/call decimal-digit?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0, msg) # . . push args - 68/push "F - test-is-decimal-digit-above-9"/imm32 + 68/push "F - test-decimal-digit-above-9"/imm32 68/push 0/imm32/false 50/push-eax # . . call diff --git a/311decimal-int.subx b/311decimal-int.subx index d0d8dde7..f7c108dd 100644 --- a/311decimal-int.subx +++ b/311decimal-int.subx @@ -124,10 +124,10 @@ $parse-decimal-int-helper:loop: # if (curr >= in->end) break 39/compare %esi 7/r32/edi 73/jump-if-addr>= break/disp8 - # if !is-decimal-digit?(*curr) return 0 + # if !decimal-digit?(*curr) return 0 8a/copy-byte *esi 1/r32/CL 50/push-eax - (is-decimal-digit? %ecx) # => eax + (decimal-digit? %ecx) # => eax { 3d/compare-eax-and 0/imm32/false 75/jump-if-!= break/disp8 diff --git a/400.mu b/400.mu index 9d0c095f..44d94213 100644 --- a/400.mu +++ b/400.mu @@ -31,11 +31,11 @@ sig append-byte f: (addr stream byte), n: int sig append-byte-hex f: (addr stream byte), n: int sig write-int32-hex f: (addr stream byte), n: int sig write-int32-hex-bits f: (addr stream byte), n: int, bits: int -sig is-hex-int? in: (addr slice) -> _/eax: boolean +sig hex-int? in: (addr slice) -> _/eax: boolean sig parse-hex-int in: (addr array byte) -> _/eax: int sig parse-hex-int-from-slice in: (addr slice) -> _/eax: int #sig parse-hex-int-helper start: (addr byte), end: (addr byte) -> _/eax: int -sig is-hex-digit? c: byte -> _/eax: boolean +sig hex-digit? c: byte -> _/eax: boolean #sig from-hex-char in/eax: byte -> out/eax: nibble sig parse-decimal-int in: (addr array byte) -> _/eax: int sig parse-decimal-int-from-slice in: (addr slice) -> _/eax: int @@ -58,7 +58,7 @@ sig write-slice out: (addr stream byte), s: (addr slice) # bad name alert sig slice-to-string ad: (addr allocation-descriptor), in: (addr slice), out: (addr handle array byte) sig write-int32-decimal out: (addr stream byte), n: int -sig is-decimal-digit? c: grapheme -> _/eax: boolean +sig decimal-digit? c: grapheme -> _/eax: boolean sig to-decimal-digit in: grapheme -> _/eax: int # bad name alert # next-word really tokenizes diff --git a/shell/eval.mu b/shell/eval.mu index 13822aac..e1fc3c50 100644 --- a/shell/eval.mu +++ b/shell/eval.mu @@ -17,8 +17,8 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel trace-lower trace var in-addr/eax: (addr cell) <- lookup *in { - var is-nil?/eax: boolean <- is-nil? in-addr - compare is-nil?, 0/false + var nil?/eax: boolean <- nil? in-addr + compare nil?, 0/false break-if-= # nil is a literal trace-text trace, "eval", "nil" @@ -51,8 +51,8 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel # if its first elem is not "fn", break var first-ah/ecx: (addr handle cell) <- get in-addr, left var first/eax: (addr cell) <- lookup *first-ah - var is-fn?/eax: boolean <- is-fn? first - compare is-fn?, 0/false + var fn?/eax: boolean <- fn? first + compare fn?, 0/false break-if-= # trace-text trace, "eval", "anonymous function" @@ -68,8 +68,8 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel var curr/ecx: (addr cell) <- copy in-addr $evaluate-list:loop: { allocate-pair curr-out-ah - var is-nil?/eax: boolean <- is-nil? curr - compare is-nil?, 0/false + var nil?/eax: boolean <- nil? curr + compare nil?, 0/false break-if-!= # eval left var curr-out/eax: (addr cell) <- lookup *curr-out-ah @@ -133,8 +133,8 @@ fn apply _f-ah: (addr handle cell), args-ah: (addr handle cell), out: (addr hand break-if-!= var first-ah/eax: (addr handle cell) <- get f, left var first/eax: (addr cell) <- lookup *first-ah - var is-fn?/eax: boolean <- is-fn? first - compare is-fn?, 0/false + var fn?/eax: boolean <- fn? first + compare fn?, 0/false break-if-= var rest-ah/esi: (addr handle cell) <- get f, right var rest/eax: (addr cell) <- lookup *rest-ah @@ -158,8 +158,8 @@ fn apply-function params-ah: (addr handle cell), args-ah: (addr handle cell), _b var body/eax: (addr cell) <- lookup *body-ah # stop when body is nil { - var body-is-nil?/eax: boolean <- is-nil? body - compare body-is-nil?, 0/false + var body-nil?/eax: boolean <- nil? body + compare body-nil?, 0/false break-if-!= $apply-function:body } # evaluate each expression, writing result to `out` @@ -191,8 +191,8 @@ fn push-bindings _params-ah: (addr handle cell), _args-ah: (addr handle cell), o var _params/eax: (addr cell) <- lookup *params-ah var params/esi: (addr cell) <- copy _params { - var params-is-nil?/eax: boolean <- is-nil? params - compare params-is-nil?, 0/false + var params-nil?/eax: boolean <- nil? params + compare params-nil?, 0/false break-if-= # nil is a literal trace-text trace, "eval", "done with push-bindings" @@ -278,7 +278,7 @@ fn apply-add _args-ah: (addr handle cell), out: (addr handle cell), env-h: (hand var _env/eax: (addr cell) <- lookup env-h var env/edi: (addr cell) <- copy _env # TODO: check that args is a pair - var empty-args?/eax: boolean <- is-nil? args + var empty-args?/eax: boolean <- nil? args compare empty-args?, 0/false { break-if-= @@ -348,8 +348,8 @@ fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell) } # if env is nil, look up in globals { - var env-is-nil?/eax: boolean <- is-nil? env - compare env-is-nil?, 0/false + var env-nil?/eax: boolean <- nil? env + compare env-nil?, 0/false break-if-= lookup-symbol-in-hardcoded-globals sym, out, trace trace-higher trace @@ -446,8 +446,8 @@ fn lookup-symbol-in-hardcoded-globals _sym: (addr cell), out: (addr handle cell) var _sym-data/eax: (addr stream byte) <- lookup *sym-data-ah var sym-data/esi: (addr stream byte) <- copy _sym-data { - var is-add?/eax: boolean <- stream-data-equal? sym-data, "+" - compare is-add?, 0/false + var add?/eax: boolean <- stream-data-equal? sym-data, "+" + compare add?, 0/false break-if-= new-primitive-function out, 1/add trace-text trace, "eval", "global +" @@ -525,8 +525,8 @@ fn car _in: (addr cell), out: (addr handle cell), trace: (addr trace) { } # if in is nil, abort { - var in-is-nil?/eax: boolean <- is-nil? in - compare in-is-nil?, 0/false + var in-nil?/eax: boolean <- nil? in + compare in-nil?, 0/false break-if-= error trace, "car on nil" trace-higher trace @@ -553,8 +553,8 @@ fn cdr _in: (addr cell), out: (addr handle cell), trace: (addr trace) { } # if in is nil, abort { - var in-is-nil?/eax: boolean <- is-nil? in - compare in-is-nil?, 0/false + var in-nil?/eax: boolean <- nil? in + compare in-nil?, 0/false break-if-= error trace, "car on nil" trace-higher trace @@ -630,15 +630,15 @@ fn cell-isomorphic? _a: (addr cell), _b: (addr cell), trace: (addr trace) -> _/e } # if a is nil, b should be nil { - # (assumes is-nil? returns 0 or 1) - var _b-is-nil?/eax: boolean <- is-nil? b - var b-is-nil?/ecx: boolean <- copy _b-is-nil? - var a-is-nil?/eax: boolean <- is-nil? a + # (assumes nil? returns 0 or 1) + var _b-nil?/eax: boolean <- nil? b + var b-nil?/ecx: boolean <- copy _b-nil? + var a-nil?/eax: boolean <- nil? a # a == nil and b == nil => return true { - compare a-is-nil?, 0/false + compare a-nil?, 0/false break-if-= - compare b-is-nil?, 0/false + compare b-nil?, 0/false break-if-= trace-higher trace trace-text trace, "eval", "=> true (nils)" @@ -646,7 +646,7 @@ fn cell-isomorphic? _a: (addr cell), _b: (addr cell), trace: (addr trace) -> _/e } # a == nil => return false { - compare a-is-nil?, 0/false + compare a-nil?, 0/false break-if-= trace-higher trace trace-text trace, "eval", "=> false (b != nil)" @@ -654,7 +654,7 @@ fn cell-isomorphic? _a: (addr cell), _b: (addr cell), trace: (addr trace) -> _/e } # b == nil => return false { - compare b-is-nil?, 0/false + compare b-nil?, 0/false break-if-= trace-higher trace trace-text trace, "eval", "=> false (a != nil)" @@ -691,7 +691,7 @@ fn cell-isomorphic? _a: (addr cell), _b: (addr cell), trace: (addr trace) -> _/e return result } -fn is-fn? _x: (addr cell) -> _/eax: boolean { +fn fn? _x: (addr cell) -> _/eax: boolean { var x/esi: (addr cell) <- copy _x var type/eax: (addr int) <- get x, type compare *type, 2/symbol diff --git a/shell/grapheme-stack.mu b/shell/grapheme-stack.mu index 456df0cb..ab42e6fa 100644 --- a/shell/grapheme-stack.mu +++ b/shell/grapheme-stack.mu @@ -270,7 +270,7 @@ fn grapheme-stack-is-decimal-integer? _self: (addr grapheme-stack) -> _/eax: boo compare i, *top-addr break-if->= var g/edx: (addr grapheme) <- index data, i - result <- is-decimal-digit? *g + result <- decimal-digit? *g compare result, 0/false break-if-= i <- increment diff --git a/shell/parse.mu b/shell/parse.mu index a0045eb3..eea5b13f 100644 --- a/shell/parse.mu +++ b/shell/parse.mu @@ -38,16 +38,16 @@ fn parse-sexpression tokens: (addr stream cell), _out: (addr handle cell), trace read-from-stream tokens, curr-token $parse-sexpression:type-check: { # not bracket -> parse atom - var is-bracket-token?/eax: boolean <- is-bracket-token? curr-token - compare is-bracket-token?, 0/false + var bracket-token?/eax: boolean <- bracket-token? curr-token + compare bracket-token?, 0/false { break-if-!= parse-atom curr-token, _out, trace break $parse-sexpression:type-check } # open paren -> parse list - var is-open-paren?/eax: boolean <- is-open-paren-token? curr-token - compare is-open-paren?, 0/false + var open-paren?/eax: boolean <- open-paren-token? curr-token + compare open-paren?, 0/false { break-if-= var curr/esi: (addr handle cell) <- copy _out @@ -56,8 +56,8 @@ fn parse-sexpression tokens: (addr stream cell), _out: (addr handle cell), trace var curr-addr/eax: (addr cell) <- lookup *curr var left/ecx: (addr handle cell) <- get curr-addr, left { - var is-close-paren?/eax: boolean <- parse-sexpression tokens, left, trace - compare is-close-paren?, 0/false + var close-paren?/eax: boolean <- parse-sexpression tokens, left, trace + compare close-paren?, 0/false break-if-!= $parse-sexpression:list-loop } # @@ -67,8 +67,8 @@ fn parse-sexpression tokens: (addr stream cell), _out: (addr handle cell), trace break $parse-sexpression:type-check } # close paren -> parse list - var is-close-paren?/eax: boolean <- is-close-paren-token? curr-token - compare is-close-paren?, 0/false + var close-paren?/eax: boolean <- close-paren-token? curr-token + compare close-paren?, 0/false { break-if-= trace-higher trace @@ -96,8 +96,8 @@ fn parse-atom _curr-token: (addr cell), _out: (addr handle cell), trace: (addr t var curr-token-data/esi: (addr stream byte) <- copy _curr-token-data trace trace, "read", curr-token-data # number - var is-number-token?/eax: boolean <- is-number-token? curr-token - compare is-number-token?, 0/false + var number-token?/eax: boolean <- number-token? curr-token + compare number-token?, 0/false { break-if-= rewind-stream curr-token-data diff --git a/shell/print.mu b/shell/print.mu index ff2a9ed6..53677c22 100644 --- a/shell/print.mu +++ b/shell/print.mu @@ -4,8 +4,8 @@ fn print-cell _in: (addr handle cell), out: (addr stream byte), trace: (addr tra var in/eax: (addr handle cell) <- copy _in var in-addr/eax: (addr cell) <- lookup *in { - var is-nil?/eax: boolean <- is-nil? in-addr - compare is-nil?, 0/false + var nil?/eax: boolean <- nil? in-addr + compare nil?, 0/false break-if-= write out, "()" trace-higher trace @@ -88,8 +88,8 @@ fn print-list _in: (addr cell), out: (addr stream byte), trace: (addr trace) { abort "null encountered" } { - var right-is-nil?/eax: boolean <- is-nil? right-addr - compare right-is-nil?, 0/false + var right-nil?/eax: boolean <- nil? right-addr + compare right-nil?, 0/false { break-if-= trace-text trace, "print", "right is null" @@ -113,7 +113,7 @@ fn print-list _in: (addr cell), out: (addr stream byte), trace: (addr trace) { # Most lisps intern nil, but we don't really have globals yet, so we'll be # less efficient for now. -fn is-nil? _in: (addr cell) -> _/eax: boolean { +fn nil? _in: (addr cell) -> _/eax: boolean { var in/esi: (addr cell) <- copy _in # if type != pair, return false var type/eax: (addr int) <- get in, type diff --git a/shell/tokenize.mu b/shell/tokenize.mu index b6ca1ffd..d28f59dc 100644 --- a/shell/tokenize.mu +++ b/shell/tokenize.mu @@ -50,7 +50,7 @@ fn next-token in: (addr gap-buffer), _out-cell: (addr cell), trace: (addr trace) } # digit { - var digit?/eax: boolean <- is-decimal-digit? g + var digit?/eax: boolean <- decimal-digit? g compare digit?, 0/false break-if-= next-number-token in, out, trace @@ -58,7 +58,7 @@ fn next-token in: (addr gap-buffer), _out-cell: (addr cell), trace: (addr trace) } # other symbol char { - var symbol?/eax: boolean <- is-symbol-grapheme? g + var symbol?/eax: boolean <- symbol-grapheme? g compare symbol?, 0/false break-if-= next-symbol-token in, out, trace @@ -66,7 +66,7 @@ fn next-token in: (addr gap-buffer), _out-cell: (addr cell), trace: (addr trace) } # brackets are always single-char tokens { - var bracket?/eax: boolean <- is-bracket-grapheme? g + var bracket?/eax: boolean <- bracket-grapheme? g compare bracket?, 0/false break-if-= var g/eax: grapheme <- read-from-gap-buffer in @@ -75,7 +75,7 @@ fn next-token in: (addr gap-buffer), _out-cell: (addr cell), trace: (addr trace) } # non-symbol operators { - var operator?/eax: boolean <- is-operator-grapheme? g + var operator?/eax: boolean <- operator-grapheme? g compare operator?, 0/false break-if-= next-operator-token in, out, trace @@ -109,7 +109,7 @@ fn next-symbol-token in: (addr gap-buffer), out: (addr stream byte), trace: (add } # if non-symbol, return { - var symbol-grapheme?/eax: boolean <- is-symbol-grapheme? g + var symbol-grapheme?/eax: boolean <- symbol-grapheme? g compare symbol-grapheme?, 0/false break-if-!= trace-text trace, "read", "stop" @@ -146,7 +146,7 @@ fn next-operator-token in: (addr gap-buffer), out: (addr stream byte), trace: (a } # if non-operator, return { - var operator-grapheme?/eax: boolean <- is-operator-grapheme? g + var operator-grapheme?/eax: boolean <- operator-grapheme? g compare operator-grapheme?, 0/false break-if-!= trace-text trace, "read", "stop" @@ -183,7 +183,7 @@ fn next-number-token in: (addr gap-buffer), out: (addr stream byte), trace: (add } # if not symbol grapheme, return { - var symbol-grapheme?/eax: boolean <- is-symbol-grapheme? g + var symbol-grapheme?/eax: boolean <- symbol-grapheme? g compare symbol-grapheme?, 0/false break-if-!= trace-text trace, "read", "stop" @@ -191,7 +191,7 @@ fn next-number-token in: (addr gap-buffer), out: (addr stream byte), trace: (add } # if not digit grapheme, abort { - var digit?/eax: boolean <- is-decimal-digit? g + var digit?/eax: boolean <- decimal-digit? g compare digit?, 0/false break-if-!= error trace, "invalid number" @@ -216,7 +216,7 @@ fn next-bracket-token g: grapheme, out: (addr stream byte), trace: (addr trace) trace trace, "read", stream } -fn is-symbol-grapheme? g: grapheme -> _/eax: boolean { +fn symbol-grapheme? g: grapheme -> _/eax: boolean { ## whitespace compare g, 9/tab { @@ -383,7 +383,7 @@ fn is-symbol-grapheme? g: grapheme -> _/eax: boolean { return 1/true } -fn is-bracket-grapheme? g: grapheme -> _/eax: boolean { +fn bracket-grapheme? g: grapheme -> _/eax: boolean { compare g, 0x28/open-paren { break-if-!= @@ -417,7 +417,7 @@ fn is-bracket-grapheme? g: grapheme -> _/eax: boolean { return 0/false } -fn is-operator-grapheme? g: grapheme -> _/eax: boolean { +fn operator-grapheme? g: grapheme -> _/eax: boolean { # '$' is a symbol char compare g, 0x25/percent { @@ -519,27 +519,27 @@ fn is-operator-grapheme? g: grapheme -> _/eax: boolean { return 0/false } -fn is-number-token? _in: (addr cell) -> _/eax: boolean { +fn number-token? _in: (addr cell) -> _/eax: boolean { var in/eax: (addr cell) <- copy _in var in-data-ah/eax: (addr handle stream byte) <- get in, text-data var in-data/eax: (addr stream byte) <- lookup *in-data-ah rewind-stream in-data var g/eax: grapheme <- read-grapheme in-data - var result/eax: boolean <- is-decimal-digit? g + var result/eax: boolean <- decimal-digit? g return result } -fn is-bracket-token? _in: (addr cell) -> _/eax: boolean { +fn bracket-token? _in: (addr cell) -> _/eax: boolean { var in/eax: (addr cell) <- copy _in var in-data-ah/eax: (addr handle stream byte) <- get in, text-data var in-data/eax: (addr stream byte) <- lookup *in-data-ah rewind-stream in-data var g/eax: grapheme <- read-grapheme in-data - var result/eax: boolean <- is-bracket-grapheme? g + var result/eax: boolean <- bracket-grapheme? g return result } -fn is-open-paren-token? _in: (addr cell) -> _/eax: boolean { +fn open-paren-token? _in: (addr cell) -> _/eax: boolean { var in/eax: (addr cell) <- copy _in var in-data-ah/eax: (addr handle stream byte) <- get in, text-data var in-data/eax: (addr stream byte) <- lookup *in-data-ah @@ -553,7 +553,7 @@ fn is-open-paren-token? _in: (addr cell) -> _/eax: boolean { return 0/false } -fn is-close-paren-token? _in: (addr cell) -> _/eax: boolean { +fn close-paren-token? _in: (addr cell) -> _/eax: boolean { var in/eax: (addr cell) <- copy _in var in-data-ah/eax: (addr handle stream byte) <- get in, text-data var in-data/eax: (addr stream byte) <- lookup *in-data-ah diff --git a/shell/trace.mu b/shell/trace.mu index 26393d2b..e3269088 100644 --- a/shell/trace.mu +++ b/shell/trace.mu @@ -70,8 +70,8 @@ fn has-errors? _self: (addr trace) -> _/eax: boolean { var curr/eax: (addr trace-line) <- index trace, offset var curr-label-ah/eax: (addr handle array byte) <- get curr, label var curr-label/eax: (addr array byte) <- lookup *curr-label-ah - var is-error?/eax: boolean <- string-equal? curr-label, "error" - compare is-error?, 0/false + var error?/eax: boolean <- string-equal? curr-label, "error" + compare error?, 0/false { break-if-= return 1/true @@ -340,9 +340,9 @@ fn render-trace screen: (addr screen), _self: (addr trace), xmin: int, ymin: int copy-to *cursor-line-index, i } # always display errors - var is-error?/eax: boolean <- string-equal? curr-label, "error" + var error?/eax: boolean <- string-equal? curr-label, "error" { - compare is-error?, 0/false + compare error?, 0/false break-if-= y <- render-trace-line screen, curr, xmin, y, xmax, ymax, 0xc/fg=trace-error, bg copy-to already-hiding-lines?, 0/false @@ -383,8 +383,8 @@ fn render-trace-line screen: (addr screen), _self: (addr trace-line), xmin: int, var label-ah/eax: (addr handle array byte) <- get self, label var _label/eax: (addr array byte) <- lookup *label-ah var label/ebx: (addr array byte) <- copy _label - var is-error?/eax: boolean <- string-equal? label, "error" - compare is-error?, 0/false + var error?/eax: boolean <- string-equal? label, "error" + compare error?, 0/false { break-if-!= var x/eax: int <- copy xsave |