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.

utlodr.src 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. .page
  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. .page
  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. ; boot routine removed, won't work with serial i|f
  111. .page
  112. boot2
  113. rts ; exit
  114. ;
  115. ;***rom -05 fix 8/18/83
  116. boot ; power-on diag sense loader
  117. ;lda pb ;get port data
  118. ;tax ;save for later
  119. ;and #clkin ;check for clk to gnd
  120. ;beq boot2 ;no...exit
  121. ;txa
  122. ;and #datin ;check for data to gnd
  123. ;beq boot2 ;no...exit
  124. ;cli ;so backgnd will run!
  125. ;
  126. ;boot clip must be on
  127. boot3
  128. ;lda pb
  129. ;and #clkin+datin
  130. ;bne boot3 ;wait untill removed?
  131. ;
  132. ;inc f2cnt ;set # files
  133. ;inc cmdsiz ;set # of chars
  134. ;lda #'*
  135. ;sta cmdbuf ;set filename for any match
  136. ;jmp boot4
  137. ;---------rom -05 fix 8/18/83---------------
  138. jmp tstatn ; *ds rom 09/03/85*
  139. .byte $ea,$ea,$ea,$ea,$ea
  140. .byte $ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea
  141. .byte $ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea
  142. .byte $ea,$ea,$ea,$ea,$ea,$ea,$ea,$ea
  143. .byte $ea,$ea,$60
  144. ;--------------------------------------------
  145. ;
  146. ;
  147. ;*entry point
  148. ;
  149. utlodr
  150. lda #$8d
  151. jsr parse
  152. boot4
  153. jsr killp ; kill protect
  154. lda f2cnt
  155. pha ; save file count for utility
  156. lda #1
  157. sta f2cnt
  158. lda #$ff ; init firstbyte flag
  159. sta r0 ; r0 is flag
  160. ;
  161. jsr lookup ; locate filename on disk
  162. ;
  163. lda filtrk ; check if found. err if not
  164. bne utld00
  165. lda #nocfil
  166. jsr cmderr
  167. utld00
  168. pla
  169. sta f2cnt ; restore file count
  170. ;
  171. lda filtrk ; init trk, sctr for open
  172. sta track
  173. lda filsec
  174. sta sector
  175. ;
  176. lda #usrtyp ; open system type file( 5 )
  177. jsr opntyp ; open
  178. ;
  179. ;********************************
  180. ;
  181. ;*file record fetch loop
  182. utld10 lda #$00 ; init checksum
  183. sta r1 ; calc. chksum resides in r1
  184. ;
  185. jsr gtabyt ; fetch load address lo
  186. sta r2
  187. jsr addsum ; add into checksum
  188. ;
  189. jsr gtabyt ; fetch load address hi
  190. sta r3
  191. jsr addsum
  192. ;
  193. lda r0 ; is this the firstbyte address?
  194. beq utld20 ; br if not
  195. lda r2 ; sav away this addr. in2 stack
  196. pha ; lo first
  197. lda r3
  198. pha ; hi next
  199. lda #$00 ; clear flag
  200. sta r0 ; firstbyte flag
  201. ;
  202. utld20 jsr gtabyt ; fetch data byte count
  203. sta r4 ; save in r4
  204. jsr addsum ; add into checksum
  205. ;
  206. ;********************************
  207. ;
  208. ;*byte store loop
  209. utld30 jsr gtabyt ; fetch data byt
  210. ldy #$00 ; init index
  211. sta (r2),y ; store byte at desired address
  212. jsr addsum ; add into checksum
  213. ;
  214. lda r2 ; pointer:=pointer+1
  215. clc
  216. adc #$01
  217. sta r2
  218. bcc utld35
  219. inc r3 ; add in carry
  220. ;
  221. utld35 dec r4 ; update byte counter
  222. bne utld30 ; if nonzero, continue
  223. ;*end of byte store loop
  224. ;
  225. ;********************************
  226. ;
  227. jsr gibyte ; get a byte without check for eoi
  228. lda data
  229. cmp r1 ; last byte fetched was chksum
  230. beq utld50 ; if same...everything ok
  231. jsr gethdr
  232. lda #norec ; show record overflow
  233. jsr cmder2 ; and leave to error exit
  234. ;
  235. utld50 lda eoiflg ; check for end of file
  236. bne utld10 ; if nonzero, not done
  237. ;*end of record load loop
  238. ;
  239. ;********************************
  240. ;
  241. pla ; xfer cntrl to 1st byte addr.
  242. sta r3
  243. pla
  244. sta r2
  245. jmp (r2)
  246. .page
  247. ;********************************
  248. ;
  249. ;*local routines used by utlodr
  250. ;
  251. ;********************************
  252. ;
  253. ;*gtabyt-fetches a byte from the
  254. ; file open on the internal
  255. ; channel. checks if this
  256. ; was the last byte in the
  257. ; file. error if it was.
  258. ; show a 'pter' (premature
  259. ; termination error).
  260. ;
  261. ;********************************
  262. ;
  263. ;*entry point
  264. ;
  265. gtabyt jsr gibyte ; fetch a byte to data loc
  266. lda eoiflg ; check if eof exists
  267. bne gtabye ; ok if nonzero
  268. jsr gethdr
  269. lda #recovf ; record size error
  270. jsr cmder2 ; call 8050 error routine
  271. ;
  272. gtabye lda data
  273. rts
  274. ;********************************
  275. ;
  276. ;*addsum-adds up checksum into
  277. ; location r1. algorithm:
  278. ; newsum:=oldsum+newbyte+
  279. ; carry
  280. ;
  281. ; inputs: expects newbyte in .a
  282. ; outputs: r1=newsum, .a destroyed
  283. ;
  284. ;********************************
  285. ;
  286. ;*entry point
  287. ;
  288. addsum clc
  289. adc r1 ; .a=.a+r1
  290. adc #$00 ; .a=.a+carry
  291. sta r1 ; save new checksum
  292. rts
  293. ;
  294. ; .end