You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

288 lines
5.9KB

  1. .PAGE 'UTLODR'
  2. ;********************************
  3. ;*UTLODR-UTILITY LOADER USED TO
  4. ; LOAD USER PROGRAMS OR SYSTEM
  5. ; UTILITIES FROM DISK AND
  6. ; EXECUTE THEM.
  7. ;
  8. ; THIS LOADER IS DESIGNED TO BE
  9. ; INCORPORATED INTO THE 1540 DOS
  10. ; SYSTEM (SERIAL BUS INTERFACE).
  11. ;
  12. ; HARDWARE REQIRED :
  13. ; CONNECT DATA AND CLOCK LINE TO
  14. ; GROUND. (2-4-5 ON CONNECTOR)
  15. ;
  16. ;********************************
  17. ;*ON ENTRY-
  18. ; ONLY REQUIREMENT IS THAT THE
  19. ; FILENAME OF THE FILE TO BE
  20. ; LOADED BE THE FIRST SPECIFIED
  21. ; NAME IN CMDBUF (THE COMMAND
  22. ; BUFFER).
  23. ;
  24. ; REGISTERS: IGNORED
  25. ;
  26. ;*ON EXIT-
  27. ; IF THE FILE EXISTED ON DISK AND
  28. ; COULD BE FOUND, AND NO CHECKSUM
  29. ; ERRORS WERE ENCOUNTERED WHILE
  30. ; LOADING IT, IT IS NOW LOADED
  31. ; INTO MEMORY, READY TO EXECUTE.
  32. ;
  33. ; REGISTERS: ALL DESTROYED
  34. ;
  35. ; EXECUTION OF THE LOADED PROGRAM
  36. ; IS STARTED AT THE FIRST BYTE
  37. ; LOADED.
  38. ;
  39. ; CMDBUF CONTAINS THE PARAMETER
  40. ; STRING FOR THE FRESHLY LOADED
  41. ; UTILITY OR USER PROGRAM.
  42. ;
  43. ;********************************
  44. .PAG
  45. ;********************************
  46. ;
  47. ;*FIRST WRITING-
  48. ; 25-JAN-80
  49. ; BY RON STEPHENS
  50. ;
  51. ;--------------------------------
  52. ;
  53. ;*REVISION LIST-
  54. ; 28-FEB-80 S. PATTERSON - ADD PARSER INTERFACE
  55. ; 09-APR-81 RSR - CHANGE FOR SERIAL BUS
  56. ;
  57. ;********************************
  58. .PAG
  59. ;********************************
  60. ;
  61. ;*ROUTINES EXTERNAL TO THIS
  62. ; MODULE THAT ARE USED:
  63. ;
  64. ; LOOKUP-
  65. ; FUNCTION-FINDS FIRST NAME
  66. ; SPECIFIED IN CMDBUF IN THE
  67. ; DISK DIRECTORY ON THE SPECIFIED
  68. ; DRIVE.
  69. ;
  70. ; INPUTS FROM UTLODR-NONE
  71. ; OUTPUTS TO UTLODR-NONE
  72. ;
  73. ; CHKIN-
  74. ; FUNCTION-CHECKS IF NAME WAS
  75. ; FOUND BY LOOKUP. ERROR IF NOT
  76. ; FOUND. EXITS TO 8050 ERROR
  77. ; ROUTINE.
  78. ;
  79. ; INPUTS FROM UTLODR-NONE
  80. ; OUTPUTS TO UTLODR-NONE
  81. ;
  82. ; GIBYTE-
  83. ; FUNCTION-FETCHES NEXT BYTE
  84. ; FROM OPEN FILE. ALSO SETS
  85. ; EOIFLG ZERO IF END OF FILE
  86. ; CONDITION DETECTED.
  87. ;
  88. ; INPUTS FROM UTLODR-NONE
  89. ; OUTPUTS TO UTLODR-VARIABLE 'DATA' CONTAINS
  90. ; THE DATA BYTE.
  91. ;
  92. ; OPNTYP-
  93. ; FUNCTION-OPENS FILE PREVIOUSLY
  94. ; "LOOKED UP" BY LOOKUP ABOVE.
  95. ; CALLS ERROR ROUTINE IF
  96. ; TYPE DOESN'T MATCH THAT SPECIFIED
  97. ;
  98. ; INPUTS FROM UTLODR-.A=FILE TYPE
  99. ; (5 IN OUR CASE)
  100. ; OUTPUTS TO UTLODR-NONE
  101. ;
  102. ; CMDER2-
  103. ; FUNCTION-PLACES ERROR MESSAGE
  104. ; SPECIFIED INTO ERROR BUFFER.
  105. ;
  106. ; INPUTS FROM UTLODR-.A=ERROR NUMBER
  107. ; OUTPUTS TO UTLODR-NONE
  108. ;
  109. ;********************************
  110. .PAG
  111. BOOT2
  112. RTS ;EXIT
  113. ;
  114. BOOT ;POWER-ON DIAG SENSE LOADER
  115. LDA PB ;GET PORT DATA
  116. TAX ;SAVE FOR LATER
  117. AND #CLKIN ;CHECK FOR CLK TO GND
  118. BEQ BOOT2 ;NO...EXIT
  119. TXA
  120. AND #DATIN ;CHECK FOR DATA TO GND
  121. BEQ BOOT2 ;NO...EXIT
  122. CLI ;SO BACKGND WILL RUN!
  123. ;
  124. ;BOOT CLIP MUST BE ON
  125. BOOT3
  126. LDA PB
  127. AND #CLKIN+DATIN
  128. BNE BOOT3 ;WAIT UNTILL REMOVED?
  129. ;
  130. INC F2CNT ;SET # FILES
  131. INC CMDSIZ ;SET # OF CHARS
  132. LDA #'*
  133. STA CMDBUF ;SET FILENAME FOR ANY MATCH
  134. ;
  135. JMP BOOT4
  136. ;
  137. ;
  138. ;*ENTRY POINT
  139. ;
  140. UTLODR
  141. LDA #$8D
  142. JSR PARSE
  143. BOOT4
  144. JSR KILLP ;KILL PROTECT
  145. LDA F2CNT
  146. PHA ;SAVE FILE COUNT FOR UTILITY
  147. LDA #1
  148. STA F2CNT
  149. LDA #$FF ;INIT FIRSTBYTE FLAG
  150. STA R0 ;R0 IS FLAG
  151. ;
  152. JSR LOOKUP ;LOCATE FILENAME ON DISK
  153. ;
  154. LDA FILTRK ;CHECK IF FOUND. ERR IF NOT
  155. BNE UTLD00
  156. LDA #NOCFIL
  157. JSR CMDERR
  158. UTLD00
  159. PLA
  160. STA F2CNT ;RESTORE FILE COUNT
  161. ;
  162. LDA FILTRK ;INIT TRK, SCTR FOR OPEN
  163. STA TRACK
  164. LDA FILSEC
  165. STA SECTOR
  166. ;
  167. LDA #USRTYP ;OPEN SYSTEM TYPE FILE( 5 )
  168. JSR OPNTYP ;OPEN
  169. ;
  170. ;********************************
  171. ;
  172. ;*FILE RECORD FETCH LOOP
  173. UTLD10 LDA #$00 ;INIT CHECKSUM
  174. STA R1 ;CALC. CHKSUM RESIDES IN R1
  175. ;
  176. JSR GTABYT ;FETCH LOAD ADDRESS LO
  177. STA R2
  178. JSR ADDSUM ;ADD INTO CHECKSUM
  179. ;
  180. JSR GTABYT ;FETCH LOAD ADDRESS HI
  181. STA R3
  182. JSR ADDSUM
  183. ;
  184. LDA R0 ;IS THIS THE FIRSTBYTE ADDRESS?
  185. BEQ UTLD20 ;BR IF NOT
  186. LDA R2 ;SAV AWAY THIS ADDR. IN2 STACK
  187. PHA ;LO FIRST
  188. LDA R3
  189. PHA ;HI NEXT
  190. LDA #$00 ;CLEAR FLAG
  191. STA R0 ;FIRSTBYTE FLAG
  192. ;
  193. UTLD20 JSR GTABYT ;FETCH DATA BYTE COUNT
  194. STA R4 ;SAVE IN R4
  195. JSR ADDSUM ;ADD INTO CHECKSUM
  196. ;
  197. ;********************************
  198. ;
  199. ;*BYTE STORE LOOP
  200. UTLD30 JSR GTABYT ;FETCH DATA BYT
  201. LDY #$00 ;INIT INDEX
  202. STA (R2),Y ;STORE BYTE AT DESIRED ADDRESS
  203. JSR ADDSUM ;ADD INTO CHECKSUM
  204. ;
  205. LDA R2 ;POINTER:=POINTER+1
  206. CLC
  207. ADC #$01
  208. STA R2
  209. BCC UTLD35
  210. INC R3 ;ADD IN CARRY
  211. ;
  212. UTLD35 DEC R4 ;UPDATE BYTE COUNTER
  213. BNE UTLD30 ;IF NONZERO, CONTINUE
  214. ;*END OF BYTE STORE LOOP
  215. ;
  216. ;********************************
  217. ;
  218. JSR GIBYTE ;GET A BYTE WITHOUT CHECK FOR EOI
  219. LDA DATA
  220. CMP R1 ;LAST BYTE FETCHED WAS CHKSUM
  221. BEQ UTLD50 ;IF SAME...EVERYTHING OK
  222. JSR GETHDR
  223. LDA #NOREC ;SHOW RECORD OVERFLOW
  224. JSR CMDER2 ;AND LEAVE TO ERROR EXIT
  225. ;
  226. UTLD50 LDA EOIFLG ;CHECK FOR END OF FILE
  227. BNE UTLD10 ;IF NONZERO, NOT DONE
  228. ;*END OF RECORD LOAD LOOP
  229. ;
  230. ;********************************
  231. ;
  232. PLA ;XFER CNTRL TO 1ST BYTE ADDR.
  233. STA R3
  234. PLA
  235. STA R2
  236. JMP (R2)
  237. .PAG
  238. ;********************************
  239. ;
  240. ;*LOCAL ROUTINES USED BY UTLODR
  241. ;
  242. .SKI
  243. ;********************************
  244. ;
  245. ;*GTABYT-FETCHES A BYTE FROM THE
  246. ; FILE OPEN ON THE INTERNAL
  247. ; CHANNEL. CHECKS IF THIS
  248. ; WAS THE LAST BYTE IN THE
  249. ; FILE. ERROR IF IT WAS.
  250. ; SHOW A 'PTER' (PREMATURE
  251. ; TERMINATION ERROR).
  252. ;
  253. ;********************************
  254. ;
  255. ;*ENTRY POINT
  256. ;
  257. GTABYT JSR GIBYTE ;FETCH A BYTE TO DATA LOC
  258. LDA EOIFLG ;CHECK IF EOF EXISTS
  259. BNE GTABYE ;OK IF NONZERO
  260. JSR GETHDR
  261. LDA #RECOVF ;RECORD SIZE ERROR
  262. JSR CMDER2 ;CALL 8050 ERROR ROUTINE
  263. ;
  264. GTABYE LDA DATA
  265. RTS
  266. .SKI 2
  267. ;********************************
  268. ;
  269. ;*ADDSUM-ADDS UP CHECKSUM INTO
  270. ; LOCATION R1. ALGORITHM:
  271. ; NEWSUM:=OLDSUM+NEWBYTE+
  272. ; CARRY
  273. ;
  274. ; INPUTS: EXPECTS NEWBYTE IN .A
  275. ; OUTPUTS: R1=NEWSUM, .A DESTROYED
  276. ;
  277. ;********************************
  278. ;
  279. ;*ENTRY POINT
  280. ;
  281. ADDSUM CLC
  282. ADC R1 ;.A=.A+R1
  283. ADC #$00 ;.A=.A+CARRY
  284. STA R1 ;SAVE NEW CHECKSUM
  285. RTS
  286. ;
  287. .END