diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-11-30 10:54:42 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-11-30 10:54:42 -0800 |
commit | 6030d7e2e56d445ca67c6a0e8c9cf33e46bc673c (patch) | |
tree | 83b6fc800dc5c90295b58e5b0494b083636efbaa /subx/058read.subx | |
parent | e9661581f092f3e210b7bd900af058d8b8c4369e (diff) | |
download | mu-6030d7e2e56d445ca67c6a0e8c9cf33e46bc673c.tar.gz |
4801
Reindent all SubX code to make some room for the new comment style.
Diffstat (limited to 'subx/058read.subx')
-rw-r--r-- | subx/058read.subx | 438 |
1 files changed, 219 insertions, 219 deletions
diff --git a/subx/058read.subx b/subx/058read.subx index b6bfac64..54f83f0f 100644 --- a/subx/058read.subx +++ b/subx/058read.subx @@ -41,76 +41,76 @@ # data: (array byte) # prefixed by length as usual == 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 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 # main: - 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 - b8/copy-to-EAX 1/imm32 - cd/syscall 0x80/imm8 + 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 + b8/copy-to-EAX 1/imm32 + cd/syscall 0x80/imm8 read: # f : fd or (address stream), s : (address stream) -> num-bytes-read/EAX - # prolog - 55/push-EBP - 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - ## if (f < 0x08000000) return _read(f, s) # f can't be a user-mode address, so treat it as a kernel file descriptor - 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 0x08000000/imm32 # compare *(EBP+8) - 7d/jump-if-greater-or-equal $read:fake/disp8 + # prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + ## if (f < 0x08000000) return _read(f, s) # f can't be a user-mode address, so treat it as a kernel file descriptor + 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 0x08000000/imm32 # compare *(EBP+8) + 7d/jump-if-greater-or-equal $read:fake/disp8 # push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) # call - e8/call _read/disp32 + e8/call _read/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # return - eb/jump $read:end/disp8 + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # return + eb/jump $read:end/disp8 $read:fake: - ## otherwise, treat 'f' as a stream to scan from - # save registers - 56/push-ESI - 57/push-EDI - # ESI = f - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI - # EDI = s - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 7/r32/EDI 0xc/disp8 . # copy *(EBP+12) to ESI - # EAX = _append-4(out = &s->data[s->write], outend = &s->data[s->length], - # in = &f->data[f->read], inend = &f->data[f->write]) + ## otherwise, treat 'f' as a stream to scan from + # save registers + 56/push-ESI + 57/push-EDI + # ESI = f + 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI + # EDI = s + 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 7/r32/EDI 0xc/disp8 . # copy *(EBP+12) to ESI + # EAX = _append-4(out = &s->data[s->write], outend = &s->data[s->length], + # in = &f->data[f->read], inend = &f->data[f->write]) # push &f->data[f->write] - 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # copy *ESI 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 + 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # copy *ESI 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 &f->data[f->read] - 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 + 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] - 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 + 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] - 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 + 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 # call - e8/call _append-4/disp32 + 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 - 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) - # restore registers - 5f/pop-to-EDI - 5e/pop-to-ESI + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32 # add to ESP + # 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) + # restore registers + 5f/pop-to-EDI + 5e/pop-to-ESI $read:end: - # epilog - 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP - 5d/pop-to-EBP - c3/return + # epilog + 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 5d/pop-to-EBP + c3/return ## helpers @@ -119,245 +119,245 @@ $read:end: # Maybe a better helper would be 'empty-stream?' _read: # fd : int, s : (address stream) -> num-bytes-read/EAX - # prolog - 55/push-EBP - 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - # save registers - 51/push-ECX - 52/push-EDX - 53/push-EBX - 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 - 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # copy *ESI to EAX - # 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) + # prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # save registers + 51/push-ECX + 52/push-EDX + 53/push-EBX + 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 + 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # copy *ESI to EAX + # 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) # 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 + 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] - 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 + 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 - 29/subtract 3/mod/direct 2/rm32/EDX . . . 0/r32/EAX . . # subtract EAX from EDX + 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 - 01/add 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # add EAX to *ESI - # restore registers - 5e/pop-to-ESI - 5b/pop-to-EBX - 5a/pop-to-EDX - 59/pop-to-ECX - # epilog - 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP - 5d/pop-to-EBP - c3/return + b8/copy-to-EAX 3/imm32/read + cd/syscall 0x80/imm8 + # 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 + 5b/pop-to-EBX + 5a/pop-to-EDX + 59/pop-to-ECX + # epilog + 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 5d/pop-to-EBP + c3/return - # Two options: - # 1 (what we have above): - # ECX = s - # 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 - # # syscall - # 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 - # and EDX must be used, and EAX must be clobbered anyway). + # Two options: + # 1 (what we have above): + # ECX = s + # 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 + # # syscall + # 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 + # and EDX must be used, and EAX must be clobbered anyway). ## tests test-read-single: - # clear-stream(_test-stream) + # clear-stream(_test-stream) # push args - 68/push _test-stream/imm32 + 68/push _test-stream/imm32 # call - e8/call clear-stream/disp32 + e8/call clear-stream/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # clear-stream(_test-stream-buffer) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # clear-stream(_test-stream-buffer) # push args - 68/push _test-stream-buffer/imm32 + 68/push _test-stream-buffer/imm32 # call - e8/call clear-stream/disp32 + e8/call clear-stream/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # write(_test-stream, "Ab") + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # write(_test-stream, "Ab") # push args - 68/push "Ab"/imm32 - 68/push _test-stream/imm32 + 68/push "Ab"/imm32 + 68/push _test-stream/imm32 # call - e8/call write/disp32 + e8/call write/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # read(_test-stream, _test-stream-buffer) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # read(_test-stream, _test-stream-buffer) # push args - 68/push _test-stream-buffer/imm32 - 68/push _test-stream/imm32 + 68/push _test-stream-buffer/imm32 + 68/push _test-stream/imm32 # call - e8/call read/disp32 + e8/call read/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # check-ints-equal(EAX, 2) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # check-ints-equal(EAX, 2) # push args - 68/push "F - test-read-single: return EAX"/imm32 - 68/push 2/imm32 - 50/push-EAX + 68/push "F - test-read-single: return EAX"/imm32 + 68/push 2/imm32 + 50/push-EAX # call - e8/call check-ints-equal/disp32 + 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) + 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) # push args - 68/push "F - test-read-single"/imm32 - 68/push 0x006241/imm32/Ab + 68/push "F - test-read-single"/imm32 + 68/push 0x006241/imm32/Ab # 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) + b8/copy-to-EAX _test-stream-buffer/imm32 + ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) # call - e8/call check-ints-equal/disp32 + e8/call check-ints-equal/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # end - c3/return + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + # end + c3/return test-read-is-stateful: - ## make two consecutive reads, check that their results are appended - # clear-stream(_test-stream) + ## make two consecutive reads, check that their results are appended + # clear-stream(_test-stream) # push args - 68/push _test-stream/imm32 + 68/push _test-stream/imm32 # call - e8/call clear-stream/disp32 + e8/call clear-stream/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # clear-stream(_test-stream-buffer) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # clear-stream(_test-stream-buffer) # push args - 68/push _test-stream-buffer/imm32 + 68/push _test-stream-buffer/imm32 # call - e8/call clear-stream/disp32 + e8/call clear-stream/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # write(_test-stream, "C") + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # write(_test-stream, "C") # push args - 68/push "C"/imm32 - 68/push _test-stream/imm32 + 68/push "C"/imm32 + 68/push _test-stream/imm32 # call - e8/call write/disp32 + e8/call write/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # read(_test-stream, _test-stream-buffer) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # read(_test-stream, _test-stream-buffer) # push args - 68/push _test-stream-buffer/imm32 - 68/push _test-stream/imm32 + 68/push _test-stream-buffer/imm32 + 68/push _test-stream/imm32 # call - e8/call read/disp32 + e8/call read/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # write(_test-stream, "D") + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # write(_test-stream, "D") # push args - 68/push "D"/imm32 - 68/push _test-stream/imm32 + 68/push "D"/imm32 + 68/push _test-stream/imm32 # call - e8/call write/disp32 + e8/call write/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # read(_test-stream, _test-stream-buffer) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # read(_test-stream, _test-stream-buffer) # push args - 68/push _test-stream-buffer/imm32 - 68/push _test-stream/imm32 + 68/push _test-stream-buffer/imm32 + 68/push _test-stream/imm32 # call - e8/call read/disp32 + 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) + 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) # push args - 68/push "F - test-read-is-stateful"/imm32 - 68/push 0x00004443/imm32/C-D + 68/push "F - test-read-is-stateful"/imm32 + 68/push 0x00004443/imm32/C-D # 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) + b8/copy-to-EAX _test-stream-buffer/imm32 + ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) # call - e8/call check-ints-equal/disp32 + e8/call check-ints-equal/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # end - c3/return + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + # end + c3/return test-read-returns-0-on-end-of-file: - ## read after hitting end-of-file, check that result is 0 - # clear-stream(_test-stream) + ## read after hitting end-of-file, check that result is 0 + # clear-stream(_test-stream) # push args - 68/push _test-stream/imm32 + 68/push _test-stream/imm32 # call - e8/call clear-stream/disp32 + e8/call clear-stream/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # clear-stream(_test-stream-buffer) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # clear-stream(_test-stream-buffer) # push args - 68/push _test-stream-buffer/imm32 + 68/push _test-stream-buffer/imm32 # call - e8/call clear-stream/disp32 + e8/call clear-stream/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # write(_test-stream, "Ab") + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # write(_test-stream, "Ab") # push args - 68/push "Ab"/imm32 - 68/push _test-stream/imm32 + 68/push "Ab"/imm32 + 68/push _test-stream/imm32 # call - e8/call write/disp32 + e8/call write/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - ## first read gets to end-of-file - # read(_test-stream, _test-stream-buffer) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + ## first read gets to end-of-file + # read(_test-stream, _test-stream-buffer) # push args - 68/push _test-stream-buffer/imm32 - 68/push _test-stream/imm32 + 68/push _test-stream-buffer/imm32 + 68/push _test-stream/imm32 # call - e8/call read/disp32 + e8/call read/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - ## second read - # read(_test-stream, _test-stream-buffer) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + ## second read + # read(_test-stream, _test-stream-buffer) # push args - 68/push _test-stream-buffer/imm32 - 68/push _test-stream/imm32 + 68/push _test-stream-buffer/imm32 + 68/push _test-stream/imm32 # call - e8/call read/disp32 + e8/call read/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # check-ints-equal(EAX, 0) + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # check-ints-equal(EAX, 0) # push args - 68/push "F - test-read-returns-0-on-end-of-file"/imm32 - 68/push 0/imm32 - 50/push-EAX + 68/push "F - test-read-returns-0-on-end-of-file"/imm32 + 68/push 0/imm32 + 50/push-EAX # call - e8/call check-ints-equal/disp32 + e8/call check-ints-equal/disp32 # discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # end - c3/return + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + # end + c3/return == data _test-stream-buffer: - # current write index - 00 00 00 00 - # current read index - 00 00 00 00 - # length (= 8) - 08 00 00 00 - # data - 00 00 00 00 00 00 00 00 # 8 bytes + # current write index + 00 00 00 00 + # current read index + 00 00 00 00 + # length (= 8) + 08 00 00 00 + # data + 00 00 00 00 00 00 00 00 # 8 bytes # vim:nowrap:textwidth=0 |