X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=adoc%2Fp_stream.adoc;h=6143ef0f7b15559b7536f2be0da9402f90be2e80;hb=af617c57b198d0b1e55e77ed2e67c57365007f29;hp=37ffb5ae7aa07c8df2b4aa9b03c34c24a39ffc9d;hpb=b7da3f7bbd1cb10241163abdb950472e539e796d;p=rrq%2Frrqforth.git diff --git a/adoc/p_stream.adoc b/adoc/p_stream.adoc index 37ffb5a..6143ef0 100644 --- a/adoc/p_stream.adoc +++ b/adoc/p_stream.adoc @@ -1,9 +1,45 @@ +// stdio.asm: WORD p_stream,'STREAM',fasm + anchor:p_stream[] -Word: STREAM ------------- +=== Word: STREAM +.... +Data stack: ( fd size -- addr ) or ( block -1 -- addr ) +.... + +"STREAM" is a function word that sets up a buffer for an input file +descriptor or for a memory block (of size+data). + +==== File descriptor backed STREAM + +A file descriptor backed STREAM gains a buffer of the given size +prefixed by a 32 byte STREAM header of the following layout: + +==== +.file descriptor stream +[caption='Layout {counter:layout}: '] +---- + 8 bytes = size of buffer (excluding the 32 byte header) + 8 bytes source file descriptor + 8 bytes current fill + 8 current read position +---- +==== + +==== Memory block backed STREAM + +A memory block stream is only the header (though allocated via +<> which reserves a full kernel page) with the +following layout: +==== +.memory block stream +[caption='Layout {counter:layout}: '] ---- -stdio.asm: WORD p_stream,'STREAM',fasm + 8 bytes = block address + 8 -1 (indicates memory block) + 8 size of block (taken from the block's first 8 bytes) + 8 current read position ---- +====