diff options
Diffstat (limited to 'subx/055trace.subx')
-rw-r--r-- | subx/055trace.subx | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/subx/055trace.subx b/subx/055trace.subx index 2f281ced..02bdc0fd 100644 --- a/subx/055trace.subx +++ b/subx/055trace.subx @@ -43,6 +43,7 @@ _test-trace-stream: # . 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: + # run-tests() e8/call run-tests/disp32 # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'. # syscall(exit, Num-test-failures) 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32 # copy *Num-test-failures to EBX @@ -87,12 +88,12 @@ trace: # t : (address trace-stream), line : string # EDX = t->length 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 2/r32/EDX 8/disp8 . # copy *(EDI+8) to EDX # EAX = _append-3(&t->data[t->write], &t->data[t->length], line) - # push line + # . . push line 56/push-ESI - # push &t->data[t->length] + # . . push &t->data[t->length] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 3/r32/EBX 0xc/disp8 . # copy EDI+EDX+12 to EBX 53/push-EBX - # push &t->data[t->write] + # . . 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 @@ -107,12 +108,12 @@ trace: # t : (address trace-stream), line : string # refresh ECX = t->write 8b/copy 0/mod/indirect 7/rm32/EDI . . . 1/r32/ECX . . # copy *EDI to ECX # EAX = _append-3(&t->data[t->write], &t->data[t->length], line) - # push line + # . . push line 68/push Newline/imm32 - # push &t->data[t->length] + # . . push &t->data[t->length] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 3/r32/EBX 0xc/disp8 . # copy EDI+EDX+12 to EBX 53/push-EBX - # push &t->data[t->write] + # . . 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 @@ -172,7 +173,7 @@ $clear-trace-stream:end: 5d/pop-to-EBP c3/return -## tests +# - tests test-trace-single: # clear-trace-stream(_test-trace-stream) @@ -194,7 +195,7 @@ test-trace-single: # . . push args 68/push "F - test-trace-single"/imm32 68/push 0x0a6241/imm32/Ab-newline - # push *_test-trace-stream.data + # . . 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 @@ -232,7 +233,7 @@ test-trace-appends: # . . push args 68/push "F - test-trace-appends"/imm32 68/push 0x0a440a43/imm32/C-newline-D-newline - # push *_test-trace-stream.data + # . . 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 @@ -262,7 +263,7 @@ test-trace-empty-line: # . . push args 68/push "F - test-trace-empty-line"/imm32 68/push 0/imm32 - # push *_test-trace-stream.data + # . . 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 @@ -272,7 +273,7 @@ test-trace-empty-line: # end c3/return -## helpers +# - helpers # 3-argument variant of _append _append-3: # out : address, outend : address, s : (array byte) -> num_bytes_appended/EAX @@ -282,20 +283,17 @@ _append-3: # out : address, outend : address, s : (array byte) -> num_bytes_app # . 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] - # EAX = s + # . . push &s.data[s.length] 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 0x10/disp8 . # copy *(EBP+16) to EAX - # ECX = s.length 8b/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . . # copy *EAX to ECX - # ECX = &s.data[s.length] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 4/disp8 . # copy EAX+ECX+4 to ECX 51/push-ECX - # push &s.data[0] + # . . push &s.data[0] 8d/copy-address 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 4/disp8 . # copy EAX+4 to ECX 51/push-ECX - # push outend + # . . push outend ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - # push out + # . . push out ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 . # push *(EBP+8) # . . call e8/call _append-4/disp32 |