diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-11-30 11:10:44 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-11-30 11:13:36 -0800 |
commit | ee9a9237d6324f1de1bb7150083eacf7b9af5f70 (patch) | |
tree | 86180456f2a3cf5503783afc78856280f088a863 /subx/055trace.subx | |
parent | 6030d7e2e56d445ca67c6a0e8c9cf33e46bc673c (diff) | |
download | mu-ee9a9237d6324f1de1bb7150083eacf7b9af5f70.tar.gz |
4802
Some automated commenting cleanup. Still needs more careful manual scanning. sed -i 's/^# 1-3/# . 1-3/' *.subx */*.subx sed -i 's/^# op/# . op/' *.subx */*.subx sed -i 's/# vim/# . . vim/' *.subx */*.subx sed -i 's/^ # push args/ # . . push args/' *.subx */*.subx sed -i 's/^ # discard args/ # . . discard args/' *.subx */*.subx sed -i 's/^ # call/ # . . call/' *.subx */*.subx sed -i 's/^ # prolog/ # . prolog/' *.subx */*.subx sed -i 's/^ # epilog/ # . epilog/' *.subx */*.subx sed -i 's/^ # save registers/ # . save registers/' *.subx */*.subx sed -i 's/^ # restore registers/ # . restore registers/' *.subx */*.subx sed -i 's/ operand / register /' *.subx */*.subx
Diffstat (limited to 'subx/055trace.subx')
-rw-r--r-- | subx/055trace.subx | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/subx/055trace.subx b/subx/055trace.subx index 7986cf33..2f281ced 100644 --- a/subx/055trace.subx +++ b/subx/055trace.subx @@ -38,9 +38,9 @@ _test-trace-stream: 00 00 00 00 00 00 00 00 # 8 bytes == 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-'. @@ -53,11 +53,11 @@ _test-trace-stream: # The Trace-stream segment will consist of variable-length lines separated by newlines (0x0a) initialize-trace-stream: # EAX = new-segment(0x1000) - # push args + # . . push args 68/push 0x1000/imm32/N - # call + # . . call e8/call new-segment/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # copy EAX to *Trace-stream 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32 # copy EAX to *Trace-stream @@ -68,10 +68,10 @@ initialize-trace-stream: # Append a string to the given trace stream. # Silently give up if it's already full. Or truncate the string if there isn't enough room. trace: # t : (address trace-stream), line : string - # 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 52/push-EDX @@ -95,9 +95,9 @@ trace: # t : (address trace-stream), line : string # push &t->data[t->write] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 1/index/ECX . 3/r32/EBX 0xc/disp8 . # copy EDI+ECX+12 to EBX 53/push-EBX - # call + # . . call e8/call _append-3/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP # if EAX == 0 return 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0/imm32 # compare EDX @@ -115,30 +115,30 @@ trace: # t : (address trace-stream), line : string # push &t->data[t->write] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 1/index/ECX . 3/r32/EBX 0xc/disp8 . # copy EDI+ECX+12 to EBX 53/push-EBX - # call + # . . call e8/call _append-3/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP # t->write += EAX 01/add 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . . # add EAX to *EDI $trace:end: - # restore registers + # . restore registers 5f/pop-to-EDI 5e/pop-to-ESI 5b/pop-to-EBX 5a/pop-to-EDX 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 clear-trace-stream: # t : (address trace-stream) - # 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 = t @@ -164,10 +164,10 @@ $clear-trace-stream:loop: 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 4/imm32 # add to EAX eb/jump $clear-trace-stream:loop/disp8 $clear-trace-stream:end: - # 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 @@ -176,98 +176,98 @@ $clear-trace-stream:end: test-trace-single: # clear-trace-stream(_test-trace-stream) - # push args + # . . push args 68/push _test-trace-stream/imm32 - # call + # . . call e8/call clear-trace-stream/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # trace(_test-trace-stream, "Ab") - # push args + # . . push args 68/push "Ab"/imm32 68/push _test-trace-stream/imm32 - # call + # . . call e8/call trace/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(*_test-trace-stream.data, 41/A 62/b 0a/newline 00, msg) - # push args + # . . push args 68/push "F - test-trace-single"/imm32 68/push 0x0a6241/imm32/Ab-newline # push *_test-trace-stream.data b8/copy-to-EAX _test-trace-stream/imm32 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) - # 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 # end c3/return test-trace-appends: # clear-trace-stream(_test-trace-stream) - # push args + # . . push args 68/push _test-trace-stream/imm32 - # call + # . . call e8/call clear-trace-stream/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # trace(_test-trace-stream, "C") - # push args + # . . push args 68/push "C"/imm32 68/push _test-trace-stream/imm32 - # call + # . . call e8/call trace/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # trace(_test-trace-stream, "D") - # push args + # . . push args 68/push "D"/imm32 68/push _test-trace-stream/imm32 - # call + # . . call e8/call trace/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(*_test-trace-stream.data, 43/C 0a/newline 44/D 0a/newline, msg) - # push args + # . . push args 68/push "F - test-trace-appends"/imm32 68/push 0x0a440a43/imm32/C-newline-D-newline # push *_test-trace-stream.data b8/copy-to-EAX _test-trace-stream/imm32 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) - # 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 # end c3/return test-trace-empty-line: # clear-trace-stream(_test-trace-stream) - # push args + # . . push args 68/push _test-trace-stream/imm32 - # call + # . . call e8/call clear-trace-stream/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # trace(_test-trace-stream, "") - # push args + # . . push args 68/push ""/imm32 68/push _test-trace-stream/imm32 - # call + # . . call e8/call trace/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(*_test-trace-stream.data, 0, msg) - # push args + # . . push args 68/push "F - test-trace-empty-line"/imm32 68/push 0/imm32 # push *_test-trace-stream.data b8/copy-to-EAX _test-trace-stream/imm32 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) - # 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 # end c3/return @@ -276,10 +276,10 @@ test-trace-empty-line: # 3-argument variant of _append _append-3: # out : address, outend : address, s : (array byte) -> num_bytes_appended/EAX - # prolog + # . prolog 55/push-EBP 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - # save registers + # . save registers 51/push-ECX # _append-4(out, outend, &s.data[0], &s.data[s.length]) -> num_bytes_appended/EAX # push &s.data[s.length] @@ -297,23 +297,23 @@ _append-3: # out : address, outend : address, s : (array byte) -> num_bytes_app ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) # push out ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 . # push *(EBP+8) - # call + # . . call e8/call _append-4/disp32 - # discard args + # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32 # add to ESP - # restore registers + # . restore registers 59/pop-to-ECX - # epilog + # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP c3/return # 4-argument variant of _append _append-4: # out : address, outend : address, in : address, inend : address -> num_bytes_appended/EAX - # prolog + # . prolog 55/push-EBP 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - # save registers + # . save registers 51/push-ECX 52/push-EDX 53/push-EBX @@ -345,15 +345,15 @@ $_append-4:loop: 47/increment-EDI eb/jump $_append-4:loop/disp8 $_append-4:end: - # restore registers + # . restore registers 5f/pop-to-EDI 5e/pop-to-ESI 5b/pop-to-EBX 5a/pop-to-EDX 59/pop-to-ECX - # 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 |