diff options
Diffstat (limited to 'subx')
-rw-r--r-- | subx/055trace.subx | 32 | ||||
-rw-r--r-- | subx/056write.subx | 30 | ||||
-rw-r--r-- | subx/058read.subx | 38 |
3 files changed, 50 insertions, 50 deletions
diff --git a/subx/055trace.subx b/subx/055trace.subx index 3482eb44..8b4c15f4 100644 --- a/subx/055trace.subx +++ b/subx/055trace.subx @@ -83,17 +83,17 @@ trace: # t : (address trace-stream), line : string 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 7/r32/EDI 8/disp8 . # copy *(EBP+8) to EDI # ESI = line 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 6/r32/ESI 0xc/disp8 . # copy *(EBP+12) to ESI - # ECX = t.write + # ECX = t->write 8b/copy 0/mod/indirect 7/rm32/EDI . . . 1/r32/ECX . . # copy *EDI to ECX - # EDX = t.length + # 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) + # EAX = _append-3(&t->data[t->write], &t->data[t->length], 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 @@ -103,24 +103,24 @@ trace: # t : (address trace-stream), line : string # if EAX == 0 return 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0/imm32 # compare EDX 74/jump-if-equal $trace:end/disp8 - # t.write += EAX + # t->write += EAX 01/add 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . . # add EAX to *EDI - # refresh ECX = t.write + # 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) + # EAX = _append-3(&t->data[t->write], &t->data[t->length], 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 e8/call _append-3/disp32 # discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # t.write += EAX + # t->write += EAX 01/add 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . . # add EAX to *EDI $trace:end: # restore registers @@ -144,15 +144,15 @@ clear-trace-stream: # t : (address trace-stream) 51/push-ECX # EAX = t 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX - # ECX = t.length + # ECX = t->length 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 8/disp8 . # copy *(EAX+8) to ECX - # ECX = &t.data[t.length] + # ECX = &t->data[t->length] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 0xc/disp8 . # copy EAX+ECX+12 to ECX - # t.write = 0 + # t->write = 0 c7/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32 # copy to *EAX - # t.read = 0 + # t->read = 0 c7/copy 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 0/imm32 # copy to *(EAX+4) - # EAX = t.data + # EAX = t->data 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 0xc/imm32 # add to EAX # while (true) $clear-trace-stream:loop: diff --git a/subx/056write.subx b/subx/056write.subx index 67115d5a..045a8187 100644 --- a/subx/056write.subx +++ b/subx/056write.subx @@ -54,24 +54,24 @@ $write:fake: 53/push-EBX # ECX = f 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX - # EDX = f.write + # EDX = f->write 8b/copy 0/mod/indirect 1/rm32/ECX . . . 2/r32/EDX . . # copy *ECX to EDX - # EBX = f.length + # EBX = f->length 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 3/r32/EBX 8/disp8 . # copy *(ECX+8) to EBX - # EAX = _append-3(&f.data[f.write], &f.data[f.length], s) + # EAX = _append-3(&f->data[f->write], &f->data[f->length], s) # push s ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - # push &f.data[f.length] + # push &f->data[f->length] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ECX 3/index/EBX . 3/r32/EBX 0xc/disp8 . # copy ECX+EBX+12 to EBX 53/push-EBX - # push &f.data[f.write] + # push &f->data[f->write] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ECX 2/index/EDX . 3/r32/EBX 0xc/disp8 . # copy ECX+EDX+12 to EBX 53/push-EBX # call e8/call _append-3/disp32 # discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # f.write += EAX + # f->write += EAX 01/add 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . . # add EAX to *ECX # restore registers 5b/pop-to-EBX @@ -92,15 +92,15 @@ clear-stream: # f : (address stream) -> <void> 51/push-ECX # EAX = f 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX - # ECX = f.length + # ECX = f->length 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 8/disp8 . # copy *(EAX+8) to ECX - # ECX = &f.data[f.length] + # ECX = &f->data[f->length] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 0xc/disp8 . # copy EAX+ECX+12 to ECX - # f.write = 0 + # f->write = 0 c7/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32 # copy to *EAX - # f.read = 0 + # f->read = 0 c7/copy 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 0/imm32 # copy to *(EAX+4) - # EAX = f.data + # EAX = f->data 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 0xc/imm32 # add to EAX # while (true) $clear-stream:loop: @@ -146,11 +146,11 @@ test-write-single: e8/call check-ints-equal/disp32 # discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # check-ints-equal(*_test-stream.data, 41/A 62/b 00 00, msg) + # check-ints-equal(*_test-stream->data, 41/A 62/b 00 00, msg) # push args 68/push "F - test-write-single"/imm32 68/push 0x006241/imm32/Ab - # push *_test-stream.data + # push *_test-stream->data b8/copy-to-EAX _test-stream/imm32 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) # call @@ -184,11 +184,11 @@ test-write-appends: e8/call write/disp32 # discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # check-ints-equal(*_test-stream.data, 43/C 44/D 00 00, msg) + # check-ints-equal(*_test-stream->data, 43/C 44/D 00 00, msg) # push args 68/push "F - test-write-appends"/imm32 68/push 0x00004443/imm32/C-D - # push *_test-stream.data + # push *_test-stream->data b8/copy-to-EAX _test-stream/imm32 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) # call diff --git a/subx/058read.subx b/subx/058read.subx index a48cd609..3d55e195 100644 --- a/subx/058read.subx +++ b/subx/058read.subx @@ -88,11 +88,11 @@ $read:fake: 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 . # copy *(ESI+4) to EAX 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 0/r32/EAX 0xc/disp8 . # copy ESI+EAX+12 to EAX 50/push-EAX - # push &s.data[s.length] + # push &s->data[s->length] 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 0/r32/EAX 8/disp8 . # copy *(EDI+8) to EAX 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 0/index/EAX . 0/r32/EAX 0xc/disp8 . # copy EDI+EAX+12 to EAX 50/push-EAX - # push &s.data[s.write] + # push &s->data[s->write] 8b/copy 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . . # copy *EDI to EAX 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 0/index/EAX . 0/r32/EAX 0xc/disp8 . # copy EDI+EAX+12 to EAX 50/push-EAX @@ -100,7 +100,7 @@ $read:fake: e8/call _append-4/disp32 # discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32 # add to ESP - # s.write += EAX + # s->write += EAX 01/add 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . . # add EAX to *EDI # f.read += EAX 01/add 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 . # add EAX to *(ESI+4) @@ -130,21 +130,21 @@ _read: # fd : int, s : (address stream) -> num-bytes-read/EAX 56/push-ESI # ESI = s 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 6/r32/ESI 0xc/disp8 . # copy *(EBP+12) to ESI - # EAX = s.write + # EAX = s->write 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # copy *ESI to EAX - # EDX = s.length + # EDX = s->length 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 2/r32/EDX 8/disp8 . # copy *(ESI+8) to EDX - # syscall(read, fd, &s.data[s.write], s.length - s.write) + # syscall(read, fd, &s->data[s->write], s->length - s->write) # fd : EBX 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 3/r32/EBX 8/disp8 . # copy *(EBP+8) to EBX - # data : ECX = &s.data[s.write] + # data : ECX = &s->data[s->write] 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 1/r32/ECX 0xc/disp8 . # copy ESI+EAX+12 to ECX - # size : EDX = s.length - s.write + # size : EDX = s->length - s->write 29/subtract 3/mod/direct 2/rm32/EDX . . . 0/r32/EAX . . # subtract EAX from EDX # syscall b8/copy-to-EAX 3/imm32/read cd/syscall 0x80/imm8 - # add the result EAX to s.write + # add the result EAX to s->write 01/add 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # add EAX to *ESI # restore registers 5e/pop-to-ESI @@ -159,19 +159,19 @@ _read: # fd : int, s : (address stream) -> num-bytes-read/EAX # Two options: # 1 (what we have above): # ECX = s - # EAX = s.write - # EDX = s.length + # EAX = s->write + # EDX = s->length # # syscall # ECX = lea ECX+EAX+12 # EDX = sub EDX EAX # # 2: # ECX = s - # EDX = s.length - # ECX = &s.data + # EDX = s->length + # ECX = &s->data # # syscall - # ECX = add ECX, s.write - # EDX = sub EDX, s.write + # ECX = add ECX, s->write + # EDX = sub EDX, s->write # # Not much to choose between the two? Option 2 performs a duplicate load to # use one less register, but doesn't increase the amount of spilling (ECX @@ -219,11 +219,11 @@ test-read-single: e8/call check-ints-equal/disp32 # discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # check-ints-equal(*_test-stream-buffer.data, 41/A 62/b 00 00, msg) + # check-ints-equal(*_test-stream-buffer->data, 41/A 62/b 00 00, msg) # push args 68/push "F - test-read-single"/imm32 68/push 0x006241/imm32/Ab - # push *_test-stream-buffer.data + # push *_test-stream-buffer->data b8/copy-to-EAX _test-stream-buffer/imm32 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) # call @@ -281,11 +281,11 @@ test-read-is-stateful: e8/call read/disp32 # discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # check-ints-equal(*_test-stream-buffer.data, 43/C 44/D 00 00, msg) + # check-ints-equal(*_test-stream-buffer->data, 43/C 44/D 00 00, msg) # push args 68/push "F - test-read-is-stateful"/imm32 68/push 0x00004443/imm32/C-D - # push *_test-stream-buffer.data + # push *_test-stream-buffer->data b8/copy-to-EAX _test-stream-buffer/imm32 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) # call |