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

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