home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ZSYS
/
SIMTEL20
/
SYSLIB
/
SLIB2.LBR
/
SEPSTR.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
2KB
|
101 lines
;
; SYSLIB Module Name: SEPSTR
; Author: Richard Conn
; SYSLIB Version Number: 3.6
; Module Version Number: 1.1
public epstr
;
; EPSTR --
; PRINT STRING PTED TO BY HL
; AFFECT ONLY HL -- WHEN DONE, HL PTS TO BYTE AFTER STRING
; PERFORM NO CONTROL CHARACTER EXPANSION EXCEPT FOR <TAB>
; INTERPRET <CR>, <LF>, <BEL>, <BS>
;
EXT COUT
EPSTR:
PUSH DE ; SAVE REGS
PUSH BC
PUSH AF ; SAVE REG A AND FLAGS
LD C,0 ; SET POSITION COUNT
PSL: LD A,(HL) ; GET BYTE
INC HL ; PT TO NEXT
OR A ; 0=DONE
JP Z,PSD
CP TAB ; EXPAND <TAB>
JP Z,PST
;
; PRINT CHAR
;
INC C ; INCR POSITION
CALL COUT ; PRINT IT ON CON:
CP CR ; CHECK FOR <CR>
JP Z,PCR
CP LF ; CHECK FOR <LF>
JP Z,PLF
CP BEL ; CHECK FOR <BEL>
JP Z,PLF
CP BS ; CHECK FOR <BS>
JP Z,PBS
JP PSL
;
; <CR> -- RESET POSITION COUNT
;
PCR: LD C,0 ; RESET
JP PSL
;
; <LF>, <BEL>, <NULL> -- CURSOR DIDN'T ADVANCE
;
PLF: DEC C ; BACK UP COUNT BY 1
JP PSL
;
; <BS> -- CURSOR WENT BACKWARD, MAYBE
;
PBS: LD A,C ; CHECK FOR ZERO
OR A
JP Z,PSL
DEC C ; BACK UP COUNT BY 2
DEC C
JP PSL
;
; EXPAND <TAB>
;
PST: LD A,C ; GET COUNT
AND 7 ; MASK FOR SUB FROM 8
LD B,A ; STORE TEMPORARILY
LD A,8 ; SUBTRACT FROM 8 FOR <SP> COUNT
SUB B
LD B,A ; COUNT IN B
ADD A,C ; ADD TO POSITION COUNT
LD C,A
LD A,' ' ; PRINT <SP>
PSTL: CALL COUT
DEC B ; COUNT DOWN
JP NZ,PSTL
JP PSL
;
; EPSTR DONE
;
PSD: POP AF ; RESTORE REG A AND FLAGS
POP BC ; RESTORE REGS
POP DE
RET
;
; ASCII SPECIAL CHARACTER EQUATES
;
NULL EQU 0 ; NULL
BEL EQU 7 ; BELL
BS EQU 8 ; BACKSPACE
TAB EQU 9 ; TAB
LF EQU 10 ; LINE FEED
CR EQU 13 ; CARRIAGE RETURN
CTRLR EQU 'R'-40H ; CTRL-R
CTRLU EQU 'U'-40H ; CTRL-U
CTRLX EQU 'X'-40H ; CTRL-X
DEL EQU 7FH ; DELETE CHAR
END