getc: add "readc" function to do block reads
authorH. Peter Anvin <hpa@zytor.com>
Mon, 14 Jul 2008 19:43:50 +0000 (12:43 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Mon, 14 Jul 2008 19:43:50 +0000 (12:43 -0700)
Add "readc" function to do block reads.  Currently it just does a loop
around "call getc/stosb".

core/getc.inc

index b36115c..ec8dab2 100644 (file)
@@ -151,6 +151,26 @@ getc:
                stc
                jmp .ret
 
+;
+; This is similar to getc, except that we read up to CX bytes and
+; store them in ES:DI.  Eventually this could get optimized...
+;
+; On return, CX and DI are adjusted by the number of bytes actually read.
+;
+readc:
+               push ax
+.loop:
+               call getc
+               jc .out
+               stosb
+               loop .loop
+.out:
+               pop ax
+               ret
+
+;
+; close: close the top of the getc stack
+;
 close:
                push bx
                push si