home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / cpm68k / msutils.lbr / PRINT.SQ / PRINT.S
Encoding:
Text File  |  1988-02-18  |  4.1 KB  |  132 lines

  1. *#######################################################################
  2. *         PROGRAM PRINT...CP/M 68k Print Utility
  3. *                ======================================
  4. *                  This program first chains to PIP to
  5. *                  print the  specified  file and then
  6. *                  to program  T to send a formfeed to
  7. *                             the printer.
  8. *                ======================================
  9. *
  10. *                         Dr. David C. Wilcox
  11. *                         DCW Industries, Inc.
  12. *                5354 Palm Drive, La Canada, CA  91011
  13. *                            818/790-3844
  14. *
  15. *                           August 1, 1985
  16. *#######################################################################
  17. boot    equ    00        *warm boot
  18. print    equ    09        *print string
  19. chain    equ    47        *chain to program
  20. lf    equ    10        *line feed
  21. cr    equ    13        *carriage return
  22. space    equ    32        *ascii space
  23. extral    equ    11        *bytes in command leadin
  24. extrat    equ    07        *bytes in command tail
  25. bdos    equ    $0002        *BDOS entry point
  26. *#######################################################################
  27. *
  28. *  Special registers:
  29. *
  30. *    a4 = address of 1st parsed FCB
  31. *    a5 = address of DMA buffer
  32. *    d5 = number of characters in input file name
  33. *    d6 = total characters in chain command (d5+extral+extrat)
  34. *
  35. *#######################################################################
  36. *
  37. *  Locate FCB and DMA (for portability)
  38. *
  39.     link    a6,#0        *mark stack frame
  40.     move.l    8(a6),a0    *get base page address
  41.     lea    $5c(a0),a4    *get address of 1st parsed file name
  42.     lea    $80(a0),a5    *get address of DMA buffer
  43.     clr.l    d2        *make sure d2 is empty
  44. *
  45. *  Check for no file specified
  46. *
  47.     cmpi.b    #space,$1(a4)
  48.     bne    start
  49.     move.l    #usage,d1    *if no parameters...
  50.     move.w    #print,d0    *display instructions
  51.     trap    #bdos
  52.     jsr    quit        *and exit to CP/M
  53. *
  54. *  Determine number of characters in file name and add
  55. *  'extral' and 'extrat' for chain command string count
  56. *
  57. start:    movea.l    a5,a1        *point to DMA
  58.     move.b    (a1)+,d6    *put total characters in d6
  59.     move.b    d6,d2        *transfer to d2 which will be counter
  60.     addi    #extral,d6    *adjust for command leadin
  61.     addi    #extrat,d6    *adjust for command tail
  62. *
  63. *  Save file name at 'source'
  64. *
  65.     clr.l    d5        *make sure d5 is empty
  66.     movea.l    #source,a0    *get the source file name
  67. sfile:    move.b    (a1)+,(a0)+
  68.     addq    #1,d5
  69.     subq    #1,d2        *make sure we're not out of characters
  70.     blt    error        *before we find the null
  71.     cmpi.b    #0,(a1)
  72.     bne    sfile
  73. *
  74. *  Copy command string count and command leadin to DMA
  75. *
  76.     movea.l    a5,a0        *point to the DMA
  77.     move.b    d6,(a0)+    *put character count in first byte
  78.     move.w    #extral,d2    *prepare to move 'extral' bytes
  79.     movea.l    #leadin,a1    *point to command leadin
  80.     jsr    movmem        *and copy to DMA
  81. *
  82. *  Copy source file name to DMA
  83. *
  84.     move.b    d5,d2        *retrieve number of chars in file name
  85.     movea.l    #source,a1    *point to source file name
  86.     jsr    movmem        *and copy to DMA
  87. *
  88. *  Copy command tail and concluding null to DMA
  89. *
  90.     move.b    #extrat,d2    *prepare to move 'extrat' bytes
  91.     movea.l    #tail,a1    *now add the command tail
  92.     jsr    movmem        *and copy to DMA
  93.     move.b    #0,(a0)        *conclude with a null
  94. *
  95. *  Invoke the chain command
  96. *
  97.     move.w    #chain,d0    *now let PIP do the rest
  98.     trap    #bdos
  99. *#######################################################################
  100. *               Subroutines
  101. *#######################################################################
  102. *
  103. *  Quit to CP/M
  104. *
  105. quit:    move.w    #boot,d0
  106.     trap    #bdos
  107. *
  108. *  Report file error
  109. *
  110. error:    move.l    #errmsg,d1
  111.     move.w    #print,d0
  112.     trap    #bdos
  113.     bra    quit
  114. *
  115. *  Move d2 bytes from a1 to a0
  116. *
  117. movmem:    move.b    (a1)+,(a0)+
  118.     subq    #1,d2
  119.     bne    movmem
  120.     rts
  121. *#######################################################################
  122. *                     Messages and storage area
  123. *#######################################################################
  124. source:    ds.b    32
  125. usage:    dc.b    lf,cr,'Correct usage:    PRINT <d:>filename'
  126.     dc.b    lf,cr,lf,cr,'$'
  127. errmsg:    dc.b    'File name error...PRINT aborted',cr,lf,'$'
  128. leadin:    dc.b    'A:PIP LST:='
  129. tail:    dc.b    '[RT8]!T'
  130. *#######################################################################
  131.     end
  132.