home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / GENASM / CARRY12.AQM / CARRY12.ASM
Assembly Source File  |  2000-06-30  |  6KB  |  238 lines

  1. ;       CARRY.ASM ver 1.2
  2. ;       (revised 6/24/81)
  3. ;    by Keith Petersen, W8SDZ
  4. ;
  5. ;This program runs up in high RAM.  It gets there
  6. ;by being moved there when CARRY <program name>
  7. ;is typed.
  8. ;
  9. ;The program in high RAM does the following:
  10. ;
  11. ;Loads and executes a .COM file named in command line,
  12. ;but first waits for the user to change disks.
  13. ;Arguements after requested .COM file name are passed
  14. ;to the executed program, thus making it possible to
  15. ;run ED or Wordmaster.
  16. ;
  17. ;Why this is useful: Users of single-drive systems
  18. ;may not have room for ED, WM, ASM, LOAD, or other
  19. ;such programs on their "work" disk.  This program
  20. ;makes it possible to change disks, get the editor
  21. ;assembler or loader, then change disks again.  CARRY
  22. ;must be on the same disk with the COM file it is to
  23. ;get.
  24. ;
  25. ;Command:  CARRY ED MYFILE.ASM
  26. ;    (gets ED.COM to edit MYFILE.ASM)
  27. ;
  28. ;Fixes/updates (in reverse order to minimize reading time):
  29. ;
  30. ;06/24/81 Added more documentation about ENDMARK. (KBP)
  31. ;
  32. ;NOTE: If you add improvements or otherwise update
  33. ;this program, please modem a copy of the new file
  34. ;to "TECHNICAL CBBS" in Dearborn, Michigan - phone
  35. ;313-846-6127 (110, 300, 450 or 600 baud).  Use the
  36. ;filename CARRYXX.NEW where XX is the new version nr.
  37. ;------------------------------------------------
  38. ;
  39. ;A marker has been placed at the end of this file to
  40. ;deliberately print an error message during assembly
  41. ;in order to determine the actual ending address of
  42. ;the program.  The error message will not affect the
  43. ;assembly.  Make sure you have free memory available
  44. ;up to the address shown.
  45. ;
  46. ;Change the following equate to an area in your
  47. ;high memory where this program may patch itself in.
  48. ;This may be below BDOS, provided that sufficient
  49. ;space is available below CARRY to load the requested
  50. ;COM file.
  51. ;
  52. DEST    EQU    0FA00H    ;RUNNING LOCATION OF CODE
  53. ;
  54. ;------------------------------------------------
  55. ;
  56. BASE    EQU    0    ;PUT 4200H HERE FOR ALTERNATE CP/M
  57. ;
  58. PRINT    EQU    9
  59. OPEN    EQU    15
  60. STDMA    EQU    26
  61. BDOS    EQU    BASE+5
  62. FCB    EQU    BASE+5CH 
  63. FCBEXT    EQU    FCB+12
  64. FCB2    EQU    BASE+6CH
  65. ;
  66. CR    EQU    0DH
  67. LF    EQU    0AH
  68. ;
  69.     ORG    BASE+100H
  70. ;
  71. ;Move the program up to high RAM and jump to it.
  72. ;
  73. MOVEUP:    LXI    B,PEND-START+1        ;NUMBER OF BYTES TO MOVE
  74.     LXI    H,DEST+PEND-START+1    ;END OF MOVED CODE
  75.     LXI    D,SOURCE+PEND-START    ;END OF SOURCE CODE
  76. ;
  77. MVLP:    LDAX    D    ;GET BYTE
  78.     DCX    H    ;BUMP POINTERS
  79.     MOV    M,A    ;NEW HOME
  80.     DCX    D
  81.     DCX    B    ;BUMP BYTE COUNT
  82.     MOV    A,B    ;CHECK IF ZERO
  83.     ORA    C
  84.     JNZ    MVLP    ;IF NOT, DO SOME MORE
  85.     PCHL        ;JUMP TO "START"
  86. ;
  87. SOURCE    EQU    $    ;BOUNDARY MEMORY MARKER
  88. ;
  89. OFFSET    EQU    DEST-SOURCE    ;RELOC AMOUNT
  90. ;-----------------------------------------------;
  91. ;    The following code gets moved        ;
  92. ;    to high RAM located at "DEST",        ;
  93. ;        where it is executed.        ;
  94. ;-----------------------------------------------;
  95. ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  96. ;XX   C A U T I O N :  If modifying anything     XX
  97. ;XX     in this program from here on:         XX
  98. ;XX      A-L-L labels must be of the form:    XX
  99. ;XX    LABEL    EQU    $+OFFSET        XX
  100. ;XX    in order that the relocation to high    XX
  101. ;XX    RAM work successfully.  Forgetting to    XX
  102. ;XX    specify '$+OFFSET' will cause the pro-    XX
  103. ;XX    gram to JMP into whatever is currently    XX
  104. ;XX    in low memory, with unpredictable    XX
  105. ;XX    results.  Be careful....        XX
  106. ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  107. ;
  108. START    EQU    $+OFFSET
  109.     LXI    SP,STACK ;SET UP LOCAL STACK POINTER
  110. ;Move requested file name to our FCB
  111.     LXI    H,FCB    ;SOURCE
  112.     LXI    D,MYFCB    ;DESTINATION
  113.     MVI    B,9    ;LENGTH
  114.     CALL    MOVE    ;MOVE THE NAME
  115. ;Move arguement to default FCB
  116.     LXI    H,FCB2    ;SOURCE
  117.     LXI    D,FCB    ;DESTINATION
  118.     MVI    B,13    ;LENGTH
  119.     CALL    MOVE    ;MOVE THE NAME
  120. ;Clear FCB2 and initialize our FCB
  121.     MVI    A,' '
  122.     STA    FCB2+1
  123.     XRA    A
  124.     STA    FCB2
  125.     STA    FCBEXT
  126.     STA    MYFCB+32
  127. ;Set DMA address to 80H
  128.     LXI    D,BASE+80H
  129.     MVI    C,STDMA
  130.     CALL    BDOS
  131. ;Open the file
  132.     LXI    D,MYFCB
  133.     MVI    C,OPEN
  134.     CALL    BDOS
  135. ;Did it exist?
  136.     INR    A    ;A=> 0 MEANS "NO"
  137.     JZ    BYERR    ;NO FILE, EXIT ERROR MSG
  138. ;
  139. OPENOK    EQU    $+OFFSET
  140.     LXI    D,BASE+100H    ;POINT TO TPA
  141. ;
  142. READLP    EQU    $+OFFSET
  143.     PUSH    D    ;SAVE BUFFER ADDRESS
  144.     PUSH    B
  145.     PUSH    H
  146.     MVI    C,STDMA
  147.     CALL    BDOS
  148. ;Read a sector
  149.     LXI    D,MYFCB
  150.     MVI    C,20    ;READ
  151.     CALL    BDOS
  152.     POP    H
  153.     POP    B
  154.     ORA    A    ;OK?
  155.     JNZ    EOF    ;NOT OK, MUST BE EOF
  156.     POP    D    ;GET DMA ADDR
  157.     LXI    H,80H    ;LENGTH OF 1 SECT.
  158.     DAD    D    ;CALC NEXT BUFF ADDR
  159.     XCHG        ;PUT IT BACK IN DE
  160.     JMP    READLP    ;LOOP
  161. ;
  162. ;Got return code on read, see if error or EOF
  163. ;
  164. EOF    EQU    $+OFFSET
  165.     POP    D    ;DELETE STACKED BUFFER ADDR
  166. ;A has return code from read
  167.     DCR    A    ;EOF?
  168.     JZ    RSDMA    ;YES, EXIT
  169. ;
  170. ;Read error - exit with message
  171. BYERR    EQU    $+OFFSET
  172.     CALL    ERXIT    ;PRINT:
  173.     DB    CR,LF,'++DISK READ ERROR or FILE NOT FOUND++',CR,LF,'$'
  174. ;
  175. ;Exit with error message
  176. ERXIT    EQU    $+OFFSET
  177.     POP    D
  178.     MVI    C,9    ;PRINT ERROR MESSAGE
  179.     CALL    BDOS
  180. ;
  181. ERXIT2    EQU    $+OFFSET
  182.     XRA    A
  183.     STA    BASE+4    ;SET DRIVE A:, USER 0
  184.     JMP    BASE
  185. ;
  186. ;Reset DMA address to normal
  187. RSDMA    EQU    $+OFFSET
  188.     LXI    D,BASE+80H
  189.     MVI    C,STDMA
  190.     CALL    BDOS
  191. ;
  192. REASK    EQU    $+OFFSET
  193.     LXI    D,RDYMSG
  194.     MVI    C,9    ;PRINT READY MESSAGE
  195.     CALL    BDOS
  196.     MVI    C,1    ;GET CONSOLE CHAR.
  197.     CALL    BDOS
  198.     CPI    'C'-40H    ;CTL-C?
  199.     JZ    ERXIT2    ;YES, EXIT
  200.     CPI    CR    ;CARRIAGE RETURN?
  201.     JNZ    REASK
  202. ;
  203.     MVI    C,13    ;RESET DISK SYSTEM
  204.     CALL    BDOS
  205. ;
  206. ;Leave warm boot address on stack, them execute file
  207.     LXI    H,BASE+0
  208.     PUSH    H
  209.     JMP    BASE+100H    ;EXECUTE PROGRAM
  210. ;
  211. ;Move (HL) to (DE), length in (B)
  212. ;
  213. MOVE    EQU    $+OFFSET
  214.     MOV    A,M    ;GET A BYTE
  215.     STAX    D    ;PUT AT NEW HOME
  216.     INX    D    ;BUMP POINTERS
  217.     INX    H
  218.     DCR    B    ;DEC BYTE COUNT
  219.     JNZ    MOVE    ;IF MORE, DO IT
  220.     RET        ;IF NOT,RETURN
  221. ;
  222. RDYMSG    EQU    $+OFFSET
  223.     DB    CR,LF,'CHANGE DISKS THEN PRESS RETURN '
  224.     DB    'TO CONTINUE (CTL-C ABORTS) > $'
  225. ;
  226. MYFCB    EQU    $+OFFSET
  227.     DB    0,'        COM',0
  228. ;
  229. PEND    EQU    $+OFFSET ;END OF RELOCATED CODE
  230. ;
  231.     DS    20    ;ROOM FOR OUR FCB
  232.     DS    40    ;ROOM FOR OUR STACK
  233. STACK    EQU    $+OFFSET ;LOCAL STACK
  234. ;
  235. ENDMARK    EQU    $+OFFSET ;! IGNORE ERROR. THIS MARKS END OF PGM
  236. ;
  237.     END
  238.