6508 - support null exit-descriptor
This commit is contained in:
parent
7dac9ade15
commit
80f53f4a18
19
059stop.subx
19
059stop.subx
|
@ -93,21 +93,28 @@ stop: # ed: (addr exit-descriptor), value: int
|
|||
# no prologue; one way or another, we're going to clobber registers
|
||||
# eax = ed
|
||||
8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/esp 4/index/none . 0/r32/eax 4/disp8 . # copy *(esp+4) to eax
|
||||
# if (ed == 0) really exit
|
||||
3d/compare-eax-and 0/imm32
|
||||
74/jump-if-= $stop:real/disp8
|
||||
# if (ed->target == 0) really exit
|
||||
81 7/subop/compare 0/mod/indirect 0/rm32/eax . . . . . 0/imm32 # compare *eax
|
||||
75/jump-if-!= $stop:fake/disp8
|
||||
# . syscall(exit, value)
|
||||
8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/esp 4/index/none . 3/r32/ebx 8/disp8 . # copy *(esp+8) to ebx
|
||||
e8/call syscall_exit/disp32
|
||||
74/jump-if-= $stop:real/disp8
|
||||
$stop:fake:
|
||||
# otherwise:
|
||||
# ed->value = value+1
|
||||
8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/esp 4/index/none . 1/r32/ecx 8/disp8 . # copy *(esp+8) to ecx
|
||||
41/increment-ecx
|
||||
89/copy 1/mod/*+disp8 0/rm32/eax . . . 1/r32/ecx 4/disp8 . # copy ecx to *(eax+4)
|
||||
# perform a non-local jump to ed->target
|
||||
8b/copy 0/mod/indirect 0/rm32/eax . . . 4/r32/esp . . # copy *eax to esp
|
||||
$stop:end:
|
||||
$stop:end1:
|
||||
# never gets here
|
||||
c3/return # doesn't return to caller
|
||||
$stop:real:
|
||||
# . syscall(exit, value)
|
||||
8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/esp 4/index/none . 3/r32/ebx 8/disp8 . # copy *(esp+8) to ebx
|
||||
e8/call syscall_exit/disp32
|
||||
$stop:end2:
|
||||
# never gets here
|
||||
c3/return # doesn't return to caller
|
||||
|
||||
test-stop-skips-returns-on-exit:
|
||||
|
|
BIN
apps/assort
BIN
apps/assort
Binary file not shown.
BIN
apps/braces
BIN
apps/braces
Binary file not shown.
BIN
apps/calls
BIN
apps/calls
Binary file not shown.
BIN
apps/crenshaw2-1
BIN
apps/crenshaw2-1
Binary file not shown.
|
@ -67,15 +67,9 @@ Entry: # run tests if necessary, call 'compile' if not
|
|||
eb/jump $main:end/disp8
|
||||
$run-main:
|
||||
# - otherwise read a program from stdin and emit its translation to stdout
|
||||
# var ed/eax: exit-descriptor
|
||||
81 5/subop/subtract 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # subtract from esp
|
||||
89/copy 3/mod/direct 0/rm32/eax . . . 4/r32/esp . . # copy esp to eax
|
||||
# configure ed to really exit()
|
||||
# . ed->target = 0
|
||||
c7 0/subop/copy 0/mod/direct 0/rm32/eax . . . . . 0/imm32 # copy to *eax
|
||||
# compile(Stdin, 1/stdout, 2/stderr, ed)
|
||||
# . compile(Stdin, 1/stdout, 2/stderr, ed)
|
||||
# . . push args
|
||||
50/push-eax/ed
|
||||
68/push 0/imm32/exit-descriptor
|
||||
68/push 2/imm32/stderr
|
||||
68/push 1/imm32/stdout
|
||||
68/push Stdin/imm32
|
||||
|
|
Binary file not shown.
|
@ -67,15 +67,9 @@ Entry: # run tests if necessary, call 'compile' if not
|
|||
eb/jump $main:end/disp8
|
||||
$run-main:
|
||||
# - otherwise read a program from stdin and emit its translation to stdout
|
||||
# var ed/eax: exit-descriptor
|
||||
81 5/subop/subtract 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # subtract from esp
|
||||
89/copy 3/mod/direct 0/rm32/eax . . . 4/r32/esp . . # copy esp to eax
|
||||
# configure ed to really exit()
|
||||
# . ed->target = 0
|
||||
c7 0/subop/copy 0/mod/direct 0/rm32/eax . . . . . 0/imm32 # copy to *eax
|
||||
# compile(Stdin, 1/stdout, 2/stderr, ed)
|
||||
# . compile(Stdin, 1/stdout, 2/stderr, 0)
|
||||
# . . push args
|
||||
50/push-eax/ed
|
||||
68/push 0/imm32/exit-descriptor
|
||||
68/push 2/imm32/stderr
|
||||
68/push 1/imm32/stdout
|
||||
68/push Stdin/imm32
|
||||
|
|
BIN
apps/dquotes
BIN
apps/dquotes
Binary file not shown.
BIN
apps/factorial
BIN
apps/factorial
Binary file not shown.
|
@ -54,15 +54,9 @@ Entry: # run tests if necessary, convert stdin if not
|
|||
eb/jump $subx-hex-main:end/disp8
|
||||
$subx-hex-main:interactive:
|
||||
# - otherwise convert stdin
|
||||
# var ed/eax: exit-descriptor
|
||||
81 5/subop/subtract 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # subtract from esp
|
||||
89/copy 3/mod/direct 0/rm32/eax . . . 4/r32/esp . . # copy esp to eax
|
||||
# configure ed to really exit()
|
||||
# . ed->target = 0
|
||||
c7 0/subop/copy 0/mod/direct 0/rm32/eax . . . . . 0/imm32 # copy to *eax
|
||||
# subx-hex(Stdin, Stdout, Stderr, ed)
|
||||
# . subx-hex(Stdin, Stdout, Stderr, 0)
|
||||
# . . push args
|
||||
50/push-eax/ed
|
||||
68/push 0/imm32/exit-descriptor
|
||||
68/push Stderr/imm32
|
||||
68/push Stdout/imm32
|
||||
68/push Stdin/imm32
|
||||
|
|
BIN
apps/sigils
BIN
apps/sigils
Binary file not shown.
BIN
apps/survey
BIN
apps/survey
Binary file not shown.
BIN
apps/tests
BIN
apps/tests
Binary file not shown.
Loading…
Reference in New Issue