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/assort.subx | |
parent | f3ab82e9431dd54c7369671232b6841073f1da68 (diff) | |
download | mu-282681c729857026e3713d45e9027fdfccda0880.tar.gz |
5600
Diffstat (limited to 'apps/assort.subx')
-rw-r--r-- | apps/assort.subx | 24 |
1 files changed, 13 insertions, 11 deletions
diff --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 |