getc: don't clobber AH; return CF=1, AL=0 on end of file
authorH. Peter Anvin <hpa@zytor.com>
Tue, 12 Feb 2008 23:48:25 +0000 (15:48 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 12 Feb 2008 23:48:25 +0000 (15:48 -0800)
Don't clobber AH when calling getc; when returning with CF=1 (EOF),
always return with AL=0.

getc.inc

index 4a9d243..275c0fa 100644 (file)
--- a/getc.inc
+++ b/getc.inc
@@ -100,8 +100,9 @@ getc:
                and bx,bx
                jnz .have_unget
 
-               mov ax,real_mode_seg    ; Borrow the real_mode_seg
-               mov es,ax
+               mov si,real_mode_seg    ; Borrow the real_mode_seg
+               mov es,si
+
 .got_data:
                sub word [di+gc_bufbytes],1
                jc .get_data            ; Was it zero already?
@@ -154,6 +155,7 @@ getc:
                ; to read the file.
                mov [di+gc_bufbytes],cx
                popad
+               xor al,al               ; Return a predictable zero
                stc
                jmp .ret