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.

parsex.src 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. .page 'parse & execute'
  2. ;parse & execute string in cmdbuf
  3. parsxq
  4. lda #0
  5. sta wbam
  6. lda lstdrv
  7. sta drvnum
  8. jsr okerr
  9. lda orgsa
  10. bpl ps05
  11. and #$f
  12. cmp #$f
  13. beq ps05
  14. jmp open
  15. ps05 jsr cmdset ; set variables,regs
  16. lda (cb),y
  17. sta char
  18. ldx #ncmds-1 ; search cmd table
  19. ps10 lda cmdtbl,x
  20. cmp char
  21. beq ps20
  22. dex
  23. bpl ps10
  24. lda #badcmd ; no such cmd
  25. jmp cmderr
  26. ps20 stx cmdnum ; x= cmd #
  27. cpx #pcmd ; cmds not parsed
  28. bcc ps30
  29. jsr tagcmd ; set tables, pointers &patterns
  30. ps30 ldx cmdnum
  31. lda cjumpl,x
  32. sta temp
  33. lda cjumph,x
  34. sta temp+1
  35. jmp (temp) ; command table jump
  36. ; successful command termination
  37. endcmd
  38. lda #0
  39. sta wbam
  40. endsav
  41. lda erword
  42. bne cmderr
  43. ;
  44. ldy #0
  45. tya
  46. sty track
  47. scrend sty sector ; scratch entry
  48. sty cb
  49. jsr errmsg
  50. jsr erroff
  51. scren1
  52. lda drvnum
  53. sta lstdrv
  54. tax
  55. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  56. jmp ptch19 ; *rom ds 09/03/85* *GCB 11/20/86*
  57. nop ; fill
  58. ; lda #0
  59. ; sta nodrv,x
  60. rtch19
  61. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  62. jsr clrcb
  63. jmp freich ; free internal channel
  64. ;
  65. clrcb
  66. ldy #cmdlen-1
  67. lda #0
  68. clrb2
  69. sta cmdbuf,y
  70. dey
  71. bpl clrb2
  72. rts
  73. ;
  74. ; command level error processing
  75. cmderr ldy #0
  76. sty track
  77. sty sector
  78. jmp cmder2
  79. simprs ldx #0 ; simple parser
  80. stx filtbl
  81. lda #':
  82. jsr parse
  83. beq sp10
  84. dey
  85. dey
  86. sty filtbl
  87. sp10 jmp setany ; set drive #
  88. .page 'parse-tagcmd'
  89. prscln
  90. ldy #0
  91. ldx #0
  92. lda #':
  93. jmp parse ; find pos'n of ":"
  94. ;
  95. ;tag command string
  96. ; set up cmd structure
  97. ; image & file stream ptrs
  98. ;
  99. tagcmd
  100. jsr prscln
  101. bne tc30
  102. tc25 lda #nofile ; none, no files
  103. jmp cmderr
  104. tc30 dey
  105. dey
  106. sty filtbl ; ":"-1 starts fs1
  107. txa
  108. bne tc25 ; err: "," before ":"
  109. tc35 lda #'= ; search: "="
  110. jsr parse
  111. txa ; ?file count= 1-1?
  112. beq tc40
  113. lda #%01000000 ; g1-bit
  114. tc40 ora #%00100001 ; e1,~e2-bits
  115. sta image ; fs structure
  116. inx
  117. stx f1cnt
  118. stx f2cnt ; init for no fs2
  119. lda patflg
  120. beq tc50
  121. lda #%10000000 ; p1-bit
  122. ora image
  123. sta image
  124. lda #0
  125. sta patflg ; clear pattern flag
  126. tc50 tya ; ptr to fs2
  127. beq tc75 ; fs2 not here
  128. sta filtbl,x
  129. lda f1cnt ; fs2 is here now,...
  130. sta f2ptr ; ...now set f2 ptr
  131. lda #$8d ; find cr-shifted
  132. jsr parse ; parse rest of cmd string
  133. inx ; advance filtbl ptr to end
  134. stx f2cnt ; save it
  135. dex ; restore for test
  136. lda patflg ; save last pattern
  137. beq tc60 ; ?any patterns?
  138. lda #%1000 ; yes, p2-bit
  139. tc60 cpx f1cnt ; ?f2cnt=f1cnt+1?
  140. beq tc70
  141. ora #%0100 ; g2-bit
  142. tc70 ora #%0011 ; e2-bit,~e2-bit
  143. eor image ; eor clears ~e2-bit
  144. sta image
  145. tc75
  146. lda image
  147. ldx cmdnum
  148. and struct,x ; match cmd template
  149. bne tc80
  150. rts
  151. tc80 sta erword ; **could be warning
  152. lda #badsyn ; err: bad syntax
  153. jmp cmderr
  154. .page 'parse'
  155. ;parse string
  156. ; looks for special chars,
  157. ; returning when var'bl char
  158. ; is found
  159. ; a: var'bl char
  160. ; x: in,out: index, filtbl+1
  161. ; y: in: index, cmdbuf
  162. ; out: new ptr, =0 if none
  163. ; (z=1) if y=0
  164. parse sta char ; save var'bl char
  165. pr10 cpy cmdsiz ; stay in string
  166. bcs pr30
  167. lda (cb),y ; match char
  168. iny
  169. cmp char
  170. beq pr35 ; found char
  171. cmp #'* ; match pattern chars
  172. beq pr20
  173. cmp #'?
  174. bne pr25
  175. pr20 inc patflg ; set pattern flag
  176. pr25 cmp #', ; match file separator
  177. bne pr10
  178. tya
  179. sta filtbl+1,x ; put ptrs in table
  180. lda patflg ; save pattern for ea file
  181. and #$7f
  182. beq pr28
  183. lda #$80 ; retain pattern presence...
  184. sta pattyp,x
  185. sta patflg ; ...but clear count
  186. pr28 inx
  187. cpx #mxfils-1
  188. bcc pr10 ; no more than mxfils
  189. pr30 ldy #0 ; y=0 (z=1)
  190. pr35 lda cmdsiz
  191. sta filtbl+1,x
  192. lda patflg
  193. and #$7f
  194. beq pr40
  195. lda #$80
  196. sta pattyp,x
  197. pr40 tya ; z is set
  198. rts
  199. ;initialize command tables, ptrs, etc.
  200. cmdset ldy buftab+cbptr
  201. beq cs08
  202. dey
  203. beq cs07
  204. lda cmdbuf,y
  205. cmp #cr
  206. beq cs08
  207. dey
  208. lda cmdbuf,y
  209. cmp #cr
  210. beq cs08
  211. iny
  212. cs07 iny
  213. cs08 sty cmdsiz ; set cmd string size
  214. cpy #cmdlen+1
  215. ldy #$ff
  216. bcc cmdrst
  217. sty cmdnum
  218. lda #longln ; long line error
  219. jmp cmderr
  220. ; clear variables,tables
  221. cmdrst
  222. ldy #0
  223. tya
  224. sta buftab+cbptr
  225. sta rec
  226. sta type
  227. sta typflg
  228. sta f1ptr
  229. sta f2ptr
  230. sta f1cnt
  231. sta f2cnt
  232. sta patflg
  233. sta erword
  234. ldx #mxfils
  235. cs10 sta filtbl-1,x
  236. sta entsec-1,x
  237. sta entind-1,x
  238. sta fildrv-1,x
  239. sta pattyp-1,x
  240. sta filtrk-1,x
  241. sta filsec-1,x
  242. dex
  243. bne cs10
  244. rts
  245. ; .end