From 83822d63240cc4d03d00133719993f5e4b2c281f Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 3 Dec 2018 17:08:04 -0800 Subject: 4828 - writing to buffered-file This is likely a sub-optimal interface, but I'm trying not to agonize. The whole point of Mu is to permit radical changes at any point in time. --- subx/059read-byte.subx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'subx/059read-byte.subx') diff --git a/subx/059read-byte.subx b/subx/059read-byte.subx index 07958a63..305bcbb8 100644 --- a/subx/059read-byte.subx +++ b/subx/059read-byte.subx @@ -53,10 +53,9 @@ read-byte: # f : (address buffered-file) -> byte-or-eof/EAX 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI # ECX = f->read 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 8/disp8 . # copy *(ESI+8) to ECX - # if (f->read < f->write) read byte from stream + # if (f->read >= f->write) populate stream from file 3b/compare 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 . # compare ECX with *(ESI+4) 7c/jump-if-lesser $read-byte:from-stream/disp8 - # otherwise first populate stream from file # . clear-stream(stream = f+4) # . . push args 8d/copy-address 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 . # copy ESI+4 to EAX @@ -79,7 +78,7 @@ read-byte: # f : (address buffered-file) -> byte-or-eof/EAX b8/copy-to-EAX 0xffffffff/imm32 eb/jump $read-byte:end/disp8 $read-byte:from-stream: - # reading from stream + # read byte from stream # AL = f->data[f->read] 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . . # clear EAX 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0x10/disp8 . # copy *(ESI+ECX+16) to AL -- cgit 1.4.1-2-gfad0