home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / zcpr33 / syslbsrc.lbr / SLPSTR.ZY0 / SLPSTR.ZY0
Text File  |  1989-06-11  |  3KB  |  93 lines

  1. ;    TITLE    "SLPSTR - Syslib 4.0"
  2.     NAME    ('LPSTR')
  3. ;=================================================================
  4. ;   The Libraries, Version 4, (C) 1989 by Alpha Systems Corp.
  5. ;-----------------------------------------------------------------
  6. ; Author  : Harold F. Bower
  7. ;        Derived from SLPSTR.Z80 Richard Conn
  8. ; Date    : 11 Jun 89
  9. ; Version : 1.3
  10. ; Module  : SLPSTR
  11. ; Abstract: This module contains the routine LPSTR which prints
  12. ;    the character string addressed by the HL register pair
  13. ;    to the LST: device until a terminating Null character is
  14. ;    encountered.  The routine returns with HL pointing to
  15. ;    the character immediately after the terminating Null.
  16. ; Revision:
  17. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  18. ; Module Entry Points
  19.  
  20.     PUBLIC        LPSTR
  21.  
  22. ; From SYSLIB Get..
  23.  
  24.     EXT        CLOUT, LOUT
  25.  
  26. ; Definitions
  27.  
  28. BEL    EQU     7        ; Bell
  29. BS    EQU     8        ; Backspace
  30. TAB    EQU     9        ; Tab
  31. LF    EQU    10        ; Line Feed
  32. CR    EQU    13        ; Carriage Return
  33.  
  34.     .Z80
  35.     CSEG
  36. ;===============================================================
  37. ; NAME - LPSTR
  38. ; Entry: HL - Points to a Null-terminated character string
  39. ; Exit : HL - Points to the character after the ending Null
  40. ;         on the LST: device
  41. ; Uses : HL
  42. ; Special Requirements: None
  43. ;===============================================================
  44.  
  45. LPSTR:    PUSH    BC        ; Save the BC register
  46.     PUSH    AF        ; Save Reg A and Flags
  47. PSL0:    LD    C,0        ; Set Position count
  48. PSL:    LD    A,(HL)        ; Get byte
  49.     INC    HL        ; Pt to next
  50.     OR    A        ; 0 = Done
  51.     JR    NZ,GO        ; ..jump if More, else done
  52.     POP    AF        ; Restore All Registers
  53.     POP    BC
  54.     RET
  55.  
  56. GO:    CP    TAB        ; Is it TAB char?
  57.     JR    Z,PST        ; ..jump to Expand if so
  58.  
  59. ;  Print char
  60.  
  61.     INC    C        ; Incr position
  62.     CALL    CLOUT        ; Print with Ctrl Char expansion
  63.     CP    CR        ; Is it CR?
  64.     JR    Z,PSL0        ; ..reset position count and loop if so
  65.     CP    LF        ; Is it LF?
  66.     JR    Z,PLF        ; ..decrement Col Ctr and check if so
  67.     CP    BEL        ; Is it BEL?
  68.     JR    Z,PLF        ; ..decrement Col Ctr and check if so
  69.     CP    BS        ; Is it BS?
  70.     JR    NZ,PSL        ; ..jump to next char if Not
  71.  
  72. ;  <BS> -- Cursor went backward
  73.  
  74. PBS:    DEC    C        ; Adjust count for BS
  75. PLF:    DEC    C        ; Back up 1 for LF and BEL (2 for BS)
  76.     JP    M,PSL0        ; ..jump if BS is first char
  77.     JR    PSL        ; Else get next char
  78.  
  79. ;  Expand <TAB>
  80.  
  81. PST:    LD    A,C        ; Get count
  82.     CPL            ; Get 1's complement
  83.     AND    7        ; .Modulo-8
  84.     INC    A        ; ..and 2's complement
  85.     LD    B,A        ; Set loop counter
  86.     LD    A,' '        ; Print <sp>
  87. PSTL:    CALL    LOUT        ; Print to LST: device
  88.     INC    C        ; ..increment Col count
  89.     DJNZ    PSTL        ; Loop til done
  90.     JR    PSL        ; ..and get next char
  91.  
  92.     END
  93.