home *** CD-ROM | disk | FTP | other *** search
/ CBM Funet Archive / cbm-funet-archive-2003.iso / cbm / src / pet / EXPANDED-BASIC.txt < prev    next >
Encoding:
Text File  |  1998-10-18  |  32.5 KB  |  843 lines

  1. exp-basic.src......page 0001
  2.  
  3. line# loc   code        line
  4.  
  5. 0001 0000               ;*****************************************
  6. 0002 0000               ;*  eeeee x   x pppp   aaa  n   n dddd   *
  7. 0003 0000               ;*  e     x   x p   p a   a nn  n d   d  *
  8. 0004 0000               ;*  e      x x  p   p a   a n n n d   d  *
  9. 0005 0000               ;*  eeee    x   pppp  aaaaa n n n d   d  *
  10. 0006 0000               ;*  e      x x  p     a   a n  nn d   d  *
  11. 0007 0000               ;*  e     x   x p     a   a n  nn d   d  *
  12. 00o8 0000               ;*  eeeee x   x p     a   a n   n dddd   *
  13. 0009 0000               ;*                                       *
  14. 0010 0000               ;*  aaa    bbbb   aaa   sss  iiiii  ccc  *
  15. 0011 0000               ;* a   a   b   b a   a s   s   i   c   c *
  16. 0012 0000               ;* a   a   b   b a   a  s      i   c     *
  17. 0013 0000               ;* a   a   b   b a   a   s     i   c     *
  18. 0014 0000               ;* aaaaa   bbbb  aaaaa    s    i   c     *
  19. 0015 0000               ;* a   a   b   b a   a     s   i   c     *
  20. 0016 0000               ;* a   a   b   b a   a s   s   i   c   c *
  21. 0017 0000               ;* a   a   bbbb  a   a  sss  iiiii  ccc  *
  22. 0018 0000               ;*                                       *
  23. 0019 0000               ;*****************************************
  24. 0020 0000               ;
  25. 0021 0000               ;
  26. 0022 0000               ;*****************************************
  27. 0023 0000               ;*                                       *
  28. 0024 0000               ;* expanded basic                        *
  29. 0025 0000               ;*                                       *
  30. 0026 0000               ;* program to append to the cbm basic    *
  31. 0027 0000               ;* version 4.0, 8032, chrget routines    *
  32. 0028 0000               ;* and add commands to cache programs    *
  33. 0029 0000               ;* in the 64k add-on memory.             *
  34. 0030 0000               ;*                                       *
  35. 0031 0000               ;* 14jul81 rjf (bob)  30jul81 (john)     *
  36. 0032 0000               ;*                                       *
  37. 0033 0000               ;*****************************************
  38.  
  39.  
  40. exp-basic.src......page 0002
  41.  
  42. line# loc   code        line
  43.  
  44. 0035 0000               ; system variable definitions
  45. 0036 0000               ;
  46. 0037 oo00               status =$96            ;system status variable
  47. 0039 0000               ds     =$13            ;disk status descriptor
  48. 0039 0000               chrget =$70            ;basic routine to get chars
  49. 0040 0000               chrgot =$76            ;get last character
  50. 0041 0000               getptr =$77            ;p0inter to characters
  51. 0042 0000               chdgot =$d39f          ;rom copy of chrgot
  52. 0043 0000               newstt =$b74a          ;new statement exex
  53. 0044 0000               lnkprg =$b4b6          ;link basic lines
  54. 0045 0000               stxtpt =$b622          ;set start text pointer
  55. 0046 0000               op94   =$f4a5          ;open a file on ieee
  56. 0047 0000               ready  =$b3ff          ;re-enter basic
  57. 0048 0000               fload  =$b60b          ;run an overlay
  58. 0049 0000               runc   =$b5e9          ;clear variables
  59. 0050 0000               clrch  =$ffcc          ;clear open channel
  60. 0051 0000               fclose =$f2e2          ;close a file
  61. 0032 0000               talk   =$f0d2          ;tell device to talk
  62. 0053 0000               acptr  =$f1co          ;get a byte
  63. 0054 0000               clsei  =$f72f          ;close a file
  64. 0055 0000               untlk  =$f1ae          ; untalk
  65. 0056 0000               tksa   =$f193          ;send secondary addr
  66. 0057 0000               wsw    =$b3
  67. 0058 0000               t1     =$b4
  68. 0059 0000               t2     =$b5
  69. 0060 0000               t3     =$b6
  70. 0061 0000               fnlen  =$d1            ;file name length
  71. 0062 0000               la     =$d2            ;logical file number
  72. 0063 0000               sa     =$d3            ;secondary address
  73. 0064 0000               fa     =$d4            ;primary address
  74. 0065 0000               fnaddr =$da            ;file name address
  75. 0066 0000               index1 =$1f            ;temp pointer
  76. 0067 0000               index2 =$21            ;temp pointer
  77. 0068 0000               eal    =$c9            ;end address pointer
  78. 0069 0000               vartab =$2a            ;variable table pointer
  79. 0070 0000               memsiz =$34            ;top of mem pointer
  80. 0071 0000               ;
  81. 0072 0000               ; program variables and constants
  82. 0073 0000               ;
  83. 0074 0000               loc    =$7800
  84. 0075 0000                      *=loc
  85. 0076 7800 4c 2e 79             jmp gooo        ;start program
  86. 0077 7803               ;
  87. 0079 7803               ;
  88. 0079 7803               tabhi
  89. 0080 7803 79                   .byt >zz1
  90. 0081 7804 79                   .byt >zz3
  91. 0082 7805 7a                   .byt >zz4
  92. 0083 7806 7a                   .byt >zz5
  93. 0084 7807 79                   .byt >zz8
  94. 0095 7808               ;
  95. 0086 7809               tablo
  96. 0097 7808 91                   .byt <zz1
  97. 0099 7009 fd                   .byt <zz3
  98. 0089 780a 11                   .byt <zz4
  99.  
  100. exp-basic.src......page 0003
  101.  
  102. line# loc   code        line
  103.  
  104. 0090 780b 22                   .byt <zz5
  105. 0091 7b0c 7c                   .byt <zz8
  106. 0092 7900               ;
  107. 0093 7800               ncmd   =5
  108. 0094 7900 52 4c         cmd    .byt 'rloeq'
  109. 0095 7812               file   *=*+22
  110. 0096 7828 00                   .byt $00
  111. 0097 7829               entry  =25
  112. 0098 7829               entmax =225            ;entry*9
  113. 0099 7b29               fitab  *=*+256
  114. 0100 7929 81 b7         wheret .wor $b782-1    ;g0ne3-3-1
  115. 0101 792b               master =$bb            ;available space (three bytes
  116. 0102 792b 4c 51 79      jump   jmp start
  117.  
  118.  
  119. exp-basic.src......page 0004
  120.  
  121. line# loc   code        line
  122.  
  123. 0104 792e               ;
  124. 0105 792e               ; init the memory manager (sys to here)
  125. 0106 792e               ;
  126. 0107 792e               gooo
  127. 0108 792e a2 02                ldx #$02        ;m0ve three bytes
  128. 0109 7930 bd 2b 79      wedge  lda jump,x
  129. 0110 7933 95 79                sta chrgot+3,x
  130. 0111 7935 ca                   dex
  131. 0112 7936 10 fb                bpl wedge
  132. 0113 7939               ;
  133. 0114 7938               tabset
  134. 0115 7939 a2 00                ldx #0
  135. 0116 793a sa                   txa
  136. 0117 793b 9d 29 78      tablp  sta fitab,x
  137. 0118 793e es                   inx
  138. 0119 793f do fa                bne tablp
  139. 0120 7941               ;
  140. 0121 7941               ; setup the start address
  141. 0122 7941               ;
  142. 0123 7941 a9 80                lda #$80
  143. 0124 7943 85 dc                sta master+1    ;high byte
  144. 0125 7945 oa                   asl a
  145. 0126 7946 55 88                sta master      ;low byte
  146. 0127 7940 95 bd                sta master+2    ;bank select
  147. 0128 794a b5 34                sta memsiz      ;set memsiz to loc
  148. 0129 794c a9 78                lda #>loc
  149. 0130 794e 95 35                sta memsiz+1
  150. 0131 7950 60                   rts
  151.  
  152.  
  153. exp-basic.src......page 0005
  154.  
  155. line# loc   code        line
  156.  
  157. 0133 7951               ;
  158. 0134 7951               ; this is where we come to do the work
  159. 0135 7951               ;
  160. 0136 7951               start
  161. 0137 7951 c9 21                cmp #'!         ;look for the escape character
  162. 0138 7953 do 21                bne notme
  163. 0139 7955 20 c9 7a             jsr savreg      ;save the registers
  164. 0140 7959               ;
  165. 0141 7958               ; test here for quote mode etc..........
  166. 0142 7959               ;
  167. 0143 7958 20 70 00             jsr chrget      ;get the next character
  168. 0144 795b 49                   pha
  169. 0145 795c fo 14                beq notcmd
  170. 0146 795e a2 04                ldx #ncmd-1
  171. 0147 7960               findc                  ;find the command
  172. 0148 7960 dd 00 79             cmp cmd,x
  173. 0149 7963 do oa                bne again
  174. 0150 7965               ;
  175. 0151 7965               ; put command address on stack
  176. 0152 7965               ;
  177. 0153 7965 68                   pla             ;fix the stack
  178. 0154 7966               ;
  179. 0155 7966 bd 03 7b             lda tabhi,x     ;fdund command...go there
  180. 0156 7969 49                   pha
  181. 0157 796a bd 08 79             lda tabld,x
  182. 0159 7960 48                   pha
  183. 0159 796e 60            strts  rts
  184. 0160 796f               ;
  185. 0161 796f               again
  186. 0162 796f ca                   dex
  187. 0163 7970 10 ee                bpl findc
  188. 0164 7972               ;
  189. 0165 7972               notcmd
  190. 0166 7972 20 do 7a             jsr resreg
  191. 0167 7975 68                   pla             ;fix the stack
  192. 0168 7976               notme
  193. 0169 7976 c9 3a                cmp #':
  194. 0170 7976 00 f4                bcs strts
  195. 0171 797a 4C 7d 00             jmp chrgot+7
  196.  
  197.  
  198. exp-dasic.src......pace 0006
  199.  
  200. line* loc   code        line
  201.  
  202. 0173 797d               ;
  203. 0174 797d               ; quit command
  204. 0175 7970               ;
  205. 0176 797d               ; this command exits the memory manager
  206. 0177 7970               ; and restores the chrget routine
  207. 0178 797d               ;
  208. 0179 797d               quit
  209. 0180 7970 20 70 00             jsr chrget      ;clean up the line
  210. 0181 7980 00 fb_               bne quit
  211. 0182 7982 a2 02                ldx #$02
  212. 0183 7984               rest
  213. 0184 7984 00 a2 d3             lda chdgot+3,x
  214. 0195 7907 95 79                sta chrgot+3,x
  215. 0196 79b9 ca                   dex
  216. 0187 799a 10 fo                bpl rest
  217. 0189 799c 20 do 7a             jsr resreg
  218. 0189 798f 4c 76 00             jmp chrgot
  219.  
  220.  
  221. exp-basic.src......page 0007
  222.  
  223. line# loc   code        line
  224.  
  225. 0191 7992               ;
  226. 0192 7992               ; load file from disk into expansion memory
  227. 0193 7992               ;
  228. 0194 7992               recal
  229. 0195 7992 20 d7 7a             jsr getfn       ;get the filename
  230. 0196 7995 a5 96                lda status
  231. 0197 7997 do 53                bne recout      ;bad status
  232. 0199 7999 20 10 7b             jsr gtype       ;get the file type
  233. 0199 799c a5 96                lda status
  234. 0200 799e do 4c                bne recout
  235. 0201 79a0 a9 52                lda #'r         ;set up for file read
  236. 0202 79a2 9d 12 78             sta file,x
  237.  
  238. 0204 79a5               ;open the file
  239. 0206 79a5 a9 oe                lda #14         ;set the logical file number
  240. 0207 79a7 95 02                sta la
  241. 0208 79a9 09 60                ora #$60        ;set the secundmy address
  242. 0209 79a9 85 03                sta sa
  243. 0210 79ad 20 a5 f4             jsr op94        ;0pen the file
  244. 0211 79b0 20 38 7b             jsr enter       ;enter filename into table
  245. 0212 79b3 80 3f                bcs recerr      ;bad...
  246. 0213 79b5               ;
  247. 0214 7985 a5 04                lda fa
  248. 0215 79b7 20 02 fo             jsr talk
  249. 0216 79da a5 03                lda sa
  250. 0217 79bc 20 93 fi             jsr tksa
  251. 0218 79bf               rec10
  252. 0219 79bf 20 co fL             jsr acptr       ;get a character
  253. 0220 79c2 78                   sei             ;kill the irq
  254. 0221 79c3 20 ae 7b             jsr selbnk      ;set up exp. ram
  255. 0222 79c6 ao 00                ldy #0
  256. 0223 79c9 91 bo                sta (master),y
  257. 0224 79ca a9 00                lda #$00        ;reset the banks
  258. 0225 79cc bd fo ff             sta $fff0
  259. 0226 79cf 58                   cli             ;restore the irq
  260. 0227 7900 20 c6 7b             jsr incmas
  261. 0229 79d3 a5 96                lda status      ;terminate on status <> 0
  262. 0229 79d5 00 04                bne rec20
  263. 0230 79d7 90 e6                bcc rec10       ;go do more bytes
  264. 0231 79d9 30 19                bcs recerr      ;out of memory
  265. 0232 79db c9 40         rec20  cmp #64         ;eoi is ok
  266. 0233 79dd 00 15                bne recerr      ;not eoi...
  267. 0234 79df 20 ae fL             jsr untlk
  268. 0235 79e2 20 2f f7             jsr clsei       ;close the file
  269. 0236 79e5 ao 15                ldy #21
  270. 0237 79e7 20 6b 7b             jsr entlst      ;put in the end address
  271. 0238 79ea a9 00                lda #0
  272. 0239 79ec               recout
  273. 0240 79ec 85 96                sta status
  274. 0241 79ee 20 do 7a             jsr resreg      ;restore registers
  275. 0242 79f1 4c 70 00             jmp chrget      ;back to basic
  276. 0243 79f4               ;
  277. 0244 79f4               recerr
  278. 0245 79f4 20 ae fi             jsr untlk       ;close the channel
  279.  
  280.  
  281. exp-basic.src...... page 0008
  282.  
  283. line* loc   code         line
  284.  
  285. 0246 79f7 20 2f f7             jsr clsei
  286. 0247 79fa a9 20                lda #32         ;send an error back
  287. 0248 79fc 00 ee                bne recout
  288.  
  289.  
  290. exp-basic.src......page 0009
  291.  
  292. line# loc   code        line
  293.  
  294. 0250 79fe               load
  295. 0251 79fe               ;
  296. 0252 79fe               ; this routine loads a file into the expansion memory
  297. 0253 79fe               ;
  298. 0254 79fe 20 3a 7a             jsr loader      ; do the load stuff
  299. 0253 7a01 a6 20                ldx index1+1
  300. 0256 7a03 56 29                stx vartab+1
  301. 0257 7a05 a6 1f                ldx index1
  302. 0258 7a07 86 2a                stx vartab
  303. 0259 7a09 20 e9 85             jsr runc        ;clear the variables
  304. 0260 7a0c 20 b6 84             jsr lnkprg      ; link basic lines
  305. 0261 7a0f 4c ff b3             jmp ready       ;say ready
  306. 0262 7a12               ;
  307.  
  308.  
  309. exp-basic.src......page 0010
  310.  
  311. line* loc   code        line
  312.  
  313. 0264 7a12               ovrly
  314. 0265 7a12               ;
  315. 0266 7a12               ; overlay an existing program (i.e. load from basic)
  316. 0267 7a12               ;
  317. 0269 7a12 20 3a 7a             jsr loader      ;load the file
  318. 0269 7a15 20 22 b6             jsr stxtpt      ;pick up the first line
  319. 0270 7a19 ad 2a 79             lda wheret+1    ;put correct address on stack
  320. 0271 7a19 49                   pha
  321. 0272 7a1c ad 29 79             lda wheret
  322. 0273 7a1f 48                   pha
  323. 0274 7a20 4c 00 b6             jmp fload       ;g0 run it
  324. 0275 7a23               ;
  325.  
  326.  
  327. exp-basic.src......page 0011
  328.  
  329. line* loc   code        line
  330.  
  331. 0277 7a23               exec
  332. 0279 7a23               ;
  333. 0279 7a23               ; load and run with a clear so variables are gone
  334. 0280 7a23               ;
  335. 0281 7a23 20 3a 7a             jsr loader      ;load the file
  336. 0292 7a26 a6 20                ldx index1+1
  337. 0283 7a29 96 2b                stx vartab+1
  338. 0284 7a2a a6 1f                ldx index1
  339. 0285 7a2c b6 2a                stx vartab
  340. 0286 7a2e 20 e9 b5             jsr runc        ;clear variables
  341. 0287 7a31 20 b6 84             jsr lnkprg      ;link lines
  342. 0299 7a34 20 22 06             jsr stxtpt      ;set pointer to first line
  343. 0289 7a37 4c 4a b7             jmp newstt      ;exec it
  344. 0290 7a3a               ;
  345.  
  346.  
  347. exp-dasic.src......page 0012
  348.  
  349. line# loc   code        line
  350.  
  351. 0292 7a3a               ;
  352. 0293 7a3a               ; routine to load files into low ram from 64k
  353. 0294 7a3a               ;
  354. 0295 7a3a               loader
  355. 0296 7a3a 20 d7 7a             jsr getfn      ;read the filename
  356. 0297 7a3d a5 96                lda status
  357. 0298 7a3f 00 5c                bne lderr      ;bad filename....
  358. 0299 7a41 20 7d 7b             jsr lukup      ;lookup the file in directory
  359. 0300 7a44 90 57                bcs lderr      ;not found...
  360. 0301 7a46               ;
  361. 0302 7a46 98                   tya            ;Lndex into the dir for addres
  362. 0303 7a47 19                   clc
  363. 0304 7a48 69 12                adc #18
  364. 0305 7a4a as                   tay
  365. 0306 7a4b 89 29 78             lda fitab,y    ;start lo
  366. 0307 7a4e 95 21                sta index2
  367. 0309 7a50 cs                   iny
  368. 0309 7a51 b9 29 78             lda fitab,y    ;start hi
  369. 0310 7a54 95 22                sta index2+1
  370. 0311 7a56               ;
  371. 0312 7a56 cs                   iny
  372. 0313 7a57 b9 29 78             lda fitab,y    ;get the mapper control byte
  373. 0314 7a5a 95 01                sta fnlen
  374. 0315 7a5c               ;
  375. 0316 7a5c cs                   iny
  376. 0317 7a5d b9 29 79             lda fitab,y    ;end lo
  377. 0318 7a60 95 c9                sta eal
  378. 0319 7a62 co                   iny
  379. 0320 7a63 89 29 79             lda fitab,y    ;end hi
  380. 0321 7a66 95 ca                sta eal+1
  381. 0322 7a69               ;
  382. 0323 7a69               ; loop to load data into lo ram
  383. 0324 7a68               ;
  384. 0325 7a69               lodlp
  385. 0326 7a68 79                   sei            ;n0 irq allowed
  386. 0327 7a69               lodlp0
  387. 0328 7a69 ao 00                ldy #$0
  388. 0329 7a6b a6 01                ldx fnlen      ;set up the banks
  389. 0330 7a6d do 04                bne lodlp1
  390. 0331 7a6f a2 80                ldx #$80       ;select 0,2
  391. 0332 7a71 00 02                bne stlp
  392. 0333 7a73               lodlp1
  393. 0334 7a73 a2 99                ldx #$88       ;select 1,3
  394. 0335 7a75               stlp
  395. 0336 7a75 8e fo ff             stx $fff0
  396. 0337 7a79               ;
  397. 0338 7a78               ;
  398. 0339 7a79 b1 21                lda (index2),y ;load address lo
  399. 0340 7a7a 95 1f                sta index1
  400. 0341 7a7c 20 9f 7a             jsr bumpx
  401. 0342 7a7f               ;
  402. 0343 7a7f 81 21                lda (index2),y ;load address hi
  403. 0344 7a81 95 20                sta index1+1
  404. 0345 7a83 20 9f 7a             jsr bumpx
  405. 0346 7a86               ;
  406.  
  407.  
  408. exp-basic.src......page 0013
  409.  
  410. line# loc   code        line
  411.  
  412. 0347 7ab6               lodlp2
  413. 0349 7ab6 bi 21                lda (index2),y ;transfer a byte
  414. 0349 7a99 91 if                sta (index1),y
  415. 0350 7a8a               ;
  416. 0351 7a8a e6 1f                inc index1     ;bump the destination pointer
  417. 0352 7a8c 00 02                bne lodlp3
  418. 0353 7a8e e6 20                inc index1+1
  419. 0354 7a90               lodlp3
  420. 0355 7a90 20 9f 7a             jsr bumpx      ;bump source pointer
  421. 0356 7a93 90 fi                bcc lodlp2     ;done yet?
  422. 0357 7a95               ;
  423. 0359 7a95 a2 00                ldx #0         ;restore the rom's
  424. 0359 7a97 8e fo ff             stx $fff0
  425. 0360 7a9a 58                   cli            ;we are done let irq go
  426. 0361 7a98 18                   clc
  427. 0362 7a9c 60                   rts
  428. 0363 7a9d               lderr                 ;load error
  429. 0364 7a9d 38                   sec
  430. 0365 7a9e 60                   rts
  431. 0366 7a9f               ;
  432. 0367 7a9f               ;subroutine to handle data pointers to expansion mem
  433. 0369 7a9f               ;
  434. 0369 7a9f               bumpx
  435. 0370 7a9f e6 21                inc index2
  436. 0371 7aai do of                bne tstxx
  437. 0372 7aa3 e6 22                inc index2+1
  438. 0373 7aa5 do ob                bne tstxx
  439. 0374 7aa7 a2 90                ldx #$80       ;crossed over to other block
  440. 0375 7aa9 96 01                stx fnlen
  441. 0376 7aab 96 22                stx index2+1
  442. 0377 7aad a9 b8                lda #%10111000
  443. 0373 7aaf bd fo ff             sta $fff0
  444. 0379 7ab2               tstxx                 ;check for end of file
  445. 0380 7ab2 a6 c9                ldx eal
  446. 0381 7ab4 e4 21                cpx index2
  447. 0382 7ab6 do 08                bne donex
  448. 0393 7ab9 a6 ca                ldx eal+1
  449. 0384 7a9a e4 22                cpx index2+1
  450. 0385 7abc do 02                bne donex
  451. 0396 7abe 38                   sec            ;done with load
  452. 0387 7abf 60                   rts
  453. 0389 7aco               donex
  454. 0389 7aco 18                   clc
  455. 0390 7ac1 60                   rts
  456. 0391 7ac2               ;
  457.  
  458.  
  459. exp-dasic.src......page 0014
  460.  
  461. line# loc   code        line
  462.  
  463. 0393 7ac2               ;
  464. 0394 7ac2               ;increment pointer to text
  465. 0395 7ac2               ;
  466. 0396 7ac2               incptr
  467. 0397 7ac2 e6 77                inc getptr
  468. 0399 7ac4 do 02                bne incrts
  469. 0399 7ac6 e6 79                inc getptr+1
  470. 0400 7acs               incrts
  471. 0401 7acs 60                   rts
  472. 0402 7ac9               ;
  473. 0403 7ac9               ;save and restore routines for .a, .x, .y
  474. 0404 7ac9               ;
  475. 0405 7ac9               savreg
  476. 0406 7ac9 85 83                sta wsw
  477. 0407 7aco 86 84                stx t1
  478. 0409 7acd 84 b5                sty t2
  479. 0409 7acf 60                   rts
  480. 0410 7ado               ;
  481. 0411 7a00               resreg
  482. 0412 7ado a5 b3                lda wsw
  483. 0413 7ad2 a6 84                ldx t1
  484. 0414 7ad4 a4 85                ldy t2
  485. 0415 7ad6 60                   rts
  486.  
  487.  
  488. exp-basic.src......page 0015
  489.  
  490. line# loc   code        line
  491.  
  492. 0417 7ad7               ;
  493. 0419 7ad7               ; get filename from user command
  494. 0419 7ad7               ;
  495. 0420 7ad7               getfn
  496. 0421 7ad7 20 70 00             jsr chrget
  497. 0422 7ada fo 57                beg badfi      ;not there error
  498. 0423 7adc c9 22                cmp #'"        ;look for open quote
  499. 0424 7ade 00 f7                bne getfn
  500. 0423 7aeg               ;
  501. 0426 7aeo a9 00                lda #0
  502. 0427 7ae2 85 96                sta status
  503. 0428 7ae4 aa                   tax
  504. 0429 7ae5 ab                   tay
  505. 0430 7ae6 a9 12                lda #<file
  506. 0431 7ae9 95 da                sta fnaddr
  507. 0432 7aea a9 78                lda #>file
  508. 0433 7aec 95 db                sta fnaddr+1
  509. 0434 7aee               floop
  510. 0435 7aee 20 c2 7a             jsr incptr
  511. 0436 7af1 bi 77                lda (getptr),y
  512. 0437 7af3 c9 22                cmp #'"        ;look for end quote
  513. 0439 7af5 fo oa                beq endfi
  514. 0439 7af7 90 12 78             sta file,x
  515. 0440 7afa es                   inx
  516. 0441 7afb eo 12                cpx #L8
  517. 0442 7afo 90 ef                bcc floop      ;g0 get more
  518. 0443 7aff 80 32                bcs badfi      ;too long
  519. 0444 7b01               endfi
  520. 0445 7b01 96 01                stx fnlen      ;save length (index)
  521. 0446 7b03 a9 00                lda #0         ;pad filename wih $00 on right
  522. 0447 7b05 eo 12         fi1o   cpx #18
  523. 0449 7b07 bo 06                bcs endfia
  524. 0449 7b09 90 12 78             sta file,x
  525. 0450 7b0c es                   inx
  526. 0451 7b00 do f6                bne fi1o
  527. 0452 7b0f               endfia
  528. 0453 7b0f 60                   rts
  529. 0454 7b10               ;
  530. 0455 7b10               ; get the file type
  531. 0456 7b10               ;
  532. 0457 7b10               gtype
  533. 0458 7b10               gcomma
  534. 0459 7b10 20 70 00             jsr chrget
  535. 0460 7b13 fo Le                beq badfi      ;not enough info.....
  536. 0461 7b15 c9 2c                cmp #',
  537. 0462 7b17 do f7                bne gcomma
  538. 0463 7b19 a6 01                ldx fnlen      ;get the current filename length
  539. 0464 7b1b 9d 12 79             sta file.x
  540. 0465 7bie 9d 14 78             sta file+2,x   ;put comma here also
  541. 0466 7b21 20 70 00             jsr chrget     ;get type byte (s,u,p,r)
  542. 0467 7b24 fo 00                beq badfi
  543. 0468 7b26 es                   inx
  544. 0469 7b27 9d 12 78             sta file,x     ;no value check is done!'!
  545. 0470 7b2a es                   inx            ;skip to put in the read or wr
  546. 0471 7b2b es                   inx            ;but do not put in here
  547.  
  548.  
  549. exp-dasic.src......page 0016
  550.  
  551. line# loc   code        line
  552.  
  553. 0472 7b2c 96 di                stx fnlen
  554. 0473 7b2e               ;
  555. 0474 7b2e               ;  put in the device number check later*************
  556. 0475 7b2e               ; for now default to 9 unly
  557. 0476 7b2e               ;
  558. 0477 782e a9 09                lda #8
  559. 0478 7930 95 04                sta fa
  560. 0479 7b32 60                   rts
  561. 0490 7b33               ;
  562. 0481 7b33               badfi
  563. 0482 7b33 a9 01                lda #$01
  564. 0483 7b35 95 96                sta status
  565. 0484 7b37 60                   rts
  566. 0485 7b38               ;
  567. 0486 7b38               ; enter file into table
  568. 0487 7b39               ; put in load address and set status in carry
  569. 0489 7b38               ;
  570. 0489 7b38               enter
  571. 0490 7b38 20 7d 7b             jsr lukup      ;look for file in table
  572. 0491 7b3b 90 3e                bcc badent     ; dup found...
  573. 0492 7b3d               ;
  574. 0493 7b3d               ; look for blank entry
  575. 0494 783d               ;
  576. 0495 793d ao eL                ldy #entmax
  577. 0496 7b3f               empty
  578. 0497 7b3f b9 29 78             lda fitab,y
  579. 0498 7b42 fo 09                beg empfnd
  580. 0499 7b44 99                   tya
  581. 0500 7b45 38                   sec
  582. 0501 7b46 e9 19                sbc #entry
  583. 0502 7b48 as                   tay
  584. 0503 7b49 do f4                bne empty
  585. 0504 7b48 fo 2e                beq badent
  586. 0505 7b4d               ;
  587. 0506 7b4d               empfnd                ;f0und an entry
  588. 0507 7b4d 99                   tya            ;point index1 to entry
  589. 0509 7b4e 19                   clc
  590. 0509 784f 69 29                adc #<fitab
  591. 0510 7b51 b5 1f                sta index1
  592. 0511 7b53 a9 79                lda #>fitab
  593. 0512 7b55 69 00                adc #0
  594. 0513 7b57 85 20                sta index1+1
  595. 0514 7b59               ;
  596. 0515 7b59               ;place entry into dir
  597. 0516 7859               ;
  598. 0517 7b59 ao 00                ldy #0
  599. 0519 7b5b               entmor
  600. 0519 7b59 89 12 78             lda file,y
  601. 0520 7b5e c9 2c                cmp #',        ;only put in drive and name
  602. 0521 7b60 fo 07                beq entfst
  603. 0522 7b62 91 1f                sta (index1),y
  604. 0523 7b64 c8                   iny
  605. 0524 7b65 co 12                cpy #18
  606. 0525 7b67 90 f2                bcc  entmor
  607. 0526 7b69               ;
  608.  
  609.  
  610. exp-basic.src......page 0017
  611.  
  612. line# loc   code        line
  613.  
  614. 0527 7b69               entfst
  615. 0529 7b69 ao 12                ldy #18
  616. 0529 7b6b               ;
  617. 0530 7b6b               entlst                ;enter end address
  618. 0531 7b6b a5 bb                lda master     ;save the load address
  619. 0532 7b6d 91 lf                sta (index1),y
  620. 0533 7b6f co                   iny
  621. 0534 7b70 a5 bc                lda master+1
  622. 0535 7b72 91 1f                sta (index1),y
  623. 0536 7b74 co                   iny            ;put in the bank control byte
  624. 0537 7b75 a5 be                lda master+3
  625. 053b 7b77 91 1f                sta (index1),y
  626. 0539 7b79 ib                   clc
  627. 0540 7b7a 60                   rts            ;come here for bad exit
  628. 0541 7b7b               badent
  629. 0542 7b7b 38                   sec
  630. 0543 7b7c 60                   rts
  631. 0544 7b70               ;
  632. 0545 7b7d               ; lookup file in directory
  633. 0546 7b7d               ;
  634. 0547 7b7d               lukup
  635. 0549 787d ao eL                ldy #entmax
  636. 0549 7b7f               luk10
  637. 0550 7b7f b9 29 78             lda fitab,y
  638. 0551 7db2 do 09                bne lukcmp
  639. 0552 7b94               luk20
  640. 0553 7b94 99                   tya            ;m0ve to next file
  641. 0554 7095 38                   sec
  642. 0555 7b96 e9 19                sbc #entry
  643. 0556 7b89 as                   tay
  644. 0557 7b89 do f4                bne luk10
  645. 0558 7bb9 fo if                beq notfnd
  646. 0559 7b9d               ;
  647. 0560 7bod               lukcmp
  648. 0561 7b9d 84 06                sty t3         ;save .y while doing the compare
  649. 0562 7b8f a2 00                ldx #0
  650. 0563 7b91               luk30
  651. 0564 7b91 bd 12 78             lda file,x
  652. 0565 7b94 c9 2c                cmp #',        ;comma means done
  653. 0566 7b96 fo ob                beq found
  654. 0567 7b99 09 29 7b             cmp fitab,y
  655. 0568 7b9b do oa                bne trymor
  656. 0569 7b9d cs                   iny
  657. 0570 7b9e e8                   inx
  658. 0571 7b9f eo 12                cpx #18
  659. 0572 7ba1 90 ee                bcc luk30
  660. 0573 7da3               ;
  661. 0574 7ba3               found                 ;i found it
  662. 0575 7ba3 a4 b6                ldy t3         ;.y points to file
  663. 0576 7ba5 is                   clc
  664. 0577 7ba6 60                   rts
  665. 0579 7ba7               trymor                ;i am trying to find it
  666. 0579 7ba7 a4 b6                ldy t3
  667. 0580 7ba9 4c 84 7b             jmp luk20
  668. 0581 7dac               notfnd                ;i lost it
  669.  
  670.  
  671. exp-basic.src......page 0018
  672.  
  673. line# loc   code        line
  674.  
  675. 0592 7bac 38                   sec
  676. 0583 7bad 60                   rts
  677. 0584 7bae               ;
  678. 0595 7bae               ;this routine turns on the proper bank
  679. 05b6 7bae               ;
  680. 0587 7bae               selbnk
  681. 058A 78ae a6 bd                ldx master+2
  682. 0589 7db0 do 06                bne sel10
  683. 0590 70b2 a2 80                ldx #$80       ;turn on banks 0 and 2
  684. 0591 7bb4 se fo ff             stx $fff0
  685. 0592 7bd7 60                   rts
  686. 0593 7899               sel10
  687. 0594 7bbb a2 88                ldx #$88       ;turn on banks 1 and 3
  688. 0595 7bba se fo ff             stx $fff0
  689. 0596 7bbd a6 bd                ldx master+2   ;one byte has the $40 flag
  690. 0597 7bbf 70 04                bvs sel30
  691. 0599 7bci a2 90                ldx #$80
  692. 0599 7bc3 86 bd                stx master+2
  693. 0600 7bc5               sel30
  694. 0601 7bc5 60                   rts
  695. 0602 7bc6               ;
  696. 0603 7bc6               ; bump up the master pointer and set the $40 flag
  697. 0604 7bc6               ;
  698. 0605 7bc6               incmas
  699. 0606 7bc6 e6 08                inc master     ;bump pointers
  700. 0607 7bcb do 10                bne masrts
  701. 0609 7bca e6 bc                inc master+1
  702. 0609 78cc do oc                bne masrts     ;check for overflow of bank
  703. 0610 7bce a6 bd                ldx master+2   ;we went over
  704. 0611 7bd0 do oa                bne inc10      ;out of memdry?
  705. 0612 7bd2 a2 40                ldx #$40       ;set flag for overflow
  706. 0613 7bd4 96 dd                stx master+2
  707. 0614 7bd6 a2 90                ldx #$80       ;reset pointer hi
  708. 0615 7bds 86 bc                stx master+1
  709. 0616 7dda               masrts
  710. 0617 7bda 18                   clc
  711. 0619 7bdb 60                   rts            ;out of memory
  712. 0619 7bdc               inc10
  713. 0620 7bdc 38                   sec
  714. 0621 7bdd 60                   rts
  715. 0622 7bde               ;
  716. 0623 72de               ;
  717. 0624 78de               ;these must be after the definition
  718. 0625 7bde               ;
  719. 0626 7bde               zz1    =recal-1       ;recall from disk
  720. 0627 7bde               zz3    =load-1        ;load low memory from expansion
  721. 0629 7bde               zz4    =ovrly-1       ;overlay program in memory
  722. 0629 7bde               zz5    =exec-1        ;execute without overlay
  723. 0630 7bde               zz8    =quit-1        ;exit program.
  724. 0631 7bde                      .end
  725.  
  726. errors = 0000
  727.  
  728.  
  729. symbol table
  730.  
  731. symbol value
  732.  acptr     f1c0    again     796f    badent    7b7b    badfi     7b33
  733.  bumpx     7a9f    chdgot    d39f    chrget    0070    chrgot    0076
  734.  clrch     ffcc    clsei     f72f    cmd       7900    donex     7aco
  735.  ds        0013    eal       00c9    empfnd    7b4d    empty     7b3f
  736.  endfi     7b01    endfia    7b0f    enter     7b39    entfst    7b69
  737.  entlst    7b6b    entmax    00e1    entmor    7b5b    entry     0019
  738.  exec      7a23    fa        00d4    fclose    f2e2    fi10      7b05
  739.  file      7812    findc     7960    fitab     7829    fload     b6ob
  740.  floop     7aee    fnaddr    ooda    fnlen     0001    found     7ba3
  741.  gcomma    7810    getfn     7ad7    getptr    0077    gooo      792e
  742.  gtype     7810    inc10     7bdc    incmas    78c6    incptr    7ac2
  743.  incrts    7ac8    index1    001f    index2    0021    jump      792b
  744.  la        00d2    lderr     7a9d    lnkprg    b4b6    load      79fe
  745.  loader    7a3a    loc       7800    lodlp     7a6b    lodlp0    7a69
  746.  lodlp1    7a73    lodlp2    7a86    lodlp3    7a90    luk10     7b7f
  747.  luk20     7b84    luk30     7b91    lukcmp    7b9d    lukup     7b7d
  748.  masrts    7bda    master    oobb    memsiz    0034    ncmd      0005
  749.  newstt    b74a    notcmd    7972    notfnd    7bac    notme     7976
  750.  op94      f4a5    ovrly     7a12    quit      7970    ready     b3ff
  751.  rec10     79bf    rec20     79db    recal     7992    recerr    79f4
  752.  recout    79ec    resreg    7ado    rest      7984    runc      b5e9
  753.  sa        0003    savreg    7ac9    sel10     79b9    sel30     7bc5
  754.  selbnk    7bae    start     7951    status    0096    stlp      7a75
  755.  strts     796e    stxtpt    b622    t1        00b4    t2        00b5
  756.  t3        00b6    tabhi     7803    tablo     7809    tablp     793b
  757.  tabset    7938    talk      f0d2    tksa      fL93    trymor    7ba7
  758.  tstxx     7ab2    untlk     f1ae    vartab    002a    wedge     7930
  759.  wheret    7929    wsw       00b3    zz1       7991    zz3       79fd
  760.  zz4       7a11    zz5       7a22    zz8       797c
  761. end of assembly
  762.  
  763.  
  764. expanded-basic
  765.  
  766.  100 rem******************************
  767.  110 rem* expanded basic demo        *
  768.  120 rem*                            *
  769.  130 rem* boot expanded basic        *
  770.  140 rem* and then cache demo program*
  771.  150 rem******************************
  772.  160 if a then sys 7*16^3+8*256
  773.  170 if a then:!r,"sttest",p:!e,"sttest"
  774.  180 a=1:dload "expanded-basic"
  775.  
  776.  
  777. sttest
  778.  
  779.  10 rem demo for memory manager
  780.  20 rem first we must get the stuff into memory
  781.  30 :!r,"test1",p
  782.  40 :!r,"test2",p
  783.  50 :!r,"test3",p
  784.  60 :!r,"test4",p
  785.  70 rem execute the first program in the chain
  786.  80 :!e,"test1"
  787.  
  788.  
  789. test1
  790.  
  791.  10 rem this is a test
  792.  15 print"<clr>test1":fori=1to200:next
  793.  17 print"print the numbers from 1 to 20"
  794.  19 fori=1to200:next
  795.  20 fori=1to20
  796.  30 print,i
  797.  40 next
  798.  50 :!e,"test2"
  799.  
  800.  
  801. test2
  802.  
  803.  10 rem this is a test
  804.  15 print"<clr>test2":fori=1to200:next
  805.  17 print"print the numbers from 20 to 1"
  806.  19 fori=1to200:next
  807.  20 fori=20 to 1 step -1
  808.  30 print,i
  809.  40 next
  810.  50 :!e,"test3"
  811.  
  812.  
  813. test3
  814.  
  815.  10 rem this is a test
  816.  15 print"<clr>test3":fori=1to200:next
  817.  17 print"print the numbers from 51 to 70"
  818.  18 print"along with the square-root
  819.  19 fori=1to200:next
  820.  20 fori=51to70
  821.  30 print,i,sqr(i)
  822.  40 next
  823.  50 :!e,"test4"
  824.  
  825.  
  826. test4
  827.  
  828.  10 rem this is a test
  829.  15 print"<clr>test4":fori=1to200:next
  830.  17 print"you have seen the system load and"
  831.  18 print"execute three programs from the
  832.  20 print"expansion memory.  if you look at
  833.  30 print"the files with the word 'test' in them
  834.  40 print"you will see how this is done
  835.  45 print"<dwn><dwn><dwn>type <rev>space<off> to continue or <rev>q<off> to quit"
  836.  50 geta$:ifa$=""then50
  837.  60 ifa$="q"then:!q:end
  838.  65 ifa$=" "then:!e,"test1"
  839.  70 ifa$="2"then:!e,"test2"
  840.  80 ifa$="3"then:!e,"test3"
  841.  
  842.  
  843.