; TITLE "SLPSTR - Syslib 4.0" NAME ('LPSTR') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SLPSTR.Z80 Richard Conn ; Date : 11 Jun 89 ; Version : 1.3 ; Module : SLPSTR ; Abstract: This module contains the routine LPSTR which prints ; the character string addressed by the HL register pair ; to the LST: device until a terminating Null character is ; encountered. The routine returns with HL pointing to ; the character immediately after the terminating Null. ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC LPSTR ; From SYSLIB Get.. EXT CLOUT, LOUT ; 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 - LPSTR ; Entry: HL - Points to a Null-terminated character string ; Exit : HL - Points to the character after the ending Null ; on the LST: device ; Uses : HL ; Special Requirements: None ;=============================================================== LPSTR: PUSH BC ; Save the BC register 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 More, else done POP AF ; Restore All Registers POP BC RET GO: CP TAB ; Is it TAB char? JR Z,PST ; ..jump to Expand if so ; Print char INC C ; Incr position CALL CLOUT ; Print with Ctrl Char expansion CP CR ; Is it CR? JR Z,PSL0 ; ..reset position count and loop if so CP LF ; Is it LF? JR Z,PLF ; ..decrement Col Ctr and check if so CP BEL ; Is it BEL? JR Z,PLF ; ..decrement Col Ctr and check if so CP BS ; Is it BS? JR NZ,PSL ; ..jump to next char if Not ; -- Cursor went backward PBS: DEC C ; Adjust count for BS PLF: DEC C ; Back up 1 for LF and BEL (2 for BS) JP M,PSL0 ; ..jump if BS is first char JR PSL ; Else get next char ; Expand PST: LD A,C ; Get count CPL ; Get 1's complement AND 7 ; .Modulo-8 INC A ; ..and 2's complement LD B,A ; Set loop counter LD A,' ' ; Print PSTL: CALL LOUT ; Print to LST: device INC C ; ..increment Col count DJNZ PSTL ; Loop til done JR PSL ; ..and get next char END