From 0b91d25cf591888252d5e99e7986e2544de31695 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 13 Apr 2019 22:30:25 -0700 Subject: 5090 Start using the new newline escape in string literals everywhere. I could use it more aggressively, but it makes tests harder to read. So only one line of text per string for now. --- subx/058stream-equal.subx | 84 +----- subx/071read-line.subx | 29 +-- subx/072slice.subx | 12 +- subx/apps/assort | Bin 21190 -> 20650 bytes subx/apps/assort.subx | 216 +++------------ subx/apps/crenshaw2-1 | Bin 18156 -> 17837 bytes subx/apps/crenshaw2-1.subx | 34 +-- subx/apps/crenshaw2-1b | Bin 18715 -> 18396 bytes subx/apps/crenshaw2-1b.subx | 36 +-- subx/apps/factorial | Bin 17018 -> 16753 bytes subx/apps/handle | Bin 17792 -> 17527 bytes subx/apps/hex | Bin 21191 -> 20846 bytes subx/apps/hex.subx | 40 +-- subx/apps/pack | Bin 35607 -> 35182 bytes subx/apps/pack.subx | 622 ++++++++------------------------------------ 15 files changed, 162 insertions(+), 911 deletions(-) (limited to 'subx') diff --git a/subx/058stream-equal.subx b/subx/058stream-equal.subx index 518607e7..18bdbf98 100644 --- a/subx/058stream-equal.subx +++ b/subx/058stream-equal.subx @@ -345,25 +345,8 @@ test-next-stream-line-equal-stops-at-newline: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # write(_test-stream, "Abc\ndef") - # . write(_test-stream, "Abc") # . . push args - 68/push "Abc"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, Newline) - # . . push args - 68/push Newline/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, "def") - # . . push args - 68/push "def"/imm32 + 68/push "Abc\ndef"/imm32 68/push _test-stream/imm32 # . . call e8/call write/disp32 @@ -403,25 +386,8 @@ test-next-stream-line-equal-stops-at-newline-2: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # write(_test-stream, "Abc\ndef") - # . write(_test-stream, "Abc") # . . push args - 68/push "Abc"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, Newline) - # . . push args - 68/push Newline/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, "def") - # . . push args - 68/push "def"/imm32 + 68/push "Abc\ndef"/imm32 68/push _test-stream/imm32 # . . call e8/call write/disp32 @@ -461,33 +427,8 @@ test-next-stream-line-equal-skips-newline: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # write(_test-stream, "Abc\ndef\n") - # . write(_test-stream, "Abc") - # . . push args - 68/push "Abc"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, Newline) - # . . push args - 68/push Newline/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, "def") # . . push args - 68/push "def"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, Newline) - # . . push args - 68/push Newline/imm32 + 68/push "Abc\ndef\n"/imm32 68/push _test-stream/imm32 # . . call e8/call write/disp32 @@ -535,25 +476,8 @@ test-next-stream-line-equal-handles-final-line: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # write(_test-stream, "Abc\ndef") - # . write(_test-stream, "Abc") - # . . push args - 68/push "Abc"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, Newline) # . . push args - 68/push Newline/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, "def") - # . . push args - 68/push "def"/imm32 + 68/push "Abc\ndef"/imm32 68/push _test-stream/imm32 # . . call e8/call write/disp32 diff --git a/subx/071read-line.subx b/subx/071read-line.subx index 6c53ba33..39c5f576 100644 --- a/subx/071read-line.subx +++ b/subx/071read-line.subx @@ -103,15 +103,7 @@ $read-line:end: $read-line:abort: # . _write(2/stderr, error) # . . push args - 68/push "read-line: line too long"/imm32 - 68/push 2/imm32/stderr - # . . call - e8/call _write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . _write(2/stderr, Newline) - # . . push args - 68/push Newline/imm32 + 68/push "read-line: line too long\n"/imm32 68/push 2/imm32/stderr # . . call e8/call _write/disp32 @@ -150,25 +142,8 @@ test-read-line: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # write(_test-stream, "ab\ncd") - # . write(_test-stream, "ab") - # . . push args - 68/push "ab"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, "\n") - # . . push args - 68/push Newline/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, "cd") # . . push args - 68/push "cd"/imm32 + 68/push "ab\ncd"/imm32 68/push _test-stream/imm32 # . . call e8/call write/disp32 diff --git a/subx/072slice.subx b/subx/072slice.subx index a795e608..9c285097 100644 --- a/subx/072slice.subx +++ b/subx/072slice.subx @@ -946,17 +946,9 @@ test-slice-to-string: #? e8/call write/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 diff --git a/subx/apps/assort b/subx/apps/assort index 2927a258..03d052ae 100755 Binary files a/subx/apps/assort and b/subx/apps/assort differ diff --git a/subx/apps/assort.subx b/subx/apps/assort.subx index b1ba63d3..bf08a41c 100644 --- a/subx/apps/assort.subx +++ b/subx/apps/assort.subx @@ -183,81 +183,41 @@ test-convert: # 8 9 (multiple lines) # == code (existing segment contiguous with previous iteration) # 10 11 - # . write(_test-input-stream, "# comment 1") + # . write(_test-input-stream, "# comment 1\n") # . . push args - 68/push "# comment 1"/imm32 + 68/push "# comment 1\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, " # comment 2 indented\n") # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, " # comment 2 indented") - # . . push args - 68/push " # comment 2 indented"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "== code") - # . . push args - 68/push "== code"/imm32 + 68/push " # comment 2 indented\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "== code\n") # . . push args - 68/push Newline/imm32 + 68/push "== code\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "# comment 3 inside a segment") + # . write(_test-input-stream, "# comment 3 inside a segment\n") # . . push args - 68/push "# comment 3 inside a segment"/imm32 + 68/push "# comment 3 inside a segment\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "1\n") # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "1") - # . . push args - 68/push "1"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 + 68/push "1\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 @@ -265,135 +225,71 @@ test-convert: 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # . write(_test-input-stream, "\n") # empty line # . . push args - 68/push Newline/imm32 + 68/push "\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "2 3 # comment 4 inline with other contents") + # . write(_test-input-stream, "2 3 # comment 4 inline with other contents\n") # . . push args - 68/push "2 3 # comment 4 inline with other contents"/imm32 + 68/push "2 3 # comment 4 inline with other contents\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "== data\n") # . . push args - 68/push Newline/imm32 + 68/push "== data\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "== data") + # . write(_test-input-stream, "4 5/imm32\n") # . . push args - 68/push "== data"/imm32 + 68/push "4 5/imm32\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "== code\n") # . . push args - 68/push Newline/imm32 + 68/push "== code\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "4 5/imm32") + # . write(_test-input-stream, "6 7\n") # . . push args - 68/push "4 5/imm32"/imm32 + 68/push "6 7\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "8 9\n") # . . push args - 68/push Newline/imm32 + 68/push "8 9\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "== code") + # . write(_test-input-stream, "== code\n") # . . push args - 68/push "== code"/imm32 + 68/push "== code\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "10 11\n") # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "6 7") - # . . push args - 68/push "6 7"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "8 9") - # . . push args - 68/push "8 9"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "== code") - # . . push args - 68/push "== code"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "10 11") - # . . push args - 68/push "10 11"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 + 68/push "10 11\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 @@ -433,17 +329,9 @@ test-convert: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -620,17 +508,9 @@ $read-segments:check0: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -701,17 +581,9 @@ $read-segments:check-for-segment-header: #? e8/call flush/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # . write(2/stderr, "$") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -773,17 +645,9 @@ $read-segments:check-for-segment-header: #? e8/call flush/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -1071,15 +935,7 @@ $test-get-or-insert-segment:first-call: # fail test # . _write(2/stderr, msg) # . . push args - 68/push "F - test-get-or-insert-segment/0"/imm32 - 68/push 2/imm32/stderr - # . . call - e8/call _write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . _write(2/stderr, Newline) - # . . push args - 68/push Newline/imm32 + 68/push "F - test-get-or-insert-segment/0\n"/imm32 68/push 2/imm32/stderr # . . call e8/call _write/disp32 diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1 index c30a1910..4299a8dd 100755 Binary files a/subx/apps/crenshaw2-1 and b/subx/apps/crenshaw2-1 differ diff --git a/subx/apps/crenshaw2-1.subx b/subx/apps/crenshaw2-1.subx index 68c5f146..20560288 100644 --- a/subx/apps/crenshaw2-1.subx +++ b/subx/apps/crenshaw2-1.subx @@ -154,33 +154,17 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(out, "b8/copy-to-EAX 1/imm32/exit") + # . write(out, "b8/copy-to-EAX 1/imm32/exit\n") # . . push args - 68/push "b8/copy-to-EAX 1/imm32/exit"/imm32 + 68/push "b8/copy-to-EAX 1/imm32/exit\n"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(out, Newline) - # . . push args - 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(out, "cd/syscall 0x80/imm8") + # . write(out, "cd/syscall 0x80/imm8\n") # . . push args - 68/push "cd/syscall 0x80/imm8"/imm32 - ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(out, Newline) - # . . push args - 68/push Newline/imm32 + 68/push "cd/syscall 0x80/imm8\n"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 @@ -502,15 +486,7 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # write(f, " expected") # . . push args - 68/push " expected"/imm32 - ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # write(f, Newline) - # . . push args - 68/push Newline/imm32 + 68/push " expected\n"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 diff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b index 79979b26..e2ab939d 100755 Binary files a/subx/apps/crenshaw2-1b and b/subx/apps/crenshaw2-1b differ diff --git a/subx/apps/crenshaw2-1b.subx b/subx/apps/crenshaw2-1b.subx index 969d12f0..2c396fb3 100644 --- a/subx/apps/crenshaw2-1b.subx +++ b/subx/apps/crenshaw2-1b.subx @@ -154,33 +154,17 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(out, "b8/copy-to-EAX 1/imm32/exit") + # . write(out, "b8/copy-to-EAX 1/imm32/exit\n") # . . push args - 68/push "b8/copy-to-EAX 1/imm32/exit"/imm32 + 68/push "b8/copy-to-EAX 1/imm32/exit\n"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(out, Newline) - # . . push args - 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(out, "cd/syscall 0x80/imm8") + # . write(out, "cd/syscall 0x80/imm8\n") # . . push args - 68/push "cd/syscall 0x80/imm8"/imm32 - ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(out, Newline) - # . . push args - 68/push Newline/imm32 + 68/push "cd/syscall 0x80/imm8\n"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 @@ -699,17 +683,9 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # write(f, " expected") + # write(f, " expected\n") # . . push args - 68/push " expected"/imm32 - ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # write(f, Newline) - # . . push args - 68/push Newline/imm32 + 68/push " expected\n"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 diff --git a/subx/apps/factorial b/subx/apps/factorial index 6ce4fc6b..c7498b32 100755 Binary files a/subx/apps/factorial and b/subx/apps/factorial differ diff --git a/subx/apps/handle b/subx/apps/handle index 3de933dd..192ac6d9 100755 Binary files a/subx/apps/handle and b/subx/apps/handle differ diff --git a/subx/apps/hex b/subx/apps/hex index 331997cf..e53aed27 100755 Binary files a/subx/apps/hex and b/subx/apps/hex differ diff --git a/subx/apps/hex.subx b/subx/apps/hex.subx index 536bb65d..c0627c77 100644 --- a/subx/apps/hex.subx +++ b/subx/apps/hex.subx @@ -810,15 +810,7 @@ test-scan-next-byte-skips-comment: # initialize '_test-stream' to input with leading comment # . write(_test-stream, comment) # . . push args - 68/push "#x"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, Newline) - # . . push args - 68/push Newline/imm32 + 68/push "#x\n"/imm32 68/push _test-stream/imm32 # . . call e8/call write/disp32 @@ -928,15 +920,7 @@ test-scan-next-byte-skips-comment-and-whitespace: # initialize '_test-stream' to input with leading comment and more whitespace after newline # . write(_test-stream, comment) # . . push args - 68/push "#x"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, Newline) - # . . push args - 68/push Newline/imm32 + 68/push "#x\n"/imm32 68/push _test-stream/imm32 # . . call e8/call write/disp32 @@ -1046,15 +1030,7 @@ test-scan-next-byte-skips-whitespace-and-comment: # initialize '_test-stream' to input with leading whitespace and comment # . write(_test-stream, comment) # . . push args - 68/push " #x"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, Newline) - # . . push args - 68/push Newline/imm32 + 68/push " #x\n"/imm32 68/push _test-stream/imm32 # . . call e8/call write/disp32 @@ -1466,15 +1442,7 @@ test-skip-until-newline: # initialize '_test-stream' to "abc\nde" # . write(_test-stream, "abc") # . . push args - 68/push "abc"/imm32 - 68/push _test-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-stream, Newline) - # . . push args - 68/push Newline/imm32 + 68/push "abc\n"/imm32 68/push _test-stream/imm32 # . . call e8/call write/disp32 diff --git a/subx/apps/pack b/subx/apps/pack index 06d5e32b..95f93d05 100755 Binary files a/subx/apps/pack and b/subx/apps/pack differ diff --git a/subx/apps/pack.subx b/subx/apps/pack.subx index 6ce49ae1..18bd43cf 100644 --- a/subx/apps/pack.subx +++ b/subx/apps/pack.subx @@ -170,17 +170,9 @@ $convert:check0: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -241,17 +233,9 @@ $convert:check2: #? e8/call flush/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # . write(2/stderr, "$") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -314,17 +298,9 @@ $convert:check2: #? e8/call flush/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -676,47 +652,23 @@ test-convert-in-data-segment: # 3 4/imm32 # . write(_test-input-stream, "== code") # . . push args - 68/push "== code"/imm32 + 68/push "== code\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "== data\n") # . . push args - 68/push Newline/imm32 + 68/push "== data\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "== data") + # . write(_test-input-stream, "3 4/imm32\n") # . . push args - 68/push "== data"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "3 4/imm32") - # . . push args - 68/push "3 4/imm32"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 + 68/push "3 4/imm32\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 @@ -748,17 +700,9 @@ test-convert-in-data-segment: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -848,81 +792,41 @@ test-convert-code-and-data-segments: # 68/push 0x20/imm8 # == data # 3 4/imm32 - # . write(_test-input-stream, "== code") - # . . push args - 68/push "== code"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "e8/call 20/disp32") - # . . push args - 68/push "e8/call 20/disp32"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") - # . . push args - 68/push Newline/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "68/push 0x20/imm8") - # . . push args - 68/push "68/push 0x20/imm8"/imm32 - 68/push _test-input-stream/imm32 - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "== code\n") # . . push args - 68/push Newline/imm32 + 68/push "== code\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "== data") + # . write(_test-input-stream, "e8/call 20/disp32\n") # . . push args - 68/push "== data"/imm32 + 68/push "e8/call 20/disp32\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "68/push 0x20/imm8\n") # . . push args - 68/push Newline/imm32 + 68/push "68/push 0x20/imm8\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "3 4/imm32") + # . write(_test-input-stream, "== data\n") # . . push args - 68/push "3 4/imm32"/imm32 + 68/push "== data\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "\n") + # . write(_test-input-stream, "3 4/imm32\n") # . . push args - 68/push Newline/imm32 + 68/push "3 4/imm32\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 @@ -959,17 +863,9 @@ test-convert-code-and-data-segments: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -1080,17 +976,9 @@ convert-data: # line : (address stream byte), out : (address buffered-file) -> #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -1139,17 +1027,9 @@ $convert-data:loop: #? e8/call flush/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -1329,17 +1209,9 @@ test-convert-data-passes-comments-through: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -1841,17 +1713,9 @@ test-convert-data-multiple-words: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -1943,17 +1807,9 @@ test-convert-data-trailing-comment: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -2497,17 +2353,9 @@ $emit-modrm:loop: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -2555,17 +2403,9 @@ $emit-modrm:loop: #? e8/call flush/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -2824,17 +2664,9 @@ $emit-sib:loop: #? e8/call write-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -2882,17 +2714,9 @@ $emit-sib:loop: #? e8/call flush/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # . write(2/stderr, "$") -#? # . . push args -#? 68/push "$"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "\n") +#? # . write(2/stderr, "$\n") #? # . . push args -#? 68/push Newline/imm32 +#? 68/push "$\n"/imm32 #? 68/push 2/imm32/stderr #? # . . call #? e8/call write/disp32 @@ -3104,17 +2928,9 @@ emit-disp: # line : (address stream byte), out : (address buffered-file) ->