home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / misc / insidcpm.lbr / COSUB.LQB / COSUB.LIB
Encoding:
Text File  |  1985-02-09  |  1.1 KB  |  53 lines

  1. COSUBM    MACRO
  2. ; * * * * *    COSUB.LIB    CONSOLE OUTPUT SUBROUTINES
  3. ;
  4. ;    Subroutine to write [A] to console
  5. ;    alters only [A] and [F]
  6. ;
  7. COUT    EQU    $
  8.     PUSH B ! PUSH D ! PUSH H
  9.     ANI    7FH    ; CP/M expects bit 7 = 0
  10.     MOV    E,A    ; put data where CP/M expects
  11.     MVI    C,2    ; console output function
  12.     CALL    0005H
  13.     POP H ! POP D ! POP B
  14.     RET
  15. ;
  16. ;    Subroutine to write return, linefeed to console
  17. ;    alters no registers
  18. ;
  19. COCRLF    EQU    $
  20.     PUSH    PSW
  21.     MVI    A,CR    ; the return...
  22.     CALL    COUT
  23.     MVI    A,LF    ; ...the line feed
  24.     CALL    COUT
  25.     POP    PSW
  26.     RET
  27. ;
  28. ;    Subroutine to write a space to the console
  29. ;    alters no registers
  30. ;
  31. COSPACE    EQU    $
  32.     PUSH    PSW
  33.     MVI    A,BLANK
  34.     CALL    COUT
  35.     POP    PSW
  36.     RET
  37. ;
  38. ;    Subroutine to write bytes addressed by HL,
  39. ;    up to and including one with bit 7 = 1
  40. ;    alters [A] and [F], steps HL to last byte of string.
  41. ;
  42. COSTR    EQU    $
  43.     MOV    A,M    ; pick up byte to go
  44.     CALL    COUT    ; print it
  45.     MOV    A,M    ; look again, and
  46.     RLC        ; ..check if bit 7
  47.     RC        ; ..return if on
  48.     INX    H    ; else point to next,
  49.     JMP    COSTR    ; ..and continue
  50. ;
  51. ; * * * * *    END OF COSUB.LIB
  52.     ENDM
  53.