h03222
s 00150/00000/00000
d D 1.1 83/03/17 14:37:10 tes 1 0
c date and time created 83/03/17 14:37:10 by tes
e
u
4
U
t
T
I 1
GSX_Code	CSeg	Byte	Public

		Extrn	FGetRec		:Near

; FGetCh	Get next character from file

;	Call FGetCh(FcbPtr,BufferPtr)	{Near PL/M invocation}

; Get the next character from the file, or ^Z and carry set if Eof.

	Public	FGetCh

OldDs		Equ	Ss:(Word Ptr 4)[Bp]
OldBx		Equ	Ss:(Word Ptr 2)[Bp]
OldBp		Equ	Ss:(Word Ptr 0)[Bp]
ReturnAddress	Equ	Ss:(Word Ptr (OldDs+2))[Bp]
BufferPtr	Equ	Ss:(Dword Ptr (ReturnAddress+2))[Bp]
FcbPtr		Equ	Ss:(Dword Ptr (BufferPtr+4))[Bp]

	Include	BStruct.A86

FGetCh:	Push	Ds			; Save caller's registers
	Push	Bx
	Push	Bp			;  & frame
	Mov	Bp,Sp			; Make local frame

	Lds	Bx,FcbPtr		; FPeekCh needs Fcb
	Push	Ds
	Push	Bx
	Lds	Bx,BufferPtr		;  & BufferPtr, too
	Push	Ds
	Push	Bx
	Call	FPeekCh			; Peek at next character

	Inc	Byte Ptr BSBufferPtr[Bx]; Point to next character, i.e. FGetCh

	Pop	Bp			; Restore caller's registers
	Pop	Bx
	Pop	Ds
	Ret	8			;  & return to caller

	Eject

; FPeekCh	Peek at (but don't GetCh) next character in file

;	Call FPeekCh(FcbPtr,BufferPtr)	{Near PL/M invocation}

; Get the next character from the file, but leave the file such that a GetCh
; will re-GetCh the same character.  Used for parse lookahead.

	Public	FPeekCh

FPeekCh:
	Push	Ds			; Save caller's registers
	Push	Bx
	Push	Bp			;  & frame
	Mov	Bp,Sp			; Make local frame

	Lds	Bx,BufferPtr		; Point to buffer structure

	Cmp	Byte Ptr BSBufferPtr[Bx],BSBufferSize; Beyond end of buffer?
	Cmc				; Carry reset means BufPtr<BufSize
	Jnc	PeekChG			; Jump if not beyond end of buffer

	Push	Word Ptr (FcbPtr+2)	; FGetRec needs FcbPtr
	Push	Word Ptr FcbPtr
	Push	Ds			;  & BufferPtr
	Push	Bx
	Call	FGetRec			; Get next record

PeekChG:
	Pushf				; Preserve flags from add
	Add	Bl,Byte Ptr BSBufferPtr[Bx]; Get ptr to next char
	Adc	Bh,0			;  both halves
	Popf				; Restore flags

	Mov	Al,Byte Ptr BSBuffer[Bx]; Get next character

	Pop	Bp			; Restore caller's registers
	Pop	Bx
	Pop	Ds
	Ret	8			;  & return to caller

	Eject

; FSkipBl	While Al is whitespace, GetCh

;	Call FSkipBl(FcbPtr,BufferPtr)	{Near PL/M invocation}

; Starting with the character in Al, skip whitespace and get the next
; non-whitespace character from the file.

	Public	FSkipBl

FSkipBl:
	Push	Ds			; Save caller's registers
	Push	Bx
	Push	Bp			;  & frame
	Mov	Bp,Sp			; Make local frame
	Pushf				; Preserve flags

SkipBlLoop:
	Cmp	Al,' '			; Space?
	Je	SkipBlGetCh		; Jump if must FGetCh
	Cmp	Al,008h			; Tab?
	Jne	SkipBlQuit		; Jump if not whitespace

SkipBlGetCh:
	Popf				; Any FGetCh must affect flags
	Lds	Bx,FcbPtr		; FGetCh needs FcbPtr
	Push	Ds
	Push	Bx
	Lds	Bx,BufferPtr		;  & BufferPtr
	Push	Ds
	Push	Bx
	Call	FGetCh			; Get next character
	Pushf				; Preserve FGetCh flags
	Jmps	SkipBlLoop		;  & loop until not whitespace

SkipBlQuit:
	Popf				; Restore caller's flags
	Pop	Bp			; Restore caller's registers
	Pop	Bx
	Pop	Ds
	Ret	8			;  & return to caller

	Eject

; FUpCase	Upcase the current character

;	Call FUpCase			{Near PL/M invocation}

; Upcase the character in Al.

	Public	FUpCase

FUpCase:
	Pushf				; Save caller's flags
	Cmp	Al,'a'			; Lowercase char?
	Jb	UpCaseQ			; Jump if no
	Cmp	Al,'z'			; Lowercase range?
	Jae	UpCaseQ			; Jump if no

	Sub	Al,'a'-'A'		; UpCase the character in Al

UpCaseQ:
	Popf				; Restore caller's flags
	Ret				;  & return to caller

	End
E 1
