diff options
Diffstat (limited to 'apps/dquotes.subx')
-rw-r--r-- | apps/dquotes.subx | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/apps/dquotes.subx b/apps/dquotes.subx index 5186eda6..4b985fbb 100644 --- a/apps/dquotes.subx +++ b/apps/dquotes.subx @@ -46,8 +46,8 @@ Entry: # run tests if necessary, convert stdin if not e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . if (eax == 0) goto interactive - 3d/compare-eax-and 0/imm32 + # . if (eax == false) goto interactive + 3d/compare-eax-and 0/imm32/false 74/jump-if-equal $subx-dquotes-main:interactive/disp8 # run-tests() e8/call run-tests/disp32 @@ -56,7 +56,7 @@ Entry: # run tests if necessary, convert stdin if not eb/jump $subx-dquotes-main:end/disp8 $subx-dquotes-main:interactive: # - otherwise convert stdin - # var ed/eax : exit-descriptor + # var ed/eax : (ref exit-descriptor) 81 5/subop/subtract 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # subtract from esp 89/copy 3/mod/direct 0/rm32/eax . . . 4/r32/esp . . # copy esp to eax # configure ed to really exit() @@ -84,7 +84,7 @@ $subx-dquotes-main:end: subx-dquotes: # in : (address buffered-file), out : (address buffered-file) # pseudocode: - # var line : (stream byte 512) + # var line : (ref stream byte 512) # var new-data-segment : (handle stream byte) = new-stream(Heap, Segment-size, 1) # # write(new-data-segment, "== data\n") @@ -125,13 +125,13 @@ subx-dquotes: # in : (address buffered-file), out : (address buffered-file) 53/push-ebx 56/push-esi 57/push-edi - # var line/ecx : (address stream byte) = stream(512) + # var line/ecx : (ref stream byte 512) 81 5/subop/subtract 3/mod/direct 4/rm32/esp . . . . . 0x200/imm32 # subtract from esp 68/push 0x200/imm32/length 68/push 0/imm32/read 68/push 0/imm32/write 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # var word-slice/edx = {0, 0} + # var word-slice/edx : (ref slice) 68/push 0/imm32/end 68/push 0/imm32/start 89/copy 3/mod/direct 2/rm32/edx . . . 4/r32/esp . . # copy esp to edx @@ -193,17 +193,17 @@ $subx-dquotes:check1: e8/call slice-empty?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp - # . if (eax != 0) break - 3d/compare-eax-and 0/imm32 + # . if (eax != false) break + 3d/compare-eax-and 0/imm32/false 0f 85/jump-if-not-equal $subx-dquotes:next-line/disp32 $subx-dquotes:check-for-comment: # if (slice-starts-with?(word-slice, "#")) continue - # . start/esi = word-slice->start + # . var start/esi : (address byte) = word-slice->start 8b/copy 0/mod/indirect 2/rm32/edx . . . 6/r32/esi . . # copy *edx to esi - # . c/eax = *start + # . var c/eax : byte = *start 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . . # clear eax 8a/copy-byte 0/mod/indirect 6/rm32/esi . . . 0/r32/AL . . # copy byte at *esi to AL - # . if (eax == '#') continue + # . if (c == '#') continue 3d/compare-eax-and 0x23/imm32/hash 74/jump-if-equal $subx-dquotes:word-loop/disp8 $subx-dquotes:check-for-string-literal: @@ -287,7 +287,7 @@ $subx-dquotes:end: # Write out 'string-literal' in a new format to 'out-segment', assign it a new # label, and write the new label out to 'out'. -process-string-literal: # string-literal : (address slice), out : (address buffered-file), out-segment : (address stream) +process-string-literal: # string-literal : (address slice), out : (address buffered-file), out-segment : (address stream byte) # pseudocode: # print(out-segment, "_string#{Next-string-literal}:\n") # emit-string-literal-data(out-segment, string-literal) @@ -300,7 +300,7 @@ process-string-literal: # string-literal : (address slice), out : (address buff 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp # . save registers 51/push-ecx - # var int32-stream/ecx = stream(10) # number of decimal digits a 32-bit number can have + # var int32-stream/ecx : (ref stream byte 10) # number of decimal digits a 32-bit number can have 81 5/subop/subtract 3/mod/direct 4/rm32/esp . . . . . 0xa/imm32 # subtract from esp 68/push 0xa/imm32/decimal-digits-in-32bit-number 68/push 0/imm32/read @@ -846,7 +846,7 @@ test-subx-dquotes-processes-string-literals: c3/return # generate the data segment contents byte by byte for a given slice -emit-string-literal-data: # out : (address stream), word : (address slice) +emit-string-literal-data: # out : (address stream byte), word : (address slice) # pseudocode # len = string-length-at-start-of-slice(word->start, word->end) # print(out, "#{len}/imm32 ") @@ -885,14 +885,14 @@ emit-string-literal-data: # out : (address stream), word : (address slice) 56/push-esi # esi = word 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0xc/disp8 . # copy *(ebp+12) to esi - # idx/ebx = 0 + # var idx/ebx : int = 0 31/xor 3/mod/direct 3/rm32/ebx . . . 3/r32/ebx . . # clear ebx - # curr/edx = word->start + # var curr/edx : (address byte) = word->start 8b/copy 0/mod/indirect 6/rm32/esi . . . 2/r32/edx . . # copy *esi to edx - # max/esi = word->end + # var max/esi : (address byte) = word->end 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 6/r32/esi 4/disp8 . # copy *(esi+4) to esi $emit-string-literal-data:emit-length: - # len/eax = string-length-at-start-of-slice(word->start, word->end) + # var len/eax : int = string-length-at-start-of-slice(word->start, word->end) # . . push args 56/push-esi 52/push-edx @@ -920,7 +920,7 @@ $emit-string-literal-data:emit-length: $emit-string-literal-data:loop-init: # ++curr # skip initial '"' 42/increment-edx - # c/ecx = 0 + # var c/ecx : byte = 0 31/xor 3/mod/direct 1/rm32/ecx . . . 1/r32/ecx . . # clear ecx $emit-string-literal-data:loop: # if (curr >= max) break @@ -955,15 +955,15 @@ $emit-string-literal-data:emit: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp # if (is-alphanumeric?(*curr)) print(out, "/#{*curr}") - # . eax = is-alphanumeric?(CL) + # . var eax : boolean = is-alphanumeric?(CL) # . . push args 51/push-ecx # . . call e8/call is-alphanumeric?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp - # . if (eax == 0) goto char-done - 3d/compare-eax-and 0/imm32 + # . if (eax == false) goto char-done + 3d/compare-eax-and 0/imm32/false 74/jump-if-equal $emit-string-literal-data:char-done/disp8 # . write(out, "/") # . . push args @@ -1027,22 +1027,22 @@ is-alphanumeric?: # c : int -> eax : boolean 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp # eax = c 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 8/disp8 . # copy *(ebp+8) to eax - # if (eax < '0') return false + # if (c < '0') return false 3d/compare-eax-with 0x30/imm32/0 7c/jump-if-lesser $is-alphanumeric?:false/disp8 - # if (eax <= '9') return true + # if (c <= '9') return true 3d/compare-eax-with 0x39/imm32/9 7e/jump-if-lesser-or-equal $is-alphanumeric?:true/disp8 - # if (eax < 'A') return false + # if (c < 'A') return false 3d/compare-eax-with 0x41/imm32/A 7c/jump-if-lesser $is-alphanumeric?:false/disp8 - # if (eax <= 'Z') return true + # if (c <= 'Z') return true 3d/compare-eax-with 0x5a/imm32/Z 7e/jump-if-lesser-or-equal $is-alphanumeric?:true/disp8 - # if (eax < 'a') return false + # if (c < 'a') return false 3d/compare-eax-with 0x61/imm32/a 7c/jump-if-lesser $is-alphanumeric?:false/disp8 - # if (eax <= 'z') return true + # if (c <= 'z') return true 3d/compare-eax-with 0x7a/imm32/z 7e/jump-if-lesser-or-equal $is-alphanumeric?:true/disp8 # return false @@ -1381,7 +1381,7 @@ test-emit-string-literal-data-handles-newline-escape: # emit everything from a word except the initial datum emit-metadata: # out : (address buffered-file), word : (address slice) # pseudocode - # var slice = {0, word->end} + # var slice : (ref slice) = {0, word->end} # curr = word->start # if *curr == '"' # curr = skip-string-in-slice(curr, word->end) @@ -1406,11 +1406,11 @@ emit-metadata: # out : (address buffered-file), word : (address slice) 56/push-esi # esi = word 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0xc/disp8 . # copy *(ebp+12) to esi - # curr/ecx = word->start + # var curr/ecx : (address byte) = word->start 8b/copy 0/mod/indirect 6/rm32/esi . . . 1/r32/ecx . . # copy *esi to ecx - # end/edx = word->end + # var end/edx : (address byte) = word->end 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 2/r32/edx 4/disp8 . # copy *(esi+4) to edx - # var slice/ebx = {0, end} + # var slice/ebx : (ref slice) = {0, end} 52/push-edx 68/push 0/imm32 89/copy 3/mod/direct 3/rm32/ebx . . . 4/r32/esp . . # copy esp to ebx @@ -1790,9 +1790,9 @@ string-length-at-start-of-slice: # curr : (address byte), end : (address byte) 8b/copy 1/mod/*+disp8 5/rm32/ebp . . 1/r32/ecx 8/disp8 . # copy *(ebp+8) to ecx # edx = end 8b/copy 1/mod/*+disp8 5/rm32/ebp . . 2/r32/edx 0xc/disp8 . # copy *(ebp+12) to edx - # length/eax = 0 + # var length/eax : int = 0 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . . # clear eax - # ebx = 0 + # var c/ebx : byte = 0 31/xor 3/mod/direct 3/rm32/ebx . . . 3/r32/ebx . . # clear ebx # skip initial dquote 41/increment-ecx @@ -1800,14 +1800,14 @@ $string-length-at-start-of-slice:loop: # if (curr >= end) return length 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx 73/jump-if-greater-unsigned-or-equal $string-length-at-start-of-slice:end/disp8 - # BL = *curr + # c = *curr 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 3/r32/BL . . # copy byte at *ecx to BL $string-length-at-start-of-slice:dquote: - # if (ebx == '"') break + # if (c == '"') break 81 7/subop/compare 3/mod/direct 3/rm32/ebx . . . . . 0x22/imm32/dquote # compare ebx 74/jump-if-equal $string-length-at-start-of-slice:end/disp8 $string-length-at-start-of-slice:check-for-escape: - # if (ebx == '\') escape next char + # if (c == '\') escape next char 81 7/subop/compare 3/mod/direct 3/rm32/ebx . . . . . 0x5c/imm32/backslash # compare ebx 75/jump-if-not-equal $string-length-at-start-of-slice:continue/disp8 $string-length-at-start-of-slice:escape: |