diff options
Diffstat (limited to 'subx/057stop.subx')
-rw-r--r-- | subx/057stop.subx | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/subx/057stop.subx b/subx/057stop.subx index 483c9404..b9ef4467 100644 --- a/subx/057stop.subx +++ b/subx/057stop.subx @@ -33,9 +33,9 @@ # Its value is its output, computed during stop and available to the test. == code -# instruction effective address operand displacement immediate -# 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 +# instruction effective address register displacement immediate +# . 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 # main: e8/call run-tests/disp32 # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'. @@ -49,10 +49,10 @@ # the stack. # Ugly that we need to know the size of args, but so it goes. tailor-exit-descriptor: # ed : (address exit-descriptor), nbytes : int -> <void> - # prolog + # . prolog 55/push-EBP 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - # save registers + # . save registers 50/push-EAX 51/push-ECX # EAX = nbytes @@ -65,7 +65,7 @@ tailor-exit-descriptor: # ed : (address exit-descriptor), nbytes : int -> <void # That's the value we need to return: X-nbytes-4 # # However, we also need to account for the perturbance to ESP caused by the - # call to tailor-exit-descriptor. It pushes 8 bytes of args followed by 4 + # . . call to tailor-exit-descriptor. It pushes 8 bytes of args followed by 4 # bytes for the return address and 4 bytes to push EBP above. # So EBP at this point is X-16. # @@ -87,10 +87,10 @@ tailor-exit-descriptor: # ed : (address exit-descriptor), nbytes : int -> <void 89/copy 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . . # copy EAX to *ECX # initialize ed->value c7/copy 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # copy to *(ECX+4) - # restore registers + # . restore registers 59/pop-to-ECX 58/pop-to-EAX - # epilog + # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP c3/return @@ -132,78 +132,78 @@ test-stop-skips-returns-on-exit: 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 0/r32/EAX . . # copy ESP to EAX # Size the exit-descriptor precisely for the next call below, to _test-stop-1. # tailor-exit-descriptor(ed, 4) - # push args + # . . push args 68/push 4/imm32/nbytes-of-args-for-_test-stop-1 50/push-EAX - # call + # . . call e8/call tailor-exit-descriptor/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # call _test-stop-1(ed) - # push args + # . . call _test-stop-1(ed) + # . . push args 50/push-EAX - # call + # . . call e8/call _test-stop-1/disp32 ## registers except ESP may be clobbered at this point # restore args 58/pop-to-EAX # check that _test-stop-1 tried to call exit(1) # check-ints-equal(ed->value, 2, msg) # i.e. stop was called with value 1 - # push args + # . . push args 68/push "F - test-stop-skips-returns-on-exit"/imm32 68/push 2/imm32 # push ed->value ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 . # push *(EAX+4) - # call + # . . call e8/call check-ints-equal/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # epilog + # . epilog 5d/pop-to-EBP # don't restore ESP from EBP; manually reclaim locals 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP c3/return _test-stop-1: # ed : (address exit-descriptor) - # prolog + # . prolog 55/push-EBP 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # _test-stop-2(ed) - # push args + # . . push args ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) - # call + # . . call e8/call _test-stop-2/disp32 ## should never get past this point - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # signal test failed: check-ints-equal(1, 0, msg) - # push args + # . . push args 68/push "F - test-stop-skips-returns-on-exit"/imm32 68/push 0/imm32 68/push 1/imm32 - # call + # . . call e8/call check-ints-equal/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # epilog + # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP c3/return _test-stop-2: # ed : (address exit-descriptor) - # prolog + # . prolog 55/push-EBP 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - # call stop(ed, 1) - # push args + # . . call 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) - # call + # . . call e8/call stop/disp32 ## should never get past this point - # epilog + # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP c3/return -# vim:nowrap:textwidth=0 +# . . vim:nowrap:textwidth=0 |