From df13e24a8a603957ce84b7b5d4dd3c33914580c7 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 17 Apr 2019 10:33:51 -0700 Subject: 5106 --- subx/apps/assort.subx | 3 +- subx/apps/dquotes | Bin 18832 -> 19092 bytes subx/apps/dquotes.subx | 146 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 147 insertions(+), 2 deletions(-) (limited to 'subx/apps') diff --git a/subx/apps/assort.subx b/subx/apps/assort.subx index 050f064d..733e486d 100644 --- a/subx/apps/assort.subx +++ b/subx/apps/assort.subx @@ -538,7 +538,7 @@ $read-segments:check1: 3d/compare-EAX-and 0/imm32 0f 85/jump-if-not-equal $read-segments:loop/disp32 $read-segments:check-for-comment: - # if slice-starts-with?(word-slice, "#") + # if (slice-starts-with?(word-slice, "#")) continue # . start/ESI = word-slice->start 8b/copy 0/mod/indirect 2/rm32/EDX . . . 6/r32/ESI . . # copy *ECX to ESI # . c/EAX = *start @@ -1312,6 +1312,7 @@ _test-data-segment: _test-data-segment-end: Segment-size: + # TODO: there's currently a tight size limit on segments because we aren't growing the heap 0x100/imm32/4KB #? 0x1000/imm32/4KB diff --git a/subx/apps/dquotes b/subx/apps/dquotes index ff32e600..92f102a6 100644 Binary files a/subx/apps/dquotes and b/subx/apps/dquotes differ diff --git a/subx/apps/dquotes.subx b/subx/apps/dquotes.subx index 5aea5cab..a0948541 100644 --- a/subx/apps/dquotes.subx +++ b/subx/apps/dquotes.subx @@ -91,7 +91,7 @@ convert: # in : (address buffered-file), out : (address buffered-file) -> write == 0) break + 81 7/subop/compare 0/mod/indirect 1/rm32/ECX . . . . . 0/imm32 # compare *ECX + 0f 84/jump-if-equal $convert:break/disp32 +$convert:word-loop: + # next-word(line, word-slice) + # . . push args + 52/push-EDX + 51/push-ECX + # . . call + e8/call next-word/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +$convert:check1: + # if (slice-empty?(word-slice)) break + # . EAX = slice-empty?(word-slice) + # . . push args + 52/push-EDX + # . . call + 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 + 0f 85/jump-if-not-equal $convert:line-loop/disp32 +$convert:check-for-comment: + # if (slice-starts-with?(word-slice, "#")) continue + # . start/ESI = word-slice->start + 8b/copy 0/mod/indirect 2/rm32/EDX . . . 6/r32/ESI . . # copy *EDX to ESI + # . c/EAX = *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 + 3d/compare-EAX-and 0x23/imm32/hash + 0f 84/jump-if-equal $convert:word-loop/disp32 +$convert:check-for-string-literal: + 3d/compare-EAX-and 0x22/imm32/hash + 0f 85/jump-if-not-equal $convert:regular-word/disp32 +$convert:string-literal: + # process-string-literal(word-slice, out, new-data-segment) + # . . push args + 57/push-EDI + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) + 52/push-EDX + # . . call + e8/call process-string-literal/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + # loop + eb/jump $convert:word-loop/disp8 +$convert:regular-word: + # write-slice(out, word-slice) + # . . push args + 52/push-EDX + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) + # . . call + e8/call write-slice/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # loop + eb/jump $convert:word-loop/disp8 +$convert:break: $convert:end: + # . reclaim locals + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x214/imm32 # add to ESP + # . restore registers + 5f/pop-to-EDI + 5e/pop-to-ESI + 5b/pop-to-EBX + 5a/pop-to-EDX + 59/pop-to-ECX + 58/pop-to-EAX + # . epilog + 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 5d/pop-to-EBP + c3/return + +process-string-literal: # word : (address slice), out : (address buffered-file), string-literal-segment : (address stream) + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # . save registers +$process-string-literal:end: + # . reclaim locals + # . restore registers # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP @@ -575,4 +712,11 @@ test-next-word-returns-string-with-escapes: 5d/pop-to-EBP c3/return +== data + +Segment-size: + # TODO: there's currently a tight size limit on segments because we aren't growing the heap + 0x100/imm32/4KB +#? 0x1000/imm32/4KB + # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0