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 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. .PAGE 'PARSE & EXECUTE'
  2. ;PARSE & EXECUTE STRING IN CMDBUF
  3. .SKIP
  4. PARSXQ
  5. LDA #0
  6. STA WBAM
  7. LDA LSTDRV
  8. STA DRVNUM
  9. JSR OKERR
  10. LDA ORGSA
  11. BPL PS05
  12. AND #$F
  13. CMP #$F
  14. BEQ PS05
  15. JMP OPEN
  16. PS05 JSR CMDSET ;SET VARIABLES,REGS
  17. LDA (CB),Y
  18. STA CHAR
  19. LDX #NCMDS-1 ;SEARCH CMD TABLE
  20. PS10 LDA CMDTBL,X
  21. CMP CHAR
  22. BEQ PS20
  23. DEX
  24. BPL PS10
  25. LDA #BADCMD ;NO SUCH CMD
  26. JMP CMDERR
  27. PS20 STX CMDNUM ;X= CMD #
  28. .SKIP
  29. CPX #PCMD ;CMDS NOT PARSED
  30. BCC PS30
  31. JSR TAGCMD ;SET TABLES, POINTERS &PATTERNS
  32. PS30 LDX CMDNUM
  33. LDA CJUMPL,X
  34. STA TEMP
  35. LDA CJUMPH,X
  36. STA TEMP+1
  37. JMP (TEMP) ;COMMAND TABLE JUMP
  38. .SKIP
  39. ; SUCCESSFUL COMMAND TERMINATION
  40. ENDCMD
  41. LDA #0
  42. STA WBAM
  43. ENDSAV
  44. LDA ERWORD
  45. BNE CMDERR
  46. ;
  47. LDY #0
  48. TYA
  49. STY TRACK
  50. .SKIP
  51. SCREND STY SECTOR ;SCRATCH ENTRY
  52. STY CB
  53. JSR ERRMSG
  54. JSR ERROFF
  55. SCREN1
  56. LDA DRVNUM
  57. STA LSTDRV
  58. TAX
  59. LDA #0
  60. STA NODRV,X
  61. JSR CLRCB
  62. JMP FREICH ;FREE INTERNAL CHANNEL
  63. ;
  64. CLRCB
  65. LDY #CMDLEN-1
  66. LDA #0
  67. CLRB2
  68. STA CMDBUF,Y
  69. DEY
  70. BPL CLRB2
  71. RTS
  72. ;
  73. ; COMMAND LEVEL ERROR PROCESSING
  74. CMDERR LDY #0
  75. STY TRACK
  76. STY SECTOR
  77. JMP CMDER2
  78. .SKIP
  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. .SKIP
  100. TAGCMD
  101. JSR PRSCLN
  102. BNE TC30
  103. TC25 LDA #NOFILE ;NONE, NO FILES
  104. JMP CMDERR
  105. TC30 DEY
  106. DEY
  107. STY FILTBL ;":"-1 STARTS FS1
  108. TXA
  109. BNE TC25 ;ERR: "," BEFORE ":"
  110. TC35 LDA #'= ;SEARCH: "="
  111. JSR PARSE
  112. TXA ;?FILE COUNT= 1-1?
  113. BEQ TC40
  114. LDA #%01000000 ;G1-BIT
  115. TC40 ORA #%00100001 ;E1,^E2-BITS
  116. STA IMAGE ;FS STRUCTURE
  117. INX
  118. STX F1CNT
  119. STX F2CNT ;INIT FOR NO FS2
  120. LDA PATFLG
  121. BEQ TC50
  122. LDA #%10000000 ;P1-BIT
  123. ORA IMAGE
  124. STA IMAGE
  125. LDA #0
  126. STA PATFLG ;CLEAR PATTERN FLAG
  127. TC50 TYA ;PTR TO FS2
  128. BEQ TC75 ; FS2 NOT HERE
  129. STA FILTBL,X
  130. LDA F1CNT ;FS2 IS HERE NOW,...
  131. STA F2PTR ;...NOW SET F2 PTR
  132. LDA #$8D ;FIND CR-SHIFTED
  133. JSR PARSE ;PARSE REST OF CMD STRING
  134. INX ;ADVANCE FILTBL PTR TO END
  135. STX F2CNT ;SAVE IT
  136. DEX ;RESTORE FOR TEST
  137. LDA PATFLG ;SAVE LAST PATTERN
  138. BEQ TC60 ;?ANY PATTERNS?
  139. LDA #%1000 ;YES, P2-BIT
  140. TC60 CPX F1CNT ;?F2CNT=F1CNT+1?
  141. BEQ TC70
  142. ORA #%0100 ;G2-BIT
  143. TC70 ORA #%0011 ;E2-BIT,^E2-BIT
  144. EOR IMAGE ;EOR CLEARS ^E2-BIT
  145. STA IMAGE
  146. TC75
  147. LDA IMAGE
  148. LDX CMDNUM
  149. AND STRUCT,X ;MATCH CMD TEMPLATE
  150. BNE TC80
  151. RTS
  152. TC80 STA ERWORD ;**COULD BE WARNING
  153. LDA #BADSYN ;ERR: BAD SYNTAX
  154. JMP CMDERR
  155. .SKIP
  156. .PAGE 'PARSE'
  157. ;PARSE STRING
  158. ; LOOKS FOR SPECIAL CHARS,
  159. ; RETURNING WHEN VAR'BL CHAR
  160. ; IS FOUND
  161. ; A: VAR'BL CHAR
  162. ; X: IN,OUT: INDEX, FILTBL+1
  163. ; Y: IN: INDEX, CMDBUF
  164. ; OUT: NEW PTR, =0 IF NONE
  165. ; (Z=1) IF Y=0
  166. .SKIP
  167. PARSE STA CHAR ;SAVE VAR'BL CHAR
  168. PR10 CPY CMDSIZ ;STAY IN STRING
  169. BCS PR30
  170. LDA (CB),Y ;MATCH CHAR
  171. INY
  172. CMP CHAR
  173. BEQ PR35 ;FOUND CHAR
  174. CMP #'* ;MATCH PATTERN CHARS
  175. BEQ PR20
  176. CMP #'?
  177. BNE PR25
  178. PR20 INC PATFLG ;SET PATTERN FLAG
  179. PR25 CMP #', ;MATCH FILE SEPARATOR
  180. BNE PR10
  181. TYA
  182. STA FILTBL+1,X ;PUT PTRS IN TABLE
  183. LDA PATFLG ;SAVE PATTERN FOR EA FILE
  184. AND #$7F
  185. BEQ PR28
  186. LDA #$80 ;RETAIN PATTERN PRESENCE...
  187. STA PATTYP,X
  188. STA PATFLG ;...BUT CLEAR COUNT
  189. PR28 INX
  190. CPX #MXFILS-1
  191. BCC PR10 ;NO MORE THAN MXFILS
  192. PR30 LDY #0 ;Y=0 (Z=1)
  193. PR35 LDA CMDSIZ
  194. STA FILTBL+1,X
  195. LDA PATFLG
  196. AND #$7F
  197. BEQ PR40
  198. LDA #$80
  199. STA PATTYP,X
  200. PR40 TYA ;Z IS SET
  201. RTS
  202. .SKIP
  203. ;INITIALIZE COMMAND TABLES, PTRS, ETC.
  204. .SKIP
  205. CMDSET LDY BUFTAB+CBPTR
  206. BEQ CS08
  207. DEY
  208. BEQ CS07
  209. LDA CMDBUF,Y
  210. CMP #CR
  211. BEQ CS08
  212. DEY
  213. LDA CMDBUF,Y
  214. CMP #CR
  215. BEQ CS08
  216. INY
  217. CS07 INY
  218. CS08 STY CMDSIZ ;SET CMD STRING SIZE
  219. .SKIP
  220. CPY #CMDLEN+1
  221. LDY #$FF
  222. BCC CMDRST
  223. STY CMDNUM
  224. LDA #LONGLN ;LONG LINE ERROR
  225. JMP CMDERR
  226. ; CLEAR VARIABLES,TABLES
  227. CMDRST
  228. LDY #0
  229. TYA
  230. STA BUFTAB+CBPTR
  231. STA REC
  232. STA TYPE
  233. STA TYPFLG
  234. STA F1PTR
  235. STA F2PTR
  236. STA F1CNT
  237. STA F2CNT
  238. STA PATFLG
  239. STA ERWORD
  240. LDX #MXFILS
  241. CS10 STA FILTBL-1,X
  242. STA ENTSEC-1,X
  243. STA ENTIND-1,X
  244. STA FILDRV-1,X
  245. STA PATTYP-1,X
  246. STA FILTRK-1,X
  247. STA FILSEC-1,X
  248. DEX
  249. BNE CS10
  250. RTS
  251. .SKIP
  252. .END