home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / cpm68k / msutils.lbr / CD.SQ / CD.S
Encoding:
Text File  |  1988-02-18  |  5.8 KB  |  211 lines

  1. *#######################################################################
  2. *                 Program CD...Change Directory Utility
  3. *
  4. *                         Dr. David C. Wilcox
  5. *                         DCW Industries, Inc.
  6. *                5354 Palm Drive, La Canada, CA  91011
  7. *                            818/790-3844
  8. *
  9. *                          February 14, 1986
  10. *#######################################################################
  11. boot    equ    00        *warm boot
  12. print    equ    09        *print string
  13. current    equ    25        *return current disk
  14. getusr    equ    32        *get/set user
  15. chain    equ    47        *chain to program
  16. tab    equ    09        *horizontal tab
  17. lf    equ    10        *line feed
  18. cr    equ    13        *carriage return
  19. space    equ    32        *ascii space
  20. upmask    equ    $5f        *upper case mask
  21. maxuser    equ    15        *maximum user number
  22. extral    equ    10        *bytes in command leadin
  23. extrat    equ    01        *bytes in command tail
  24. bdos    equ    $0002        *bdos entry point
  25. *#######################################################################
  26. *  User selectable parameter...For consistency, you should change the
  27. *  drive letter specification in the "usage:" message near the end of
  28. *  this program.   It is currently configured for 8 drives, A thru H.
  29. *
  30. ndrives    equ    08        *number of drives in system
  31. *
  32. *#######################################################################
  33. *  Special registers:
  34. *
  35. *    a5 = address of dma buffer
  36. *    a6 = address of 1st parsed FCB
  37. *    d6 = number of characters in chain command string
  38. *#######################################################################
  39. *
  40. *  Locate FCB and DMA (for portability)
  41. *
  42.     link    a6,#0        *mark stack frame
  43.     move.l    8(a6),a0    *get base page address
  44.     lea    $80(a0),a5    *get address of DMA buffer
  45.     lea    $5c(a0),a6    *get address of 1st parsed file name
  46. *
  47. *  Clear data registers
  48. *
  49.     jsr    clear
  50. *
  51. *   Check for no parameters specified
  52. *
  53.     cmpi.b    #space,$1(a6)    *is first character in fcb a space?
  54.     bne    start
  55.     move.l    #usage,d1    *if so, display instructions
  56.     jsr    pstring
  57.     bra    quit        *and return to CP/M
  58. *
  59. *  Get current drive
  60. *
  61. start:    move.w    #current,d0    *get current drive
  62.     trap    #bdos
  63.     addi.b    #'A',d0        *make it ascii
  64.     movea.l    #drive,a0
  65.     move.b    d0,(a0)        *and fill in drivespec for chain command
  66. *
  67. *  Set selected drive
  68. *
  69.     movea.l    a6,a2
  70.     move.b    1(a2),d0    *point to first character in fcb
  71.     addq    #2,a2        *position for subsequent reads
  72.     cmpi.b    #'9',d0    
  73.     ble    digit        *no drive specified
  74.     andi.b    #upmask,d0    *make it upper case
  75.     subi.b    #'A',d0
  76.     blt    baddrv        *illegal character
  77.     cmpi.b    #ndrives,d0
  78.     bge    baddrv        *illegal drive specified
  79.     addi.b    #'A',d0        *it's legit so make it ascii
  80.     movea.l    #drive,a0    *and save it    
  81.     move.b    d0,(a0)
  82. *
  83. *  Set selected user area
  84. *
  85.     move.b    (a2)+,d0
  86.     cmpi.b    #space,d0
  87.     bne    digit
  88.     jsr    udfault        *no user area specified
  89.     bra    chainit
  90. digit:    subi.b    #'0',d0
  91.     blt    badusr        *non-digit
  92.     cmpi.b    #10,d0
  93.     bge    badusr        *non-digit
  94.     move.b    d0,d5        *save it in d5
  95.     addi.b    #'0',d0        *make it ascii again
  96.     movea.l    #user,a0    *point to first digit of user number
  97.     move.b    d0,(a0)     *in chain command string and save it
  98.     move.b    (a2),d0
  99.     cmpi.b    #space,d0
  100.     bne    twodig        *two-digit user so we aren't done yet
  101.     move.l    #extral-1,d2
  102.     bra    chainit
  103. twodig:    subi.b    #'0',d0
  104.     blt    badusr        *non-digit
  105.     cmpi.b    #10,d0
  106.     bge    badusr        *non-digit
  107.     move.b    d0,d4        *save it in d4
  108.     mulu    #10,d5        *multiply tens digit x 10
  109.     add.b    d5,d0        *add to units digit
  110.     cmpi.b    #maxuser,d0    *is it within allowable range?
  111.     bgt    badusr
  112.     addi.b    #'0',d4        *if so, make it ascii and
  113.     movea.l    #user+1,a0    *save it in chain command string
  114.     move.b    d4,(a0)
  115.     move.l    #extral,d2
  116. *
  117. *  Chain to program
  118. *
  119. chainit:
  120.     move.b    d2,d6        *compute total characters in
  121.     addi.b    #extrat,d6    *chain command string
  122.     movea.l    a5,a0        *point to the dma buffer
  123.     move.b    d6,(a0)+    *put total length in first byte
  124.     movea.l    #drive,a1    *transfer chain command string
  125.     jsr    movmem        *including a trailing null
  126.     move.b    #extral,d2    *to the dma buffer
  127.     movea.l    #tail,a1
  128.     jsr    movmem
  129.     move.w    #chain,d0
  130.     trap    #bdos        *and let the bdos do the rest
  131. *#######################################################################
  132. *                           Subroutines
  133. *#######################################################################
  134. *
  135. *  Display drivespec error message
  136. *
  137. baddrv:    move.l    #drvmsg,d1
  138.     jsr    pstring
  139.     bra    quit
  140. *
  141. *  Display userspec error message
  142. *
  143. badusr:    move.l    #usrmsg,d1
  144.     jsr    pstring
  145.     bra    quit
  146. *
  147. *  Clear data registers
  148. *
  149. clear:    clr.l    d0
  150.     clr.l    d1
  151.     clr.l    d2
  152.     clr.l    d3
  153.     clr.l    d4
  154.     clr.l    d5
  155.     clr.l    d6
  156.     clr.l    d7
  157.     rts
  158. *
  159. *  Move d2 bytes from a1 to a0
  160. *
  161. movmem:    move.b    (a1)+,(a0)+
  162.     subq    #1,d2
  163.     bne    movmem
  164.     rts
  165. *
  166. *  Display string on console
  167. *
  168. pstring:
  169.     move.w    #print,d0
  170.     trap    #bdos
  171.     rts
  172. *
  173. *  Return to CP/M
  174. *
  175. quit:    move.w    #boot,d0
  176.     trap    #bdos
  177. *
  178. *  Put default user number in chain command string
  179. *
  180. udfault:
  181.     move.w    #$ff,d1        *get current user
  182.     move.w    #getusr,d0
  183.     trap    #bdos
  184.     move.b    d0,d5        *save it in d5
  185.     subi.b    #10,d0        *subtract 10
  186.     blt    unit        *negative => single digit user
  187.     addi.b    #'0',d0        *make it ascii
  188.     movea.l    #user+1,a2
  189.     move.b    d0,(a2)        *save it
  190.     move.b    #'1',-(a2)    *put a one in tens digit
  191.     move.b    #extral,d2    *set the string length counter
  192.     rts
  193. unit:    addi.b    #'0',d5        *make user number ascii
  194.     movea.l    #user,a2    *save it
  195.     move.b    d5,(a2)
  196.     move.l    #extral-1,d2    *set the string length counter
  197.     rts
  198. *#######################################################################
  199. drive:    dc.b    0
  200.     dc.b    ':!USER '
  201. user:    dc.b    0,0
  202. tail:    dc.b    0
  203. drvmsg:    dc.b    lf,cr,'Illegal drive specification',lf,cr,'$'
  204. usrmsg:    dc.b    lf,cr,'Illegal user specification',lf,cr,'$'
  205. usage:    dc.b    tab,'Correct usage:',tab,tab,'cd  {drive}{user}',lf,cr
  206.     dc.b    lf,cr,tab,tab,'drive = letter  between A and H'
  207.     dc.b    lf,cr,tab,tab,'user  = integer between 0 and 15'
  208.     dc.b    lf,cr,lf,cr,'$'
  209. *#######################################################################
  210.     end
  211.