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
/
TEXT.SRC
< prev
next >
Wrap
Text File
|
1999-04-05
|
3KB
|
104 lines
;MANIPULATE A TEXT BUFFER AND ASSOCIATED POINTERS
;
NAME TEXT
ENTRY .TIN,.TXTIN,.TOUT,.TXTYP
EXT .POPHDB,.CO,.PUSHBD
INCLUDE DEFLT.SRC
;
;
;THE .TIN, .TXTIN, AND .TOUT ROU.TINES MANIPULATE A TEXT BUFFER AND
;THEIR ASSOCIATED POINTERS. THE BUFFER RESIDES IN THE TOP OF THE
;TPA.
;EACH CALL TO .TIN RETURNS THE NEXT CHARACTER IN THE TEXT BUFFER.
;A CARRAIGE RETURN IS PASSED TO INDICATE END OF LINE. A CPI 20H
;IS DONE BEFORE CONTROL IS RETURNED TO THE CALLING PROGRAM. THUS,
;Z IS TRUE IF THE CHARACTER IS A SPACE AND M AND C ARE TRUE IF
;THE RETURNED CHARACTER IS A CONTROL CHARACTER. THE CHARACTER IS
;RETURNED IN A.
.TIN CALL .PUSHBD ;SAVE ALL REGISTERS EXCEPT A
LHLD 6 ; HL POINTS TO TOP OF TPA + 1.
LXI D,-GETP
DAD D
PUSH H ; Save pointer to text_in_pointer.
MOV E,M
MVI D,0
DAD D ; HL points to next character to read - 1.
INX H
MOV A,M
POP H
CPI ' ' ; Test for end of line.
JRC ENDL
INR M
CPI ' '
EN: JMP .POPHDB
ENDL INX H ; HL POINTS TO LAST CHARACTER POINTER.
MVI M,0 ; MAKE IT 1 FOR FUTURE .TOUT CALLS.
JMPR EN
;.TXTIN READS A LINE INTO THE TEXT BUFFER AND SETS THE TEXT IN
;POINTER TO THE FIRST CHARACTER (TEXT IN POINTER := 1).
.TXTIN CALL .PUSHBD ;SAVE ALL REGISTERS EXCEPT A
LHLD 6
LXI D,-GETP
DAD D ; HL POINTS TO START OF TEXT BUFFER.
MVI M,BUFLEN-1 ; TELL CP/M THE MAXIMUM # OF CHARS TO READ.
XCHG
MVI C,10 ; CP/M CODE TO READ A LINE.
CPM
MVI C,CR
CALL .TOUT
MVI C,LF
CALL .CO
JMP .POPHDB
;.TOUT STUFFS THE CHARACTER PASSED IN C INTO THE TEXT BUFFER. THE CARRY IS
;SET IFF THE BUFFER IS FULL. THE TEXT_IN_POINT IS RESET TO THE FIRST
;CHARACTER ON EVERY CALL.
.TOUT CALL .PUSHBD ;SAVE ALL REGISTERS EXCEPT A
PUSH PSW
LHLD 6
LXI D,-GETP
DAD D ; HL POINTS TO THE TEXT_IN_POINTER.
MVI M,1 ; TEXT_IN_POINTER := 1
INX H
MOV A,M ; A := TEXT_FILL_POINTER
CPI BUFLEN
JRZ BFULL ; BRANCH IF BUFFER IS FULL.
INR M ; TEXT_FILL_POINTER := TEXT_FILL_POINTER + 1
MOV E,M
MVI D,0
DAD D ; HL POINTS TO SLOT FOR CHARACTER IN C.
MOV M,C ; STUFF IT.
POP PSW
ORA A
JMP .POPHDB
BFULL DCR M ; Make it work.
MVI C,CR ; Put CR at end of text buffer.
CALL .TOUT ; Watch out, here's Recursive Robert.
POP PSW
STC
JMP .POPHDB
;.TXTYP WRITES THE STRING OF CHARACTERS POINTED TO BY HL TO THE CONSOLE.
;A NULL OR A CHARACTER WITH ITS MSB SET MARKS THE END OF THE STRING.
.TXTYP MOV A,M
ORA A
RZ
PUSH PSW
ANI 7FH
MOV C,A
CALL .CO
POP PSW
RM
INX H
JMPR .TXTYP
;