diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-12-29 13:36:06 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-12-29 13:36:06 -0800 |
commit | dd9ba09a7c74455f17afb515c377a217fa8be8bc (patch) | |
tree | bdeba01efd5c56d3ccf4df10750bd99087d1bb24 /subx/apps | |
parent | d762282438f603d47804be04cebf77d6137c2728 (diff) | |
download | mu-dd9ba09a7c74455f17afb515c377a217fa8be8bc.tar.gz |
4888
We only can't use rm32=5 when mod=0. Totally fine when it's mod=1.
Diffstat (limited to 'subx/apps')
-rwxr-xr-x | subx/apps/crenshaw2-1 | bin | 8333 -> 8241 bytes | |||
-rw-r--r-- | subx/apps/crenshaw2-1.subx | 56 | ||||
-rwxr-xr-x | subx/apps/crenshaw2-1b | bin | 8892 -> 8800 bytes | |||
-rw-r--r-- | subx/apps/crenshaw2-1b.subx | 56 | ||||
-rwxr-xr-x | subx/apps/factorial | bin | 7228 -> 7159 bytes | |||
-rw-r--r-- | subx/apps/factorial.subx | 10 | ||||
-rwxr-xr-x | subx/apps/hex | bin | 11840 -> 11755 bytes | |||
-rw-r--r-- | subx/apps/hex.subx | 42 |
8 files changed, 82 insertions, 82 deletions
diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1 index 1f3b5436..5a28117c 100755 --- a/subx/apps/crenshaw2-1 +++ b/subx/apps/crenshaw2-1 Binary files differdiff --git a/subx/apps/crenshaw2-1.subx b/subx/apps/crenshaw2-1.subx index e0ab0f47..25dbe8a8 100644 --- a/subx/apps/crenshaw2-1.subx +++ b/subx/apps/crenshaw2-1.subx @@ -39,12 +39,12 @@ 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # - if argc > 1 and argv[1] == "test" then return run_tests() # . argc > 1 - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0/disp8 1/imm32 # compare *EBP + 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 0/disp8 1/imm32 # compare *EBP 7e/jump-if-lesser-or-equal $run-main/disp8 # . argv[1] == "test" # . . push args 68/push "test"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call kernel-string-equal/disp32 # . . discard args @@ -91,7 +91,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # prime the pump # . Look = get-char(in) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call get-char/disp32 # . . discard args @@ -116,10 +116,10 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # read a digit from 'in' into 'num' # . get-num(in, num, err, ed) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x14/disp8 . # push *(EBP+20) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 . # push *(EBP+20) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) 51/push-ECX/num - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call get-num/disp32 # . . discard args @@ -132,7 +132,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, "bb/copy-to-EBX ") # . . push args 68/push "bb/copy-to-EBX "/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -140,7 +140,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write-stream(out, num) # . . push args 51/push-ECX/num - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write-stream/disp32 # . . discard args @@ -148,7 +148,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, Newline) # . . push args 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -156,7 +156,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, "b8/copy-to-EAX 1/imm32/exit") # . . push args 68/push "b8/copy-to-EAX 1/imm32/exit"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -164,7 +164,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, Newline) # . . push args 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -172,7 +172,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, "cd/syscall 0x80/imm8") # . . push args 68/push "cd/syscall 0x80/imm8"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -180,7 +180,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, Newline) # . . push args 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -235,8 +235,8 @@ get-num: # in : (address buffered-file), out : (address stream), err : fd or (a # . expected(ed, err, "integer") # . . push args 68/push "integer"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x14/disp8 . # push *(EBP+20) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 . # push *(EBP+20) # . . call e8/call expected/disp32 # never returns # . . discard args @@ -252,9 +252,9 @@ $get-num:main: 57/push-EDI # read necessary variables to registers # ESI = in - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI # EDI = out - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 7/r32/EDI 0xc/disp8 . # copy *(EBP+12) to EDI + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 0xc/disp8 . # copy *(EBP+12) to EDI # ECX = out->write 8b/copy 0/mod/indirect 7/rm32/EDI . . . 1/r32/ECX . . # copy *EDI to ECX # EDX = out->length @@ -265,8 +265,8 @@ $get-num:main: # . error(ed, err, msg) # TODO: show full number # . . push args 68/push "get-num: too many digits in number"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x14/disp8 . # push *(EBP+20) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 . # push *(EBP+20) # . . call e8/call error/disp32 # never returns # . . discard args @@ -487,15 +487,15 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad # write(f, "Error: ") # . . push args 68/push "Error: "/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + 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, s) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -503,7 +503,7 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad # write(f, " expected") # . . push args 68/push " expected"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -511,7 +511,7 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad # write(f, Newline) # . . push args 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -519,7 +519,7 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad # stop(ed, 1) # . . push args 68/push 1/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call stop/disp32 # should never get past this point @@ -538,7 +538,7 @@ get-char: # f : (address buffered-file) -> <void> 50/push-EAX # read-byte(f) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call read-byte/disp32 # . . discard args @@ -560,10 +560,10 @@ is-digit?: # c : int -> bool/EAX # EAX = false b8/copy-to-EAX 0/imm32 # if c < '0' return false - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 0x30/imm32 # compare *(EBP+8) + 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 0x30/imm32 # compare *(EBP+8) 7c/jump-if-lesser $is-digit?:end/disp8 # if c > '9' return false - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 0x39/imm32 # compare *(EBP+8) + 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 0x39/imm32 # compare *(EBP+8) 7f/jump-if-greater $is-digit?:end/disp8 # otherwise return true b8/copy-to-EAX 1/imm32 diff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b index 08395a6b..46a26183 100755 --- a/subx/apps/crenshaw2-1b +++ b/subx/apps/crenshaw2-1b Binary files differdiff --git a/subx/apps/crenshaw2-1b.subx b/subx/apps/crenshaw2-1b.subx index 268e6400..74222798 100644 --- a/subx/apps/crenshaw2-1b.subx +++ b/subx/apps/crenshaw2-1b.subx @@ -39,12 +39,12 @@ 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # - if argc > 1 and argv[1] == "test" then return run_tests() # . argc > 1 - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0/disp8 1/imm32 # compare *EBP + 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 0/disp8 1/imm32 # compare *EBP 7e/jump-if-lesser-or-equal $run-main/disp8 # . argv[1] == "test" # . . push args 68/push "test"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call kernel-string-equal/disp32 # . . discard args @@ -91,7 +91,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # prime the pump # . Look = get-char(in) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call get-char/disp32 # . . discard args @@ -116,10 +116,10 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # read a digit from 'in' into 'num' # . get-num(in, num, err, ed) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x14/disp8 . # push *(EBP+20) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 . # push *(EBP+20) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) 51/push-ECX/num - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call get-num/disp32 # . . discard args @@ -132,7 +132,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, "bb/copy-to-EBX ") # . . push args 68/push "bb/copy-to-EBX "/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -140,7 +140,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write-stream(out, num) # . . push args 51/push-ECX/num - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write-stream/disp32 # . . discard args @@ -148,7 +148,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, Newline) # . . push args 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -156,7 +156,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, "b8/copy-to-EAX 1/imm32/exit") # . . push args 68/push "b8/copy-to-EAX 1/imm32/exit"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -164,7 +164,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, Newline) # . . push args 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -172,7 +172,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, "cd/syscall 0x80/imm8") # . . push args 68/push "cd/syscall 0x80/imm8"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -180,7 +180,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd # . write(out, Newline) # . . push args 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -240,8 +240,8 @@ get-num: # in : (address buffered-file), out : (address stream), err : fd or (a # . expected(ed, err, "integer") # . . push args 68/push "integer"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x14/disp8 . # push *(EBP+20) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 . # push *(EBP+20) # . . call e8/call expected/disp32 # never returns # . . discard args @@ -257,9 +257,9 @@ $get-num:main: 57/push-EDI # read necessary variables to registers # ESI = in - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI # EDI = out - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 7/r32/EDI 0xc/disp8 . # copy *(EBP+12) to EDI + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 0xc/disp8 . # copy *(EBP+12) to EDI # ECX = out->write 8b/copy 0/mod/indirect 7/rm32/EDI . . . 1/r32/ECX . . # copy *EDI to ECX # EDX = out->length @@ -271,8 +271,8 @@ $get-num:loop: # . error(ed, err, msg) # TODO: show full number # . . push args 68/push "get-num: too many digits in number"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x14/disp8 . # push *(EBP+20) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 . # push *(EBP+20) # . . call e8/call error/disp32 # never returns # . . discard args @@ -686,15 +686,15 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad # write(f, "Error: ") # . . push args 68/push "Error: "/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + 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, s) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -702,7 +702,7 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad # write(f, " expected") # . . push args 68/push " expected"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -710,7 +710,7 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad # write(f, Newline) # . . push args 68/push Newline/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write/disp32 # . . discard args @@ -718,7 +718,7 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad # stop(ed, 1) # . . push args 68/push 1/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call stop/disp32 # should never get past this point @@ -736,7 +736,7 @@ get-char: # f : (address buffered-file) -> <void> 50/push-EAX # read-byte(f) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call read-byte/disp32 # . . discard args @@ -757,10 +757,10 @@ is-digit?: # c : int -> bool/EAX # EAX = false b8/copy-to-EAX 0/imm32 # if c < '0' return false - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 0x30/imm32 # compare *(EBP+8) + 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 0x30/imm32 # compare *(EBP+8) 7c/jump-if-lesser $is-digit?:end/disp8 # if c > '9' return false - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 0x39/imm32 # compare *(EBP+8) + 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 0x39/imm32 # compare *(EBP+8) 7f/jump-if-greater $is-digit?:end/disp8 # otherwise return true b8/copy-to-EAX 1/imm32 diff --git a/subx/apps/factorial b/subx/apps/factorial index 3bd1c65b..679feb71 100755 --- a/subx/apps/factorial +++ b/subx/apps/factorial Binary files differdiff --git a/subx/apps/factorial.subx b/subx/apps/factorial.subx index adc772db..068a63cb 100644 --- a/subx/apps/factorial.subx +++ b/subx/apps/factorial.subx @@ -24,12 +24,12 @@ 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # - if argc > 1 and argv[1] == "test" then return run_tests() # . argc > 1 - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0/disp8 1/imm32 # compare *EBP + 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 0/disp8 1/imm32 # compare *EBP 7e/jump-if-lesser-or-equal $run-main/disp8 # . argv[1] == "test" # . . push args 68/push "test"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call kernel-string-equal/disp32 # . . discard args @@ -63,10 +63,10 @@ factorial: # n : int -> int/EAX # EAX = 1 (base case) b8/copy-to-EAX 1/imm32 # if (n <= 1) return - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 1/imm32 # compare *(EBP+8) + 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 1/imm32 # compare *(EBP+8) 7e/jump-if-<= $factorial:end/disp8 # EBX = n-1 - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 3/r32/EBX 8/disp8 . # copy *(EBP+8) to EBX + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 3/r32/EBX 8/disp8 . # copy *(EBP+8) to EBX 81 5/subop/subtract 3/mod/direct 3/rm32/EBX . . . . . 1/imm32 # subtract from EBX # EAX = factorial(n-1) # . . push args @@ -76,7 +76,7 @@ factorial: # n : int -> int/EAX # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # return n * factorial(n-1) - f7 4/subop/multiply 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 8/disp8 . # multiply *(EBP+8) into EAX + f7 4/subop/multiply 1/mod/*+disp8 5/rm32/EBP . . 8/disp8 . # multiply *(EBP+8) into EAX # TODO: check for overflow $factorial:end: # . epilog diff --git a/subx/apps/hex b/subx/apps/hex index 9287faa7..93c9f27f 100755 --- a/subx/apps/hex +++ b/subx/apps/hex Binary files differdiff --git a/subx/apps/hex.subx b/subx/apps/hex.subx index 032c1da7..2660bd54 100644 --- a/subx/apps/hex.subx +++ b/subx/apps/hex.subx @@ -27,12 +27,12 @@ 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # - if argc > 1 and argv[1] == "test" then return run_tests() # . argc > 1 - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0/disp8 1/imm32 # compare *EBP + 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 0/disp8 1/imm32 # compare *EBP 7e/jump-if-lesser-or-equal $run-main/disp8 # . argv[1] == "test" # . . push args 68/push "test"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call kernel-string-equal/disp32 # . . discard args @@ -91,9 +91,9 @@ convert: # in : (address buffered-file), out : (address buffered-file), err : ( $convert:loop: # EAX = convert-next-octet(in, err, ed) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x14/disp8 . # push *(EBP+20) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 . # push *(EBP+20) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call convert-next-octet/disp32 # . . discard first 2 args @@ -104,7 +104,7 @@ $convert:loop: # write-byte(out, AL) # . . push args 50/push-EAX - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call write-byte/disp32 # . . discard args @@ -114,7 +114,7 @@ $convert:loop: $convert:loop-end: # flush(out) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call e8/call flush/disp32 # . . discard args @@ -151,9 +151,9 @@ convert-next-octet: # in : (address buffered-file), err : (address buffered-fil 51/push-ECX # EAX = scan-next-byte(in, err, ed) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + 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) # . . call e8/call scan-next-byte/disp32 # . . discard args @@ -167,9 +167,9 @@ convert-next-octet: # in : (address buffered-file), err : (address buffered-fil 89/copy 3/mod/direct 1/rm32/ECX . . . 0/r32/EAX . . # copy EAX to ECX # EAX = scan-next-byte(in, err, ed) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + 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) # . . call e8/call scan-next-byte/disp32 # . . discard args @@ -181,8 +181,8 @@ convert-next-octet: # in : (address buffered-file), err : (address buffered-fil # . . push args 68/push 0x2e/imm32/period/dummy 68/push "convert-next-octet: partial byte found"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) + 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 . . . . 0x10/disp8 . # push *(EBP+16) # . . call e8/call error-byte/disp32 # never returns $convert-next-octet:convert: @@ -508,7 +508,7 @@ scan-next-byte: # in : (address buffered-file), err : (address buffered-file), $scan-next-byte:loop: # EAX = read-byte(in) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call read-byte/disp32 # . . discard args @@ -548,7 +548,7 @@ $scan-next-byte:check2: 75/jump-if-not-equal $scan-next-byte:check3/disp8 # . skip-until-newline(in) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call skip-until-newline/disp32 # . . discard args @@ -559,8 +559,8 @@ $scan-next-byte:check3: # . . push args 50/push-EAX 68/push "scan-next-byte: invalid byte"/imm32 - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) + 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 . . . . 0x10/disp8 . # push *(EBP+16) # . . call e8/call error-byte/disp32 # never returns $scan-next-byte:end: @@ -1421,7 +1421,7 @@ is-hex-lowercase-byte?: # c : byte -> bool/EAX # . save registers 51/push-ECX # ECX = c - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX # return false if c < '0' b8/copy-to-EAX 0/imm32/false 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x30/imm32 # compare ECX @@ -1601,7 +1601,7 @@ skip-until-newline: # in : (address buffered-file) -> <void> $skip-until-newline:loop: # . EAX = read-byte(in) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call read-byte/disp32 # . . discard args |