; TITLE "SEPSTR - Syslib 4.0" NAME ('EPSTR') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SEPSTR.Z80 Ver 1.1 by Richard Conn ; Date : 11 Jun 89 ; Version : 1.3 ; Module : SEPSTR ; Abstract: This module contains the routine EPSTR which prints ; the Null-terminated character string addressed by an ; internal register to the CON: device until the Null is ; encountered. The routine returns the address of the ; character immediately following the Null. No control- ; character interpretation is performed except for TAB ; expansion, Carriage Return, Line Feed, Bell and Backspace. ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC EPSTR ; From SYSLIB Get.. EXT COUT ; Definitions BEL EQU 7 ; Bell BS EQU 8 ; Backspace TAB EQU 9 ; Tab LF EQU 10 ; Line Feed CR EQU 13 ; Carriage Return .Z80 CSEG ;=============================================================== ; NAME - EPSTR ; Entry: HL - Points to a Null-terminated character string ; Exit : HL - Points to the character following the Null ; Uses : HL ; Special Requirements: None ;=============================================================== EPSTR: PUSH BC ; Save Regs PUSH AF ; Save Reg A and Flags PSL0: LD C,0 ; Set position count PSL: LD A,(HL) ; Get byte INC HL ; Pt to next OR A ; 0 = Done JR NZ,GO ; ..jump if Not, else done POP AF ; Restore Reg A and Flags POP BC ; Restore Regs RET GO: CP TAB ; Is it TAB? JR Z,PST ; ..jump to expand if so ; Print Char INC C ; Incr position CALL COUT ; Print it on CON: CP CR ; Is it CR? JR Z,PSL0 ; ..reset position counter and loop if so CP LF ; Is it LF? JR Z,PLF ; ..dec ctr and check if so CP BEL ; Is it BEL? JR Z,PLF ; ..dec ctr and check if so CP BS ; Is it BS? JR NZ,PSL ; ..loop for next char if Not ; -- Cursor went backward, maybe PBS: DEC C ; Back up count by 2 if BS PLF: DEC C ; Back up by 1 for & JP M,PSL0 ; ..reset counter if BS first char JR PSL ; Else get next char ; Expand PST: LD A,C ; Get count CPL ; 1's complement AND 7 ; Modulo-8 INC A ; Make 2's complement LD B,A ; Count in B LD A,' ' ; Print PSTL: CALL COUT INC C ; Increment Col count DJNZ PSTL ; Count down JR PSL END