home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
norge.freeshell.org (192.94.73.8)
/
192.94.73.8.tar
/
192.94.73.8
/
pub
/
computers
/
cpm
/
alphatronic
/
PASCALZ4.ZIP
/
D3
/
EOFLN.SRC
< prev
next >
Wrap
Text File
|
1999-04-05
|
2KB
|
86 lines
;ROUTINES FOR EOLN,EOF,AND FOR FILLING THE TXTIN BUFFER
;
NAME EOFLN
ENTRY .EOLN,.EOF,.FTXTIN,L120,L121,L124
EXT .TOUT,.TIN,.MTRUE,.MTRU1,.FALSE
INCLUDE DEFLT.SRC
;
;EOLN RETURNS THE CARRY SET IF THE END OF LINE FLAG IN THE BUFFER
;IS SET AND RETURNS THE CARRY RESET IF IT ISN'T. IT EXPECTS HL TO CONTAIN
;THE FILE BUFFER ADDRESS.
;MUST BE CALLED WITH A 0
;EOLN( 0 ) IS DEFINED AS EOLN ON THE CONSOLE
;EOLN MUST PRESERVE REGISTERS BECAUSE IT IS CALLED BY INPUT ROUTINES
L120:
.EOLN: XRA A
PUSH H
CMP H ;CHECK FOR CONSOLE POINTER
JRNZ FEOLN ;NO...CHECK FILE EOLN
CONLN: PUSH D
LHLD 6
LXI D,-PUTP
DAD D
MOV A,M ; A := fill pointer.
DCX H
CMP M ; fill pointer - text_in_pointer
JC .MTRU1 ; Branch if end of line.
MOV E,M
MVI D,0
DAD D
INX H ; HL points to next character to read.
MOV A,M
CPI CR ; EOLN is also true if we about to read a CR.
JZ .MTRU1
POP D
POP H
JMP .FALSE
FEOLN:
BIT 7,M ;IS THIS A 'CON:' CONSOLE FILE VARIABLE
JRNZ CONLN ; YES, TEST AS A CONSOLE FILE
BIT 0,M ;TEST EOLN FLAG, BIT 0 OF BYTE 1 OF BUFFER
POP H
JZ .FALSE
JMP .MTRUE
;EOF RETURNS THE CARRY SET IF END OF FILE IS TRUE AND RESET IF IT IS
;FALSE. IT EXPECTS HL TO CONTAIN THE BUFFER ADDRESS.
;A REG MUST BE 0
L121:
.EOF: XRA A
CMP H ;FOR CONSOLE FILES END OF FILE IS ALWAYS FALSE
JZ .FALSE
BIT 7,M ;IS THIS A 'CON:' CONSOLE FILE
JNZ .FALSE ;YES, CONSOLE EOF IS ALWAYS FALSE
BIT 1,M ;EOF FLAG,BIT 1 OF BYTE 1 OF BUFFER
JNZ .MTRUE
JMP .FALSE
;FTXTIN ALLOWS THE USER TO FILL THE PASCAL TXTIN BUFFER
L124:
.FTXTIN: MOV H,A ;SET HL TO LENGTH OF STRING+1
MOV L,C
INX H
DAD SP ;POINT TO STRING
PUSH H ;SAVE THIS POINTER
MOV B,C ;MOVE COUNT TO B-REGISTER
FTXT2: CALL .TIN ;FIRST EMPTY THE BUFFER
CPI CR
JRNZ FTXT2
FTXT3: MOV C,M ;GET CHAR
CALL .TOUT
DCX H ;BUMP POINTER
DJNZ FTXT3 ;CHECK FOR MORE
MVI C,CR
CALL .TOUT ;ADD A CR
POP H
POP D ;GET RETURN ADDRESS
INX H ;FIX STACK
SPHL
XRA A
XCHG ;AND...
PCHL ;...RETURN