diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-08-31 23:22:49 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-08-31 23:42:45 -0700 |
commit | 282681c729857026e3713d45e9027fdfccda0880 (patch) | |
tree | 33b3e0fd15aa70150f88df81edc8d6454814c487 /apps | |
parent | f3ab82e9431dd54c7369671232b6841073f1da68 (diff) | |
download | mu-282681c729857026e3713d45e9027fdfccda0880.tar.gz |
5600
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/assort | bin | 38657 -> 38657 bytes | |||
-rw-r--r-- | apps/assort.subx | 24 | ||||
-rwxr-xr-x | apps/crenshaw2-1 | bin | 30993 -> 30993 bytes | |||
-rw-r--r-- | apps/crenshaw2-1.subx | 19 | ||||
-rwxr-xr-x | apps/crenshaw2-1b | bin | 31552 -> 31552 bytes | |||
-rw-r--r-- | apps/crenshaw2-1b.subx | 19 | ||||
-rwxr-xr-x | apps/dquotes | bin | 43819 -> 43819 bytes | |||
-rw-r--r-- | apps/dquotes.subx | 22 | ||||
-rwxr-xr-x | apps/factorial | bin | 30005 -> 30005 bytes | |||
-rw-r--r-- | apps/factorial.subx | 9 | ||||
-rwxr-xr-x | apps/hex | bin | 41050 -> 41050 bytes | |||
-rw-r--r-- | apps/hex.subx | 19 | ||||
-rwxr-xr-x | apps/pack | bin | 51343 -> 51343 bytes | |||
-rw-r--r-- | apps/pack.subx | 19 | ||||
-rwxr-xr-x | apps/sigils | bin | 51857 -> 51857 bytes | |||
-rw-r--r-- | apps/sigils.subx | 20 | ||||
-rw-r--r-- | apps/subx-common.subx | 3 | ||||
-rwxr-xr-x | apps/survey | bin | 47940 -> 47940 bytes | |||
-rw-r--r-- | apps/survey.subx | 22 | ||||
-rwxr-xr-x | apps/tests | bin | 37469 -> 37469 bytes | |||
-rw-r--r-- | apps/tests.subx | 26 |
21 files changed, 111 insertions, 91 deletions
diff --git a/apps/assort b/apps/assort index 7edb60a9..3e4911fd 100755 --- a/apps/assort +++ b/apps/assort Binary files differdiff --git a/apps/assort.subx b/apps/assort.subx index c185e137..f1d76df6 100644 --- a/apps/assort.subx +++ b/apps/assort.subx @@ -23,7 +23,10 @@ # . 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 -Entry: +Entry: # run tests if necessary, convert stdin if not + # . prolog + 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + # initialize heap # . Heap = new-segment(Heap-size) # . . push args @@ -34,14 +37,12 @@ Entry: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # run tests if necessary, convert stdin if not - # . prolog - 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 + # if (argc <= 1) goto run-main 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" + # if (!kernel-string-equal?(argv[1], "test")) goto run-main + # . eax = kernel-string-equal?(argv[1], "test") # . . push args 68/push "test"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) @@ -49,11 +50,12 @@ Entry: e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . check result - 3d/compare-eax-and 1/imm32 - 75/jump-if-not-equal $run-main/disp8 - # . run-tests() + # . if (eax == 0) goto run-main + 3d/compare-eax-and 0/imm32 + 74/jump-if-equal $run-main/disp8 + # run-tests() e8/call run-tests/disp32 + # return *Num-test-failures 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx eb/jump $main:end/disp8 $run-main: @@ -64,7 +66,7 @@ $run-main: # configure ed to really exit() # . ed->target = 0 c7 0/subop/copy 0/mod/direct 0/rm32/eax . . . . . 0/imm32 # copy to *eax - # return convert(Stdin, 1/stdout, 2/stderr, ed) + # return convert(Stdin, Stdout, Stderr, ed) # . . push args 50/push-eax/ed 68/push Stderr/imm32 diff --git a/apps/crenshaw2-1 b/apps/crenshaw2-1 index ee400a90..e7e21ee0 100755 --- a/apps/crenshaw2-1 +++ b/apps/crenshaw2-1 Binary files differdiff --git a/apps/crenshaw2-1.subx b/apps/crenshaw2-1.subx index 17e2649c..e4e78e9c 100644 --- a/apps/crenshaw2-1.subx +++ b/apps/crenshaw2-1.subx @@ -31,6 +31,9 @@ # . 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 Entry: # run tests if necessary, call 'compile' if not + # . prolog + 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + # initialize heap # . Heap = new-segment(64KB) # . . push args @@ -41,13 +44,12 @@ Entry: # run tests if necessary, call 'compile' if not # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . prolog - 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 + # if (argc <= 1) goto run-main 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" + # if (!kernel-string-equal?(argv[1], "test")) goto run-main + # . eax = kernel-string-equal?(argv[1], "test") # . . push args 68/push "test"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) @@ -55,11 +57,12 @@ Entry: # run tests if necessary, call 'compile' 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 - # . check result - 3d/compare-eax-and 1/imm32 - 75/jump-if-not-equal $run-main/disp8 - # . run-tests() + # . if (eax == 0) goto run-main + 3d/compare-eax-and 0/imm32 + 74/jump-if-equal $run-main/disp8 + # run-tests() e8/call run-tests/disp32 + # return *Num-test-failures 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx eb/jump $main:end/disp8 $run-main: diff --git a/apps/crenshaw2-1b b/apps/crenshaw2-1b index 68bb81e6..1e81ca9e 100755 --- a/apps/crenshaw2-1b +++ b/apps/crenshaw2-1b Binary files differdiff --git a/apps/crenshaw2-1b.subx b/apps/crenshaw2-1b.subx index 9ebb7465..cbd18d46 100644 --- a/apps/crenshaw2-1b.subx +++ b/apps/crenshaw2-1b.subx @@ -31,6 +31,9 @@ # . 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 Entry: # run tests if necessary, call 'compile' if not + # . prolog + 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + # initialize heap # . Heap = new-segment(64KB) # . . push args @@ -41,13 +44,12 @@ Entry: # run tests if necessary, call 'compile' if not # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . prolog - 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 + # if (argc <= 1) goto run-main 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" + # if (!kernel-string-equal?(argv[1], "test")) goto run-main + # . eax = kernel-string-equal?(argv[1], "test") # . . push args 68/push "test"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) @@ -55,11 +57,12 @@ Entry: # run tests if necessary, call 'compile' 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 - # . check result - 3d/compare-eax-and 1/imm32 - 75/jump-if-not-equal $run-main/disp8 - # . run-tests() + # . if (eax == 0) goto run-main + 3d/compare-eax-and 0/imm32 + 74/jump-if-equal $run-main/disp8 + # run-tests() e8/call run-tests/disp32 + # return *Num-test-failures 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx eb/jump $main:end/disp8 $run-main: diff --git a/apps/dquotes b/apps/dquotes index c41c90c8..4a00ec5e 100755 --- a/apps/dquotes +++ b/apps/dquotes Binary files differdiff --git a/apps/dquotes.subx b/apps/dquotes.subx index 97d2eaa7..95d3bc15 100644 --- a/apps/dquotes.subx +++ b/apps/dquotes.subx @@ -19,7 +19,10 @@ # . 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 -Entry: +Entry: # run tests if necessary, convert stdin if not + # . prolog + 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + # initialize heap # . Heap = new-segment(Heap-size) # . . push args @@ -30,14 +33,12 @@ Entry: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # run tests if necessary, convert stdin if not - # . prolog - 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 + # if (argc <= 1) goto run-main 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" + # if (!kernel-string-equal?(argv[1], "test")) goto run-main + # . eax = kernel-string-equal?(argv[1], "test") # . . push args 68/push "test"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) @@ -45,11 +46,12 @@ Entry: e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . check result - 3d/compare-eax-and 1/imm32 - 75/jump-if-not-equal $run-main/disp8 - # . run-tests() + # . if (eax == 0) goto run-main + 3d/compare-eax-and 0/imm32 + 74/jump-if-equal $run-main/disp8 + # run-tests() e8/call run-tests/disp32 + # return *Num-test-failures 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx eb/jump $main:end/disp8 $run-main: diff --git a/apps/factorial b/apps/factorial index 4f679168..77db0705 100755 --- a/apps/factorial +++ b/apps/factorial Binary files differdiff --git a/apps/factorial.subx b/apps/factorial.subx index 12fc3b0c..1fb111d0 100644 --- a/apps/factorial.subx +++ b/apps/factorial.subx @@ -50,10 +50,9 @@ Entry: # run tests if necessary, compute `factorial(5)` if not 74/jump-if-equal $run-main/disp8 # run-tests() e8/call run-tests/disp32 - # eax = *Num-test-failures - 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/eax Num-test-failures/disp32 # copy *Num-test-failures to eax - # return - eb/jump $main:end/disp8 # where eax will get copied to ebx + # return *Num-test-failures + 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx + eb/jump $main:end/disp8 $run-main: # - otherwise return factorial(5) # . . push args @@ -62,9 +61,9 @@ $run-main: e8/call factorial/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp -$main:end: # syscall(exit, eax) 89/copy 3/mod/direct 3/rm32/ebx . . . 0/r32/eax . . # copy eax to ebx +$main:end: b8/copy-to-eax 1/imm32/exit cd/syscall 0x80/imm8 diff --git a/apps/hex b/apps/hex index 93e0a280..b5eec4b5 100755 --- a/apps/hex +++ b/apps/hex Binary files differdiff --git a/apps/hex.subx b/apps/hex.subx index be8f9fb5..a28d9461 100644 --- a/apps/hex.subx +++ b/apps/hex.subx @@ -18,6 +18,9 @@ # . 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 Entry: # run tests if necessary, convert stdin if not + # . prolog + 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + # initialize heap # . Heap = new-segment(64KB) # . . push args @@ -28,13 +31,12 @@ Entry: # run tests if necessary, convert stdin if not # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . prolog - 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 + # if (argc <= 1) goto run-main 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" + # if (!kernel-string-equal?(argv[1], "test")) goto run-main + # . eax = kernel-string-equal?(argv[1], "test") # . . push args 68/push "test"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) @@ -42,11 +44,12 @@ 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 - # . check result - 3d/compare-eax-and 1/imm32 - 75/jump-if-not-equal $run-main/disp8 - # . run-tests() + # . if (eax == 0) goto run-main + 3d/compare-eax-and 0/imm32 + 74/jump-if-equal $run-main/disp8 + # run-tests() e8/call run-tests/disp32 + # return *Num-test-failures 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx eb/jump $main:end/disp8 $run-main: diff --git a/apps/pack b/apps/pack index 9eed75fd..63cc900f 100755 --- a/apps/pack +++ b/apps/pack Binary files differdiff --git a/apps/pack.subx b/apps/pack.subx index 14387ad9..fe695c4f 100644 --- a/apps/pack.subx +++ b/apps/pack.subx @@ -19,6 +19,9 @@ # . 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 Entry: # run tests if necessary, convert stdin if not + # . prolog + 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + # initialize heap # . Heap = new-segment(64KB) # . . push args @@ -29,13 +32,12 @@ Entry: # run tests if necessary, convert stdin if not # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . prolog - 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 + # if (argc <= 1) goto run-main 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" + # if (!kernel-string-equal?(argv[1], "test")) goto run-main + # . eax = kernel-string-equal?(argv[1], "test") # . . push args 68/push "test"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) @@ -43,11 +45,12 @@ 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 - # . check result - 3d/compare-eax-and 1/imm32 - 75/jump-if-not-equal $run-main/disp8 - # . run-tests() + # . if (eax == 0) goto run-main + 3d/compare-eax-and 0/imm32 + 74/jump-if-equal $run-main/disp8 + # run-tests() e8/call run-tests/disp32 + # return *Num-test-failures 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx eb/jump $main:end/disp8 $run-main: diff --git a/apps/sigils b/apps/sigils index dd24d96a..1772267d 100755 --- a/apps/sigils +++ b/apps/sigils Binary files differdiff --git a/apps/sigils.subx b/apps/sigils.subx index 934f3be2..53452f1e 100644 --- a/apps/sigils.subx +++ b/apps/sigils.subx @@ -46,6 +46,9 @@ # . 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 Entry: # run tests if necessary, convert stdin if not + # . prolog + 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + # initialize heap # . Heap = new-segment(Heap-size) # . . push args @@ -56,14 +59,12 @@ Entry: # run tests if necessary, convert stdin if not # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # run tests if necessary, convert stdin if not - # . prolog - 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 + # if (argc <= 1) goto run-main 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" + # if (!kernel-string-equal?(argv[1], "test")) goto run-main + # . eax = kernel-string-equal?(argv[1], "test") # . . push args 68/push "test"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) @@ -71,11 +72,12 @@ 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 - # . check result - 3d/compare-eax-and 1/imm32 - 75/jump-if-not-equal $run-main/disp8 - # . run-tests() + # . if (eax == 0) goto run-main + 3d/compare-eax-and 0/imm32 + 74/jump-if-equal $run-main/disp8 + # run-tests() e8/call run-tests/disp32 + # return *Num-test-failures 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx eb/jump $main:end/disp8 $run-main: diff --git a/apps/subx-common.subx b/apps/subx-common.subx index 3b55829d..4b9423aa 100644 --- a/apps/subx-common.subx +++ b/apps/subx-common.subx @@ -1,6 +1,5 @@ -# common helpers shared by phases of the SubX translator +# return shared by phases of the SubX translator -# - some limits on the programs we can translate == data # maximum memory available for allocation diff --git a/apps/survey b/apps/survey index 12290097..c2a0ffaf 100755 --- a/apps/survey +++ b/apps/survey Binary files differdiff --git a/apps/survey.subx b/apps/survey.subx index aabd1cfa..e19befc2 100644 --- a/apps/survey.subx +++ b/apps/survey.subx @@ -41,7 +41,10 @@ # . 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 -Entry: +Entry: # run tests if necessary, convert stdin if not + # . prolog + 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + # Heap = new-segment(Heap-size) # . . push args 68/push Heap/imm32 @@ -58,14 +61,12 @@ Entry: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp - # run tests if necessary, convert stdin if not - # . prolog - 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 + # if (argc <= 1) goto run-main 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" + # if (!kernel-string-equal?(argv[1], "test")) goto run-main + # . eax = kernel-string-equal?(argv[1], "test") # . . push args 68/push "test"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) @@ -73,11 +74,12 @@ Entry: e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . check result - 3d/compare-eax-and 1/imm32 - 75/jump-if-not-equal $run-main/disp8 - # . run-tests() + # . if (eax == 0) goto run-main + 3d/compare-eax-and 0/imm32 + 74/jump-if-equal $run-main/disp8 + # run-tests() e8/call run-tests/disp32 + # return *Num-test-failures 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx eb/jump $main:end/disp8 $run-main: diff --git a/apps/tests b/apps/tests index 16b360d4..ef4abae9 100755 --- a/apps/tests +++ b/apps/tests Binary files differdiff --git a/apps/tests.subx b/apps/tests.subx index 99b02664..8f825a3a 100644 --- a/apps/tests.subx +++ b/apps/tests.subx @@ -9,8 +9,12 @@ # . 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 -Entry: - # Heap = new-segment(Heap-size) +Entry: # run tests if necessary, convert stdin if not + # . prolog + 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + + # initialize heap + # . Heap = new-segment(Heap-size) # . . push args 68/push Heap/imm32 68/push Heap-size/imm32 @@ -26,15 +30,12 @@ Entry: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp - # run tests if necessary, convert stdin if not - # . prolog - 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp - # initialize heap # - if argc > 1 and argv[1] == "test", then return run_tests() - # . argc > 1 + # if (argc <= 1) goto run-main 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" + # if (!kernel-string-equal?(argv[1], "test")) goto run-main + # . eax = kernel-string-equal?(argv[1], "test") # . . push args 68/push "test"/imm32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) @@ -42,11 +43,12 @@ Entry: e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . check result - 3d/compare-eax-and 1/imm32 - 75/jump-if-not-equal $run-main/disp8 - # . run-tests() + # . if (eax == 0) goto run-main + 3d/compare-eax-and 0/imm32 + 74/jump-if-equal $run-main/disp8 + # run-tests() e8/call run-tests/disp32 + # return *Num-test-failures 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx eb/jump $main:end/disp8 $run-main: |