TPSRC8 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600
  1. OR.B CL,BH
  2. CALL errnz ;yes:
  3. B $46 ;70:Set base type out of range
  4. MOV CL,#$03 ;calculate component size
  5. SHR AX,CL ;(upper/8)-(lower/8)+1
  6. MOV CL,#$03
  7. SHR BX,CL
  8. SUB AX,BX
  9. INC AX
  10. MOV varsize,AX ;-> component size
  11. MOV AX,vartp ;type ptr
  12. MOV lower,AX ;-> type
  13. MOV.B varctp,#$03 ;tag: set
  14. CALL stotype ;store type
  15. setret RET ;"
  16. pointer CALL cptr ;pointer: prelim def
  17. JNZ ptrret ;ptr ? no: ret
  18. MOV AX,#$0000 ;tag: invisible
  19. CALL symword ;store in symtab
  20. PUSH symtop ;save pos
  21. CALL rdsymnew ;get name of ptr
  22. CALL symoffs ;write symtab offset
  23. POP lower ;restore pos of prelim offset
  24. MOV.B varctp,#$04 ;tag: pointer
  25. MOV.B varnest,#$FF ;flag: not fully defined
  26. MOV varsize,#$0004 ;size: 4 bytes
  27. CALL stotype ;store type
  28. ptrret RET ;"
  29. file CALL ctoken ;FILE ?
  30. W tkfile
  31. JNZ fileret ;no: ret
  32. CALL ctoken ;OF ?
  33. W tkof
  34. JNZ filuntp ;no: untyped file
  35. CALL rdtype ;read type
  36. CMP.B varctp,#$05 ;component type = file ?
  37. JB file2 ;:no
  38. CMP.B varctp,#$07
  39. JA file2 ;:no
  40. CALL err ;yes:
  41. B $44 ;'68:File components may not be files
  42. file2 MOV AX,vartp ;type ptr
  43. MOV lower,AX ;store it
  44. MOV.B varctp,#$05 ;typed file
  45. MOV varsize,#$004C ;set size
  46. CALL stotype ;store type
  47. fileret RET ;'
  48. filuntp MOV BP,ptcbeg ;untyped file
  49. B $81,$ED,$02,$00 ;point to it
  50. JMP stdtype ;"standard type
  51. text CALL ctoken ;TEXT ?
  52. W tktext
  53. JNZ textret ;no:ret
  54. CALL csqr1 ;[ ?
  55. JNZ textstd ;no: standard text file
  56. CALL rdintcn ;get integer constant
  57. OR BX,BX ;buffer size = 0 ?
  58. CALL errz ;yes:
  59. B $2D ;45:Constant out of range
  60. CALL esqr2 ;! ]
  61. ADD BX,#$4C ;add size of file var
  62. MOV varsize,BX ;-> var size
  63. MOV.B varctp,#$06 ;text file
  64. CALL stotype ;store type
  65. textret RET ;'
  66. textstd MOV BP,ptcbeg ;set ptr to std TEXT file
  67. B $81,$ED,$3E,$00
  68. JMP stdtype ;'standard type
  69. string CALL ctoken ;STRING ?
  70. W tkstr
  71. JNZ strrt ;no: ret
  72. CALL esqr1 ;! [
  73. CALL rdintcn ;get integer constant
  74. OR.B BH,BH ;> 255 ?
  75. CALL errnz ;yes:
  76. B $31 ;49:Invalid string length
  77. OR.B BL,BL ;length = 0 ?
  78. CALL errz ;yes:
  79. B $31 ;49:Invalid string length
  80. CALL esqr2 ;! ]
  81. INC BX ;len+1 (for length byte)
  82. MOV varsize,BX ;-> component size
  83. MOV.B varctp,#$08 ;tag: string
  84. CALL stotype ;store type
  85. strrt RET ;"
  86. scalar CALL cbrack1 ;do scalar list
  87. JNZ scalret ;( ? no: ret
  88. MOV BX,#$FFFF ;init counter
  89. scallp PUSH BX
  90. MOV AX,#$0200 ;tag: const
  91. CALL symword ;store tag word
  92. CALL rdsym ;read symbol
  93. MOV AL,scalcnt ;number of scalar type
  94. CALL symbyte ;store (elementary type)
  95. POP AX ;restore counter
  96. INC AX ;inc it
  97. PUSH AX ;save it again
  98. CALL symword ;store value of that const
  99. CALL symoffs ;write symtab offset
  100. CALL ccomma ;, ?
  101. POP BX
  102. JZ scallp ;yes: another element
  103. CALL ebrack2 ;! )
  104. MOV.B CL,scalcnt ;number of this type
  105. INC.B scalcnt ;count scalar types
  106. XOR DX,DX ;clear lower bound
  107. scalsto MOV.B varctp,CL ;store component type
  108. MOV upper,BX ;store upper bound
  109. MOV lower,DX ;store lower bound
  110. OR.B DH,BH ;byte possible ?
  111. MOV AX,#$0001 ;size = 1
  112. JZ scalbyt ;yes: ok
  113. INC AX ;size = 2
  114. scalbyt MOV varsize,AX ;store component size
  115. CALL stotype ;store type
  116. scalret RET ;"
  117. subrange CALL rdconst ;do subrange: read constant
  118. JNZ subret ;no good: ret
  119. PUSH CX ;save type, result
  120. PUSH BX
  121. CMP.B CL,#$0A ;scalar ?
  122. CALL errb ;no:
  123. B $33 ;51:Invalid subrange base type
  124. CALL ctoken ;.. ?
  125. W tk2dot
  126. CALL errnz ;no:
  127. B $0B ;11: .. expected
  128. CALL rdnumcn ;get constant
  129. POP DX ;restore component type
  130. POP AX ;restore lower bound
  131. CMP.B CL,AL ;same component type ?
  132. CALL errnz ;no:
  133. B $2C ;44:Type mismatch
  134. CMP BX,DX ;upper >= lower ?
  135. JGE scalsto ;yes: ok
  136. CALL err ;52:Lower bound > upper bound
  137. B $34 ;'
  138. subret RET ;"
  139. rdscaltp CALL subrange ;get scalar type: do subrange
  140. JZ rdscret ;done: ret
  141. CALL scalar ;do scalar list
  142. JZ rdscret ;done: ret
  143. CALL srchtype ;search type
  144. CALL errnz ;complex ?
  145. B $1E ;30:Simple type expected
  146. CMP.B varctp,#$0A ;scalar ?
  147. JNB rdscret ;:yes
  148. CALL err ;30:Simple type expected
  149. B $1E ;'
  150. rdscret RET ;"
  151. progpart MOV.B stklev,#$00 ;Program part
  152. MOV.B withnest,#$00 ;no with nesting
  153. CALL block ;do block
  154. PUSH pc ;save PC: jump to end of exit codes
  155. CALL ejump ;emit jump
  156. MOV BP,symtop2
  157. prpatch CMP BP,symtop ;= actual symtab top ?
  158. JZ prpend ;yes: end it
  159. MOV BX,[BP]-$02 ;get dest addr
  160. OR BX,BX ;exit ?
  161. JZ prpexit ;:yes
  162. SS:
  163. MOV AX,[BX]-$02 ;get dest offset (from label)
  164. SS:
  165. MOV.B CH,[BX]-$04 ;label defined ?
  166. CMP.B CH,#$FF ;no:
  167. CALL errz ;40:Undefined label
  168. B $28
  169. JMP.b prpgoto ;'patch GOTO
  170. prpexit POP AX ;get PC of end jump
  171. PUSH AX ;= dest
  172. MOV CH,#$00 ;level: 0
  173. prpgoto MOV BX,[BP]-$04 ;get addr of jump
  174. INC BX ;+1: point to offset
  175. MOV.B CL,[BP]-$05 ;stack level-dest stack level
  176. SUB.B CL,CH
  177. JNZ prpremov ;not zero: remove from stack
  178. CALL ptcjmp ;patch jump
  179. JMP.b prpnxt ;'
  180. prpremov CALL errb ;trying to jump into a WITH/FOR ?
  181. B $47 ;71:Invalid GOTO
  182. PUSH AX ;save PC of end jump
  183. CALL ptcjmppc ;patch jump to current pos
  184. prpremlp CALL epopax ;* POP AX
  185. DEC.B CL ;remove another var from stack ?
  186. JNZ prpremlp ;:no
  187. POP AX ;restore PC of end jump
  188. CALL ejump ;emit jump to end jump
  189. prpnxt SUB BP,#$05 ;go to next entry
  190. JMP prpatch ;'next one
  191. prpend POP BX ;restore PC of end jump
  192. INC BX ;point to offset
  193. JMP ptcjmppc ;"patch jump
  194. block CALL statemnt ;do block: do statement
  195. CALL ctoken ;END ?
  196. W tkend
  197. JZ blkret ;yes: done
  198. CALL esemi2 ;! ;
  199. JMP block ;'next statement
  200. blkret RET ;"
  201. statemnt MOV.B semiflg,#$FF ;Do statement
  202. MOV AX,direct ;get compiler directives
  203. MOV direcsv,AX ;use copy during statement
  204. TEST direcsv,#$0010 ;user interrupt ?
  205. JZ stmnoint ;:no
  206. MOV.B usrint,#$FF ;set flag: used
  207. CALL ecode ;* INT 3
  208. B $01,$CC
  209. stmnoint CALL ckey ;search keyword - code level
  210. B $02
  211. W tkbegin
  212. JZ stmstd2 ;:found
  213. CALL rdvar ;search var
  214. JNZ stmproc ;:not found
  215. JMP cassign ;'do assignment
  216. stmproc MOV CX,#$0500 ;search procedure
  217. CALL search
  218. JNZ stmlabel ;:not found
  219. JMP cproc ;'do procedure
  220. stmlabel MOV CX,#$0100 ;search label
  221. CALL search
  222. JZ clabel ;:found
  223. MOV CX,#$0600 ;search function
  224. CALL search
  225. JNZ stmstd ;:not found
  226. JMP assgnvar ;'do function: assign return var
  227. stmstd CALL ckey ;search keyword: std procedures
  228. B $02
  229. W stdprocs
  230. JZ stmstd2 ;:found
  231. RET ;'
  232. stmstd2 CS: ;jump to procedure compilation
  233. JMP [BX] ;"routine
  234. clabel CALL ecolon ;! : - do label
  235. MOV AL,lexnest ;lexical level
  236. CMP.B AL,[BP]-$03 ;= that of label ?
  237. CALL errnz ;no:
  238. B $48 ;72:Label not within current block
  239. CMP.B [BP]-$04,#$FF ;label already defined ?
  240. CALL errnz ;43:Duplicate ID or label
  241. B $2B
  242. MOV AL,stklev ;store stack level
  243. MOV.B [BP]-$04,AL ;in label entry
  244. MOV AX,pc ;store offset
  245. MOV [BP]-$02,AX
  246. JMP statemnt ;"do statement
  247. if CALL excond ;IF: evaluate condition
  248. MOV AL,brnchop ;branch opcode
  249. MOV AH,#$03 ;offset
  250. CALL eword ;emit branch
  251. PUSH pc ;save pos of jump
  252. CALL ejump ;emit jump
  253. CALL ctoken ;THEN ?
  254. W tkthen
  255. CALL errnz ;no:
  256. B $11 ;17:THEN expected
  257. CALL statemnt ;do statement
  258. CALL ctoken ;ELSE ?
  259. W tkelse
  260. JNZ ifnoelse ;:no
  261. POP BX ;get pos of THEN-jump
  262. PUSH pc ;save pos of second jump
  263. CALL ejump ;emit second jump
  264. INC BX ;point to offset
  265. CALL ptcjmppc ;patch jump addr: to ELSE-part
  266. CALL statemnt ;do statement
  267. ifnoelse POP BX ;restore pos
  268. INC BX ;point to offset
  269. JMP ptcjmppc ;"patch jump offset
  270. while PUSH pc ;WHILE: save loop beg addr
  271. CALL excond ;evaluate condition
  272. MOV AL,brnchop ;branch opcode
  273. MOV AH,#$03 ;offset
  274. CALL eword ;emit branch
  275. PUSH pc ;save pos of jump to end
  276. CALL ejump ;emit it
  277. CALL ctoken ;DO ? Bug: not checked
  278. W tkdo ;(try it !!)
  279. CALL statemnt ;do statement
  280. POP BX ;pos of jump
  281. POP AX ;pos of loop beg
  282. CALL ejump ;emit jump to loop beg
  283. INC BX ;point to offset
  284. JMP ptcjmppc ;"patch jump to loop end
  285. repeat PUSH pc ;REPEAT: save loop beg addr
  286. reploop CALL statemnt ;do statement
  287. CALL ctoken ;UNTIL ?
  288. W tkuntil
  289. JZ repend ;yes: end it
  290. CALL esemi2 ;! ;
  291. JMP reploop ;'
  292. repend CALL excond ;evaluate condition
  293. MOV AL,brnchop ;branch opcode
  294. MOV AH,#$03 ;offset
  295. CALL eword ;emit branch
  296. POP AX ;restore pos: loop beg
  297. JMP ejump ;"emit jump to loop beg
  298. for MOV CX,#$0400 ;FOR
  299. CALL search ;search loop var
  300. CALL errnz ;not found:
  301. B $29 ;41:Unknown ID or syntax error
  302. CALL getvprm ;get var parms
  303. MOV.B indflg,#$00 ;not indexed
  304. CMP.B indptflg,#$00 ;var indirect ?
  305. JNZ forerr ;yes: error
  306. CMP.B varctp,#$0A ;scalar ?
  307. JNB forstrt ;:yes, ok
  308. forerr CALL err ;30:Simple type expected
  309. B $1E ;'
  310. forstrt CALL pushe1 ;push var entry
  311. MOV AL,varctp ;save component type
  312. PUSH AX
  313. CALL eassign ;! :=
  314. CALL exprax ;expression -> AX
  315. CALL epushax ;* PUSH AX
  316. POP AX ;component type
  317. PUSH AX
  318. CMP.B AL,CL ;= type read ?
  319. CALL errnz ;no:
  320. B $2C ;44:Type mismatch
  321. CALL ckey ;TO or DOWNTO ?
  322. B $04
  323. W tkto
  324. CALL errnz ;not found:
  325. B $12 ;18:TO or DOWNTO expected
  326. MOV forptr,BX ;store direction pointer
  327. CALL exprax ;expression -> AX
  328. POP AX ;test component type
  329. CMP.B AL,CL
  330. CALL errnz ;44:Type mismatch
  331. B $2C
  332. CALL ctoken ;DO ?
  333. W tkdo
  334. CALL errnz ;no:
  335. B $0D ;13:DO expected
  336. CALL pope1 ;restore entry from stack
  337. CALL ecode ;* POP CX
  338. B $04,$59,$91,$2B,$C8 ;* XCHG CX,AX
  339. MOV BX,forptr ;* SUB CX,AX
  340. CS: ;get flag: pointer to table entry
  341. MOV.B AL,[BX] ;get branch
  342. CALL ebyte ;emit it
  343. CALL ecode ;* branch offset
  344. B $04,$03,$E9,$00,$00 ;* JUMP ....
  345. PUSH pc ;save jump pos
  346. CS:
  347. MOV.B AL,[BX]$01 ;emit INC/DEC
  348. CALL ebyte
  349. CALL estore2 ;store var
  350. PUSH pc ;save PC
  351. CALL ecode ;* PUSH CX
  352. B $01,$51
  353. CALL pushe1 ;save var entry
  354. PUSH forptr ;save for-ptr
  355. INC.B stklev ;space used on stack (counter!)
  356. CALL statemnt ;do statement
  357. DEC.B stklev ;remove from stack
  358. POP forptr ;restore FOR-ptr
  359. CALL pope1 ;restore var entry
  360. CALL ecode ;* POP CX
  361. B $01,$59 ;(get counter var from stack)
  362. MOV BX,forptr
  363. CS:
  364. MOV.B AL,[BX]$02 ;INC/DEC CX
  365. CALL ebyte ;emit
  366. PUSH pc ;save PC
  367. CALL eword ;emit (dummy) branch to loop end
  368. CS:
  369. MOV.B DH,[BX]$03 ;INC or DEC var ?
  370. MOV DL,#$FF ;word opcode
  371. CMP varsize,#$01 ;test component size
  372. JA forword ;:word
  373. MOV DL,#$FE ;byte obcode
  374. forword CALL einstr ;emit INC loop var
  375. POP BX ;restore PC
  376. POP AX ;restore PC: beg of loop
  377. CALL ejump ;emit jump to loop beg
  378. MOV AX,pc ;PC-dest-2
  379. SUB AX,BX
  380. DEC AX
  381. DEC AX
  382. MOV.B AH,AL ;-> offset
  383. MOV AL,#$74 ;JZ
  384. CALL ptcjmp2 ;patch branch: to loop end
  385. POP BX ;restore addr: loop beg-2
  386. DEC BX
  387. DEC BX
  388. JMP ptcjmppc ;"patch jump to loop end
  389. case CALL exscal ;CASE: get scalar expression
  390. MOV.B casectp,CL ;store CASE-type
  391. CALL expof ;! OF
  392. XOR CX,CX ;clear counter: main
  393. PUSH CX
  394. caselp1 XOR CX,CX ;clear counter: sub
  395. caselp2 PUSH CX ;save it
  396. CALL cmpbound ;get element / lower bound
  397. CALL ctoken ;.. ?
  398. W tk2dot
  399. MOV DL,#$74 ;JZ
  400. JNZ casenrng ;:no
  401. CALL ecode ;* JL +05
  402. B $02,$7C,$05
  403. CALL cmpbound ;get upper bound
  404. MOV DL,#$7E ;JG
  405. POP CX ;count: range done
  406. INC.B CH ;count space used
  407. PUSH CX
  408. casenrng POP CX ;restore counter
  409. INC.B CH ;count space used
  410. INC.B CL ;count labels
  411. PUSH DX ;save opcode
  412. PUSH pc ;save pos
  413. CALL eword ;emit branch op
  414. CALL ccomma ;, ?
  415. JNZ caselab ;:no
  416. CMP.B CH,#$14 ;branch distance ok ?
  417. JB caselp2 ;:yes
  418. CALL ecode ;* JMP +02
  419. B $02,$EB,$02 ;make a hip
  420. XOR.B CH,CH ;clear space used
  421. casehip POP BX ;get branch pos
  422. POP DX ;get opcode
  423. MOV AX,pc ;PC-pos-2
  424. SUB AX,BX
  425. DEC AX
  426. DEC AX
  427. MOV.B AH,AL ;-> offset
  428. MOV.B AL,DL ;branch opcode
  429. CALL ptcjmp2 ;patch in branch
  430. LOOP casehip ;:another one
  431. MOV DL,#$EB ;JMP
  432. PUSH DX ;remember opcode
  433. PUSH pc ;& position
  434. CALL eword ;emit it (dummy)
  435. MOV CX,#$0101 ;space counter
  436. JMP caselp2 ;'continue
  437. caselab CALL ecolon ;! :
  438. CALL ejump ;emit jump to next case label
  439. XOR.B CH,CH ;clear space counter
  440. caseres POP BX ;fill in branches - as above !
  441. POP DX
  442. MOV AX,pc
  443. SUB AX,BX
  444. DEC AX
  445. DEC AX
  446. MOV.B AH,AL
  447. MOV.B AL,DL
  448. CALL ptcjmp2 ;patch it
  449. LOOP caseres ;:another
  450. POP CX ;restore main counter
  451. PUSH pc ;save current pos
  452. INC CX ;count case labels
  453. PUSH CX ;save again
  454. MOV AL,casectp ;save type
  455. PUSH AX ;(CASE may be nested !)
  456. CALL statemnt ;do statement
  457. POP AX ;restore type
  458. MOV casectp,AL
  459. CALL csemi ;semicolon ?
  460. MOV DL,#$FF ;set flag
  461. JZ casesemi ;:yes
  462. XOR.B DL,DL ;clr flag
  463. casesemi PUSH DX ;save it
  464. CALL ctoken ;END ?
  465. W tkend
  466. POP DX ;restore flag
  467. JZ caseres2 ;:yes
  468. CALL ejump ;emit jump to end of CASE
  469. POP CX ;counter
  470. POP BX ;pos of last comparison
  471. PUSH pc ;save pos of jump to CASE-end
  472. PUSH CX ;save counter
  473. DEC BX ;pos-2
  474. DEC BX
  475. CALL ptcjmppc ;patch jump
  476. PUSH DX ;flag
  477. CALL ctoken ;ELSE ?
  478. W tkelse
  479. POP DX ;'flag
  480. JZ caseelse ;:yes
  481. OR.B DL,DL ;test flag
  482. JZ caseend ;:no semicolon
  483. JMP caselp1 ;'case loop
  484. caseend CMP.B semiflg,#$00 ;flag for semi error
  485. CALL errz ;cleared:
  486. B $0E ;14:END expected
  487. CALL err
  488. B $29 ;"41:Unknown ID or syntax error
  489. caseelse CALL statemnt ;ELSE-part: do statement
  490. CALL ctoken ;END ?
  491. W tkend
  492. JZ caseres2 ;:yes
  493. CALL esemi2 ;! ;
  494. JMP caseelse ;'
  495. caseres2 POP CX ;number of jumps
  496. caseres3 POP BX ;addr of jump-2
  497. DEC BX
  498. DEC BX ;patch jumps to end of CASE
  499. CALL ptcjmppc
  500. LOOP caseres3 ;:another
  501. RET ;"
  502. cmpbound CALL rdnumcn ;get bound: read num constant
  503. CMP.B CL,casectp ;correct type ?
  504. CALL errnz ;46:Constant and CASE selector type
  505. B $2E ;does not match
  506. MOV AL,#$3D ;* CMP AX,i
  507. CALL ebyte
  508. XCHG AX,BX ;emit constant: bound
  509. JMP eword ;"
  510. goto MOV CX,#$0100 ;do GOTO
  511. CALL search ;search label
  512. CALL errnz ;not found:
  513. B $28 ;40:Undefined label
  514. MOV.B AL,[BP]-$03 ;lexical level
  515. CMP.B AL,lexnest ;= current ?
  516. CALL errnz ;no:
  517. B $48 ;72:Label not within current block
  518. MOV AX,BP ;symtab-ptr of label
  519. exit CALL symword ;store in symtab
  520. MOV AX,pc ;store PC
  521. CALL symword
  522. MOV AL,stklev ;store stack level
  523. CALL symbyte
  524. JMP ejump ;"emit jump - resolved at block end
  525. with MOV AL,withnest ;WITH: nesting level
  526. MOV.B AH,stklev ;stack level
  527. PUSH AX ;save them
  528. withlp CMP.B withnest,#$10 ;too much ?
  529. CALL errz ;yes:
  530. B $61
  531. CALL rdvar ;get var
  532. CALL errnz ;not found:
  533. B $29 ;41:Unknown ID or syntax error
  534. CMP.B varctp,#$02 ;type = record ?
  535. CALL errnz ;no:
  536. B $1D ;29:Record variable expected
  537. CMP.B indflg,#$00 ;indexed ?
  538. JNZ withindx ;:yes
  539. MOV.B AH,varseg ;segment and offset
  540. MOV DX,varofs ;already known
  541. JMP.b withsto ;'store in WITH-buffer
  542. withindx CALL varptr2 ;get var ptr
  543. CALL epushdi ;* PUSH DI
  544. ADD.B stklev,#$02 ;4 bytes on stack
  545. MOV.B AH,stklev ;get stack level
  546. MOV DX,#$FFFF ;dummy pos: variable
  547. withsto MOV.B BL,withnest
  548. XOR.B BH,BH ;nesting level*4 -> BX
  549. SHL BX,1 ;offset into WITH-buffer
  550. SHL BX,1
  551. MOV AL,varnest ;store type, position
  552. MOV [BX]withtab,AX ;-> WITH-buffer
  553. MOV [BX]withtab1,DX
  554. INC.B withnest ;inc nesting level
  555. CALL ccomma ;, ?
  556. JZ withlp ;yes: repeat
  557. CALL ctoken ;DO ?
  558. W tkdo
  559. CALL errnz ;no:
  560. B $0D ;13:DO expected
  561. CALL statemnt ;do statement
  562. MOV.B CL,stklev ;stack usage
  563. POP AX ;restore stack usage, nesting level
  564. MOV withnest,AL
  565. MOV.B stklev,AH
  566. SUB.B CL,AH ;remove from stack ?
  567. JZ withret ;:nothing to remove
  568. MOV AX,#$C483 ;* ADD SP,...
  569. CALL eword
  570. MOV.B AL,CL ;var count * 2
  571. SHL.B AL,1
  572. CALL ebyte ;emit byte
  573. withret RET ;"
  574. inline CALL ebrack1 ;! ( - Inline
  575. inllp MOV.B inlinflg,#$02 ;flag: byte mode
  576. MOV AL,#$3E
  577. CALL chkal ;> ?
  578. JZ inltp ;:yes
  579. MOV.B inlinflg,#$01 ;word mode
  580. MOV AL,#$3C ;< ?
  581. CALL chkal
  582. JZ inltp ;:yes
  583. MOV.B inlinflg,#$00 ;normal mode
  584. inltp XOR BX,BX ;clear number
  585. XOR CX,CX ;clear neg flag
  586. inlexlp PUSH BX ;save
  587. PUSH CX
  588. CALL rdconst ;read num constant
  589. JNZ inlnocn ;:no good
  590. CMP.B CL,#$0A ;type = integer ?
  591. CALL errnz ;no:
  592. B $16 ;22:Integer constant expected
  593. XCHG AX,BX ;result -> AX
  594. JMP.b inlatom ;'
  595. inlnocn CMP.B inlinflg,#$00 ;normal mode ?
  596. JNZ inlpc ;:no
  597. MOV.B inlinflg,#$02 ;set word mode
  598. inlpc MOV AL,#$2A ;* ?
  599. CALL chkal
  600. JNZ inlvar ;:no
  601. MOV AX,pc ;PC -> result
  602. JMP.b inlatom ;'
  603. inlvar MOV CX,#$0400 ;search var
  604. CALL search
  605. JNZ inlproc ;:not found
  606. CALL getvprm ;get var parms
  607. MOV AX,varofs ;get var offset
  608. JMP.b inlatom ;'
  609. inlproc MOV CX,#$0500 ;search proc
  610. CALL search
  611. JZ inlproc2 ;:found
  612. MOV CX,#$0600 ;search func
  613. CALL search
  614. CALL errnz ;not found:
  615. B $4A ;74:Inline error
  616. inlproc2 MOV AX,[BP]-$08 ;get offset
  617. inlatom POP CX ;restore
  618. POP BX
  619. JCXZ inlnoneg ;:no negation
  620. NEG AX ;negate result
  621. inlnoneg ADD BX,AX ;add to number
  622. XOR CX,CX ;clear neg flag
  623. MOV AL,#$2B ;+ ?
  624. CALL chkal
  625. JZ inlexlp ;:yes
  626. DEC CX ;set neg flag
  627. MOV AL,#$2D ;- ?
  628. CALL chkal
  629. JZ inlexlp ;:yes
  630. XCHG AX,BX ;else: end of expression
  631. CMP.B inlinflg,#$01 ;byte mode ?
  632. JA inlword ;:word mode
  633. JZ inlbyte ;:byte mode
  634. OR.B AH,AH ;normal mode: result > 255 ?
  635. JNZ inlword ;:yes
  636. inlbyte CALL ebyte ;emit byte
  637. JMP.b inlchk ;'
  638. inlword CALL eword ;emit word
  639. inlchk MOV AL,#$2F ;/ ?
  640. CALL chkal
  641. JNZ inlend ;no: end it
  642. JMP inllp ;'loop back: next expression
  643. inlend CALL ebrack2 ;! )
  644. RET ;"
  645. cproc CALL estkchk ;procedure call: stack checking
  646. cproc2 PUSH BP ;save symtab pos
  647. MOV.B CL,[BP]-$10 ;parameter count
  648. SUB BP,#$10 ;go to parameter
  649. OR.B CL,CL ;any parms ?
  650. JNZ cprparms ;:yes
  651. JMP cprnoprm ;'none - end it
  652. cprparms CALL ebrack1 ;! (
  653. cprlp1 PUSH CX ;parameter loop
  654. PUSH BP ;save counter, symtab pos
  655. MOV CX,[BP]-$04 ;parm count same type
  656. MOV BP,[BP]-$02 ;type ptr
  657. CALL getvprm2 ;get type parms
  658. cprlp2 PUSH CX ;save counter
  659. OR.B CH,CH ;VAR-parameter ?
  660. JNZ cprvar ;:yes
  661. CMP.B varctp,#$03 ;set ?
  662. JB cprcpl ;:below, complex var
  663. CALL exprsave ;get expression -> AX/stack
  664. CALL typechk ;type checking, conversions
  665. CALL erngchk ;range check
  666. CMP.B varctp,#$0A ;scalar ?
  667. JNB cprscal ;:yes
  668. CMP.B varctp,#$04 ;ptr ?
  669. JNZ cprstr ;:no
  670. CALL ecode ;* PUSH DX
  671. B $01,$52
  672. cprscal CALL epushax ;* PUSH AX
  673. JMP.b cprnext ;'next parm
  674. cprstr CMP.B varctp,#$08 ;string ?
  675. JNZ cprset ;:no
  676. MOV.B AH,varsize ;get max length
  677. DEC.B AH
  678. MOV AL,#$B1
  679. CALL eword ;* MOV CL,max_len
  680. MOV AX,#xstrparm ;adapt string size
  681. CALL ecall ;* CALL xstrparm
  682. JMP.b cprnext ;'next parm
  683. cprset CMP.B varctp,#$03 ;set ?
  684. JNZ cprnext ;no:next parm
  685. CALL esetfac ;calc set crunch factor
  686. MOV AX,#xsetparm ;adapt set size
  687. CALL ecall ;* CALL xsetparm
  688. JMP.b cprnext ;'next parm
  689. cprcpl CALL pushe1 ;save var entry: complex var
  690. CALL fullvar ;do full var
  691. CALL errnz ;no good:
  692. B $29 ;41:Unknown ID or syntax error
  693. CALL varptr2 ;get var ptr
  694. MOV AX,varsize ;component size
  695. CALL emovcxi ;* MOV CX,compo_size
  696. MOV AX,#xblkparm ;copy complex var to stack
  697. CALL ecall ;* CALL xblkparm
  698. JMP.b cprchk ;'check type
  699. cprvar CALL pushe1 ;save entry - VAR-parameter
  700. CALL varptr ;get var ptr
  701. CALL epushdi ;* PUSH DI
  702. cprchk CALL copye2 ;copy entry from stack
  703. CMP.B var2ctp,#$00 ;type = 0 ?
  704. JZ cpruntyp ;yes: untyped
  705. CALL tchkstrc ;type checking struct vars
  706. cpruntyp CALL pope1 ;restore entry
  707. cprnext POP CX ;restore counter
  708. DEC.B CL ;another parm of same type ?
  709. JZ cprskip ;:no
  710. CALL ecomma ;! ,
  711. JMP cprlp2 ;'loop back - same type
  712. cprskip POP BP ;restore symtab pos
  713. SUB BP,#$04 ;go to next parm
  714. MOV.B AL,[BP]$00 ;get cnt
  715. cprsklp DEC BP
  716. MOV.B CL,[BP]$00 ;skip var entries
  717. XOR.B CH,CH
  718. SUB BP,CX ;skip name
  719. DEC.B AL ;count down
  720. JNZ cprsklp ;:another
  721. POP CX ;restore count
  722. DEC.B CL ;another parameter ?
  723. JZ cprend ;:no
  724. CALL ecomma ;! ,
  725. JMP cprlp1 ;'loop back
  726. cprend CALL ebrack2 ;! )
  727. cprnoprm POP BP ;symtab pos
  728. MOV AX,[BP]-$0E ;overlay ?
  729. OR AX,AX
  730. JZ cprnoovr ;:no
  731. CALL emovaxi ;* MOV AX,proc_len
  732. MOV AX,[BP]-$0C ;get file offset
  733. CALL emovdxi ;* MOV DX,file_offs
  734. cprnoovr MOV AX,[BP]-$08 ;get proc offset
  735. JMP ecall ;"* CALL proc
  736. estkchk TEST direcsv,#$0020 ;Stack checking ?
  737. JZ estkret ;:switched off
  738. MOV AX,[BP]-$0A ;get space needed
  739. CALL emovcxi ;* MOV CX,space_needed
  740. MOV AX,#xchkstk
  741. CALL ecall ;* CALL xchkstk
  742. estkret RET ;"
  743. cassign CMP.B varctp,#$00 ;Do assignment: untyped ?
  744. JZ asnerr ;yes: error
  745. CMP.B varctp,#$05 ;file var ?
  746. JB asnscal ;:no
  747. CMP.B varctp,#$07
  748. JA asnscal ;:no
  749. asnerr CALL err ;files cannot be assigned !
  750. B $36 ;'54:Illegal assignment
  751. asnscal CMP.B varctp,#$0A ;scalar ?
  752. JNB asnscal2 ;:yes
  753. CMP.B varctp,#$04 ;pointer ?
  754. JNZ asnvar ;:no
  755. asnscal2 CMP.B varseg,#$FD ;segment = ES ?
  756. JNZ asnnoseg ;:no
  757. MOV.B flgpshes,#$01 ;set flag: PUSH ES
  758. asnnoseg CMP.B indflg,#$00 ;indexed ?
  759. JZ asn2 ;:no
  760. MOV.B flgpshdi,#$01 ;set flag: PUSH DI
  761. JMP.b asn2 ;'
  762. asnvar CALL varptr2 ;get var ptr
  763. CALL epushdi ;* PUSH DI
  764. asn2 CALL eassign ;! :=
  765. CMP.B varctp,#$03 ;set ?
  766. JB asncpl ;:no, complex type
  767. CALL pushe1 ;save dest var entry
  768. PUSH pc ;save PC
  769. CALL expr ;evaluate expression
  770. POP AX ;old = new PC ?
  771. SUB AX,pc
  772. MOV flgpshes,#$0000 ;clear flag: PUSH ES
  773. PUSH AX ;save difference
  774. CALL expload ;get expression, ready for store
  775. POP AX
  776. CALL pope1 ;restore dest var entry
  777. PUSH AX ;save diff
  778. CALL typechk ;type checking, conversions
  779. POP AX
  780. CMP.B varctp,#$0A ;scalar ?
  781. JNB asnscal3 ;:yes
  782. CMP.B varctp,#$04 ;pointer ?
  783. JNZ asnstore ;:no
  784. asnscal3 OR AX,AX ;test diff
  785. JZ asnstore ;none: ok
  786. CMP.B indflg,#$00 ;indexed ?
  787. JZ asnnoind ;:no
  788. CALL ecode ;* POP DI - restore ptr
  789. B $01,$5F
  790. asnnoind CMP.B varseg,#$FD ;segment = ES ?
  791. JNZ asnstore ;:no
  792. CALL ecode ;* POP ES
  793. B $01,$07
  794. asnstore JMP estore ;'Store var
  795. asncpl CALL pushe1 ;store dest var entry
  796. CALL fullvar ;do full var
  797. CALL errnz ;no good:
  798. B $29 ;41:Unknown ID or syntax error
  799. CALL varptr2 ;get var ptr
  800. CALL pope2 ;restore dest var entry
  801. CALL tchkstrc ;type checking - struct vars
  802. MOV AX,var2size ;component size
  803. CALL emovcxi ;* MOV CX,comp_size
  804. MOV AX,#xmovevar
  805. JMP ecall ;'* CALL xmovevar
  806. typechk CMP.B varctp,#$09 ;Type checking, conversions
  807. JNZ tckstr ;:no real
  808. CMP.B CL,#$0A ;now integer ?
  809. JNZ tckchk ;:no
  810. MOV AX,#xintreal ;conversion int -> real
  811. CALL ecall ;* CALL xintreal
  812. MOV CL,#$09 ;now real
  813. JMP.b tckchk ;'
  814. tckstr CMP.B varctp,#$08 ;string expected ?
  815. JNZ tckch ;:no
  816. CMP.B CL,#$0C ;result = char ?
  817. JNZ tckchk ;:no
  818. CALL ecode ;* MOV AH,AL
  819. B $05,$8A,$E0,$B0,$01,$50 ;* MOV AL,01
  820. MOV CL,#$08 ;* PUSH AX
  821. JMP.b tckchk ;'now string
  822. tckch CMP.B varctp,#$0C ;char expected ?
  823. JNZ tckchk ;:no
  824. CMP.B CL,#$08 ;result = string ?
  825. JNZ tckchk ;:no
  826. MOV AX,#xstrch ;convert to char
  827. CALL ecall ;* CALL xstrch
  828. MOV CL,#$0C ;now char
  829. tckchk CMP.B CL,varctp ;type = expected ?
  830. JNZ tckerr ;no: error
  831. CMP.B CL,#$03 ;set ?
  832. JNZ tckptr ;:no
  833. OR.B CH,CH ;constant ?
  834. JZ tckret ;yes: ret
  835. MOV BP,lower ;same base type ?
  836. CMP.B CH,[BP]-$08
  837. JZ tckret ;yes: ret
  838. tckerr CALL err ;44:Type mismatch
  839. B $2C ;'
  840. tckptr CMP.B CL,#$04 ;pointer ?
  841. JNZ tckret ;no: ret
  842. MOV AX,functp ;type pointer
  843. OR AX,AX ;untyped ?
  844. JZ tckret ;yes: ret
  845. CMP AX,lower ;compare types
  846. JNZ tckerr ;different: error
  847. tckret RET ;"
  848. tchkstrc MOV AL,varctp ;Type checking struct vars
  849. CMP AL,#$00 ;type expected: untyped ?
  850. JZ tcserr ;yes: type mismatch
  851. MOV DL,#$BF ;check everything
  852. CMP AL,#$0A ;scalar ?
  853. JNB tcschk ;yes: check it
  854. CMP AL,#$08 ;string ?
  855. JNZ tcsnostr ;:no
  856. MOV DL,#$80 ;check type only
  857. TEST direcsv,#$0040 ;string checking ?
  858. JZ tcschk ;:no
  859. tcsnostr MOV DL,#$83 ;check type, component size
  860. CMP AL,#$06 ;text, untyped file ?
  861. JNB tcschk ;:check it
  862. MOV DL,#$B3
  863. CMP AL,#$03 ;set ?
  864. JNB tcschk ;:check it
  865. MOV DL,#$C3 ;check type, rec nest, size
  866. CMP AL,#$02 ;record ?
  867. JNB tcschk ;:check it
  868. CMP upper,#$00 ;second type
  869. MOV DL,#$BF ;check everything
  870. JNZ tcschk ;:check it
  871. MOV BP,upper2 ;second type
  872. CMP.B [BP]-$08,#$0A ;scalar index ?
  873. JNZ tcserr ;no: type mismatch
  874. MOV DL,#$B3 ;check type, lower, upper, size
  875. tcschk MOV SI,#varctp ;check buffers
  876. MOV DI,#var2ctp
  877. MOV CX,#$0008 ;check 8 bytes
  878. tcschklp ROL.B DL,1 ;test this byte ?
  879. JNB tcsnochk ;:no
  880. MOV.B AL,[SI] ;compare
  881. CMP.B AL,[DI]
  882. JNZ tcserr ;different: error
  883. tcsnochk INC SI ;next byte
  884. INC DI
  885. LOOP tcschklp ;:another
  886. RET ;'
  887. tcserr CALL err ;44:Type mismatch
  888. B $2C ;"
  889. assgnvar CALL getvprm ;get var parms
  890. CMP.B indptflg,#$00 ;indirect ?
  891. CALL errnz ;yes:
  892. B $29 ;41:Unknown ID or syntax error
  893. CALL rdvarind ;do indexing
  894. JMP cassign ;"do assignment
  895. passign CALL brfilvar ;ASSIGN: get file var
  896. MOV AX,#xassign ;normal Assign
  897. CMP.B CL,#$06 ;text file ?
  898. JNZ pasgn2 ;:no
  899. MOV AX,#xassgntx ;assign text file
  900. CALL pasgn2 ;get params
  901. JMP.b pfilchk ;'do checking
  902. pasgn2 PUSH AX ;save call addr
  903. CALL epushdi ;* PUSH DI
  904. CALL ecomma ;! ,
  905. CALL exstr ;get string expr
  906. POP AX ;restore call addr
  907. pemit PUSH AX ;save call addr
  908. CALL ebrack2 ;! )
  909. POP AX ;call addr
  910. JMP ecall ;"emit call
  911. prename CALL brfilvar ;RENAME: get file var
  912. MOV AX,#xrename
  913. CALL pasgn2 ;get string, emit call
  914. JMP.b pfilchk ;"do checking
  915. perase CALL brfilvar ;ERASE: get file var
  916. MOV AX,#xerase
  917. JMP.b pfilend ;'put it
  918. pchain MOV AX,#xchain ;CHAIN
  919. JMP.b pexec2 ;'put it
  920. pexecute MOV AX,#xexecute ;EXECUTE
  921. pexec2 PUSH AX ;save addr
  922. CALL brfilvar ;get file var
  923. pexec3 POP AX ;restore addr
  924. pfilend CALL pemit ;test ), emit call
  925. pfilchk JMP efilchk ;"do checking
  926. pseek CALL brfilvar ;SEEK, LONGSEEK: get file var
  927. CMP.B CL,#$06 ;text file ?
  928. CALL errz ;yes:
  929. B $3F ;63:Textfiles are not allowed here
  930. CALL epushdi ;* PUSH DI
  931. CALL ecomma ;! ,
  932. CALL exnum ;get num expr
  933. MOV AX,#xseek
  934. CMP.B CL,#$0A ;integer ?
  935. JZ pseekint ;:yes
  936. MOV AX,#xlngseek ;real...
  937. pseekint JMP pfilend ;"test ), emit call, check
  938. pappend CALL brfilvar ;APPEND: get file var
  939. CMP.B CL,#$06 ;text file ?
  940. CALL errnz ;no:
  941. B $23 ;35:Textfile expected
  942. MOV AX,varsize ;component size
  943. SUB AX,#$004C ;sub size of file var
  944. CALL emovcxi ;* MOV CX,buf_size
  945. MOV AX,#xappndtx
  946. JMP pfilend ;"test ), emit call, check
  947. preset MOV BX,#vreset ;RESET
  948. JMP.b prw2 ;'ptr into vector table
  949. prewrite MOV BX,#vrewrite ;REWRITE
  950. prw2 PUSH BX ;save ptr
  951. CALL brfilvar ;get file var
  952. CMP.B varctp,#$05 ;typed file ?
  953. JNZ prwtext ;:no
  954. MOV BP,lower ;type ptr
  955. CALL getparm ;get var parms
  956. MOV AX,var2size ;component size
  957. CALL emovcxi ;* MOV CX,compo_size
  958. JMP.b prwemit ;'
  959. prwtext CMP.B varctp,#$06 ;text file ?
  960. JNZ prwuntp ;:no
  961. MOV AX,varsize ;var size-base size
  962. SUB AX,#$004C
  963. CALL emovcxi ;* MOV CX,buf_size
  964. JMP.b prwemit ;'
  965. prwuntp CALL epushdi ;* PUSH DI - untyped file
  966. CALL ccomma ;, ?
  967. JNZ prwuntp2 ;:no
  968. CALL pushe1 ;save var entry
  969. CALL exint ;get int expr: block size
  970. CALL pope1 ;restore var entry
  971. JMP.b prwemit ;'
  972. prwuntp2 MOV AX,#$0080 ;std blk size
  973. CALL emovaxi ;* MOV AX,0080
  974. prwemit POP BX ;restore table index
  975. JMP.b pclose3 ;'
  976. ptruncat MOV BX,#vtruncat ;TRUNCATE
  977. JMP.b pclose2 ;'
  978. pflush MOV BX,#vflush ;FLUSH
  979. JMP.b pclose2 ;'
  980. pclose MOV BX,#vclose ;CLOSE
  981. pclose2 PUSH BX ;save table index
  982. CALL brfilvar ;get file var
  983. POP BX ;restore index
  984. pclose3 CALL ebrack2 ;! )
  985. CALL ecallio ;emit call
  986. JMP pfilchk ;"do checking
  987. ecallio MOV AL,varctp ;emit call for I/O
  988. SUB AL,#$05 ;(component type-5)*2
  989. XOR.B AH,AH
  990. ADD AX,AX
  991. ADD BX,AX ;+ BX -> pointer
  992. CS:
  993. MOV AX,[BX] ;get vector
  994. JMP ecall ;"emit call
  995. vreset W xresetty,xresettx,xresetun ;vector table for I/O
  996. vrewrite W xrewrtty,xrewrttx,xrewrtun
  997. vclose W xclosety,xclosetx,xclosety
  998. vflush W xflushty,xflush,xflushty
  999. vtruncat W xtruncat,xtrunctx,xtruncat ;"
  1000. brfilvar CALL ebrack1 ;! (
  1001. CALL rdfilvar ;get file var
  1002. JZ brfilret ;ok:ret
  1003. CALL err
  1004. B $15 ;'21:File variable expected
  1005. brfilret RET ;"
  1006. rdfilvar CALL rdvar ;get file var: get var
  1007. JZ rdfil2 ;:found
  1008. STC ;not found
  1009. RET ;'
  1010. rdfil2 CMP.B varctp,#$05 ;file var ?
  1011. JB rdfilnf ;:no
  1012. CMP.B varctp,#$07
  1013. JA rdfilnf ;:no
  1014. CALL varptr2 ;get var ptr
  1015. MOV.B CL,varctp ;get type
  1016. XOR AX,AX ;ok
  1017. rdfilnf CLC
  1018. RET ;"
  1019. preadln MOV AL,#$FF ;READLN: set flag
  1020. JMP.b prd1 ;'
  1021. pread XOR.B AL,AL ;READ
  1022. prd1 MOV rdlnflg,AL ;store flag
  1023. CALL cbrack1 ;( ?
  1024. JZ prdfil ;:yes
  1025. CALL setinp ;set input path
  1026. JMP prdrdln ;'do checking
  1027. prdfil CALL rdfilvar ;get file var
  1028. JB prderr ;:error
  1029. JNZ prdsetin ;no file var: use std
  1030. CMP.B CL,#$05 ;typed file ?
  1031. JNZ prdtext ;:no
  1032. JMP prdtyped ;'do read typed file
  1033. prdtext CMP.B CL,#$06 ;text file ?
  1034. CALL errnz ;no:
  1035. B $41 ;65:Untyped files are not allowed here
  1036. MOV AX,#xrdfil ;(prepare for input)
  1037. CALL ecall ;* CALL xrdfil
  1038. JMP prdnxt ;'
  1039. prderr CALL err ;41:Unknown ID or syntax error
  1040. B $29 ;'
  1041. prdsetin CALL setinp ;set input path
  1042. JMP.b prdlp2 ;'
  1043. prdloop CALL rdvar ;parameter loop: read var
  1044. CALL errnz ;not found:
  1045. B $29 ;41:Unknown ID or syntax error
  1046. prdlp2 CALL varptr2 ;get var ptr
  1047. MOV.B CL,varctp ;component type
  1048. CMP.B CL,#$01 ;array ?
  1049. JZ prdarrch ;yes: read as byte block
  1050. CMP.B CL,#$08 ;file, ptr, set, record ?
  1051. JB prderrtp ;:not allowed
  1052. CMP.B CL,#$0B ;boolean ?
  1053. JZ prderrtp ;:not allowed
  1054. CMP.B CL,#$0D ;scalar ?
  1055. JB prdstr ;below: ok
  1056. prderrtp CALL err ;66:I/O not allowed here
  1057. B $42 ;'
  1058. prdarrch MOV BP,lower ;type ptr - test array of char
  1059. CMP.B [BP]-$08,#$0C ;component type = char ?
  1060. JNZ prderrtp ;no:error
  1061. MOV BP,upper ;index type = integer ?
  1062. CMP.B [BP]-$08,#$0A
  1063. JNZ prderrtp ;no:error
  1064. MOV AX,varsize ;component size
  1065. OR.B AH,AH ;> 255 ?
  1066. JNZ prderrtp ;yes:error
  1067. MOV.B AH,AL ;* MOV CL,len
  1068. MOV AL,#$B1
  1069. CALL eword
  1070. MOV AX,#xrdarrch ;(read array of char)
  1071. JMP.b prdemit ;'
  1072. prdstr CMP.B CL,#$08 ;string ?
  1073. JNZ prdnum ;:no
  1074. MOV.B AH,varsize ;max len-1
  1075. DEC.B AH
  1076. MOV AL,#$B1
  1077. CALL eword ;* MOV CL,max_len
  1078. MOV AX,#xrdstr ;(read string)
  1079. JMP.b prdemit ;'
  1080. prdnum MOV AX,#xrdreal ;(read real)
  1081. CMP.B CL,#$09 ;real ?
  1082. JZ prdemit ;:yes
  1083. MOV AX,#xrdchar ;(read char)
  1084. CMP.B CL,#$0C ;char ?
  1085. JZ prdemit ;:yes
  1086. MOV AX,#xrdint ;(read integer)
  1087. CMP varsize,#$01 ;word ?
  1088. JA prdemit ;:yes
  1089. MOV AX,#xrdbyte ;(read byte)
  1090. prdemit CALL ecall ;emit call
  1091. prdnxt CALL ccomma ;another var ?
  1092. JNZ prdend ;no: end it
  1093. JMP prdloop ;'parameter loop
  1094. prdend CALL ebrack2 ;! )
  1095. prdrdln MOV AX,#xreadln ;(readln)
  1096. prdln CMP.B rdlnflg,#$00 ;ReadLn ?
  1097. JZ efilchk ;:no
  1098. CALL ecall ;emit call
  1099. efilchk TEST direcsv,#$0001 ;do I/O-checking ?
  1100. JZ prdret ;:no
  1101. MOV AX,#xiochk ;(I/O-check)
  1102. CALL ecall
  1103. prdret RET ;"
  1104. setinp MOV AX,#xstdin ;set input path: std input
  1105. CMP cinpsize,#$00 ;buffer > 0 ?
  1106. JNZ setinprt ;yes: do it
  1107. TEST direcsv,#$0004 ;test I/O-mode
  1108. JZ setinprt ;:MS-DOS std input
  1109. MOV AX,#xrdln ;(read with editing)
  1110. CMP.B rdlnflg,#$00 ;ReadLn ?
  1111. JZ setinprt ;:no
  1112. MOV.B rdlnflg,#$00 ;clear flag
  1113. MOV AX,#xrd ;(Readln with editing)
  1114. setinprt JMP ecall ;"emit call
  1115. pwriteln MOV AL,#$FF ;WRITELN
  1116. JMP.b pwr1 ;'
  1117. pwrite XOR.B AL,AL ;WRITE
  1118. pwr1 MOV rdlnflg,AL ;set flag
  1119. CALL cbrack1 ;( ?
  1120. JZ pwrfil ;yes: ok
  1121. MOV AX,#xstdout ;set std output
  1122. CALL ecall ;emit call
  1123. JMP pwrend2 ;'end it
  1124. pwrfil CALL rdfilvar ;get file var
  1125. JB pwrstd2 ;:none
  1126. JNZ pwrstd ;no file var
  1127. CMP.B CL,#$05 ;typed file ?
  1128. JNZ pwrtext ;:no
  1129. JMP pwrtyped ;'write typed file
  1130. pwrtext CMP.B CL,#$06 ;text file ?
  1131. CALL errnz ;no:
  1132. B $41 ;65:Untyped files are not allowed here
  1133. MOV AX,#xwrfil ;(prepare for write)
  1134. CALL ecall ;* CALL xwrfil
  1135. JMP pwrnext ;'
  1136. pwrstd MOV AX,#xstdout ;set std output
  1137. CALL ecall ;* CALL xstdout
  1138. CALL expvar ;expression (var pre-read)
  1139. JMP.b pwrstr ;'check type
  1140. pwrstd2 MOV AX,#xstdout ;set std output
  1141. CALL ecall ;* CALL xstdout
  1142. pwrloop CALL constel ;get const element
  1143. JNZ pwrexpv ;:no, try expression
  1144. CMP.B CL,#$08 ;string ?
  1145. JNZ pwrexpc ;:no
  1146. MOV DI,chptr ;check current char
  1147. CMP.B [DI],#$2C ;, ?
  1148. JZ pwrinlin ;:yes
  1149. CMP.B [DI],#$29 ;) ?
  1150. JNZ pwrexpc ;no: normal
  1151. pwrinlin MOV AX,#xwrtinl ;(write inline string)
  1152. CALL ecall ;* CALL xwrtinl
  1153. CALL estring ;emit string
  1154. JMP.b pwrnext ;'get next element
  1155. NOP
  1156. pwrexpc CALL expconst ;expression (const pre-read)
  1157. JMP.b pwrstr ;'check type
  1158. pwrexpv CALL exprax ;expression (var pre-read)
  1159. pwrstr CMP.B CL,#$08 ;string ?
  1160. JB pwrerrtp ;below:illegal
  1161. CMP.B CL,#$0D ;scalar ?
  1162. JB pwrint ;below: ok
  1163. pwrerrtp CALL err ;66:I/O not allowed here
  1164. B $42 ;'
  1165. pwrint CMP.B CL,#$0A ;integer ?
  1166. JB pwrnoint ;below: real, string
  1167. CALL epushax ;* PUSH AX - stack it
  1168. pwrnoint CALL ccolon ;: ?
  1169. JNZ pwrdef ;no:default format
  1170. PUSH CX ;save type
  1171. CALL exint ;get int expression
  1172. POP CX
  1173. CMP.B CL,#$09 ;real ?
  1174. JNZ pwrchk ;no: no second parm
  1175. CALL ccolon ;: ?
  1176. JNZ pwrdef3 ;no: use default
  1177. CALL epushax ;* PUSH AX
  1178. PUSH CX ;save type
  1179. CALL exint ;get int expression
  1180. POP CX
  1181. JMP.b pwrchk ;'continue
  1182. pwrdef XOR AX,AX ;standard format
  1183. CMP.B CL,#$09 ;real ?
  1184. JNZ pwrdef2 ;:no
  1185. MOV AL,#$12 ;default: 18 chars
  1186. pwrdef2 CALL emovaxi ;* MOV AX,field_len
  1187. CMP.B CL,#$09 ;real ?
  1188. JNZ pwrchk ;:no
  1189. pwrdef3 CALL epushax ;* PUSH AX
  1190. MOV AX,#$FFFF
  1191. CALL emovaxi ;* MOV AX,#FFFF
  1192. pwrchk MOV AX,#xwrtstr ;(write string)
  1193. CMP.B CL,#$08 ;string ?
  1194. JZ pwremit ;:yes
  1195. MOV AX,#xwrreal ;(write real)
  1196. CMP.B CL,#$09 ;real ?
  1197. JZ pwremit ;:yes
  1198. MOV AX,#xwrint ;(write integer)
  1199. CMP.B CL,#$0A ;integer ?
  1200. JZ pwremit ;:yes
  1201. MOV AX,#xwrbool ;(write boolean)
  1202. CMP.B CL,#$0B ;boolean ?
  1203. JZ pwremit ;:yes
  1204. MOV AX,#xwrchar ;(write char)
  1205. pwremit CALL ecall ;emit call
  1206. pwrnext CALL ccomma ;, ?
  1207. JNZ pwrend ;no: end it
  1208. JMP pwrloop ;'do param loop
  1209. pwrend CALL ebrack2 ;! )
  1210. pwrend2 MOV AX,#xwrln ;(writeln)
  1211. JMP prdln ;"like read/readln
  1212. prdtyped MOV AX,#xrdvar ;Read typed file
  1213. JMP.b pwt2 ;'(read byte block)
  1214. pwrtyped MOV AX,#xwrvar ;Write typed file
  1215. pwt2 CMP.B rdlnflg,#$00 ;ReadLn/WriteLn ?
  1216. CALL errnz ;yes:
  1217. B $23 ;35:Textfile expected
  1218. PUSH AX ;save addr
  1219. MOV AX,#xfilsel ;(select file)
  1220. CALL ecall ;* CALL xfilsel
  1221. MOV BP,lower ;type ptr
  1222. CALL getparm ;get type parms
  1223. pwtloop CALL ccomma ;, ?
  1224. JNZ pwtend ;no: end it
  1225. CALL pushe2 ;push entry
  1226. CALL varptr ;get var ptr
  1227. CALL pope2 ;pop entry
  1228. CALL tchkstrc ;check type struct vars
  1229. POP AX ;get routine addr
  1230. PUSH AX
  1231. CALL ecall ;* CALL xwrvar / xrdvar
  1232. JMP pwtloop ;'parameter loop
  1233. pwtend POP AX ;remove
  1234. CALL ebrack2 ;! )
  1235. JMP efilchk ;"do checking
  1236. pblockrd MOV AX,#xblkrdrd ;BLOCKREAD
  1237. MOV BX,#xblkrd ;with / without res var
  1238. JMP.b pbl1 ;'
  1239. pblockwr MOV AX,#xblkwrrs ;BLOCKWRITE
  1240. MOV BX,#xblkwr
  1241. pbl1 PUSH AX ;save addr
  1242. PUSH BX
  1243. CALL brfilvar ;get file var
  1244. CMP.B CL,#$07 ;untyped ?
  1245. CALL errnz ;no:
  1246. B $25 ;37:Untyped file expected
  1247. CALL epushdi ;* PUSH DI
  1248. CALL ecomma ;! ,
  1249. CALL varptr ;get var ptr (src/dst var)
  1250. CALL epushdi ;* PUSH DI
  1251. CALL ecomma ;! ,
  1252. CALL exint ;get int expr (count)
  1253. CALL ccomma ;, ?
  1254. POP BX ;restore addr
  1255. POP AX
  1256. JZ pblres ;yes: with result var
  1257. PUSH BX ;without result var
  1258. JMP.b pblend ;'
  1259. pblres PUSH AX ;save routine addr
  1260. CALL epushax ;* PUSH AX (save count)
  1261. CALL varptr ;get res var ptr
  1262. CMP.B varctp,#$0A ;integer ?
  1263. JNZ pblerr ;no: error
  1264. CMP varsize,#$02 ;word ?
  1265. JZ pblend ;yes: ok
  1266. pblerr CALL err ;24:Integer variable expected
  1267. B $18 ;'
  1268. pblend JMP pexec3 ;"emit call, check end
  1269. pchdir MOV AX,#xchdir ;CHDIR
  1270. JMP.b prmd2 ;'
  1271. pmkdir MOV AX,#xmkdir ;MKDIR
  1272. JMP.b prmd2 ;'
  1273. prmdir MOV AX,#xrmdir ;RMDIR
  1274. prmd2 PUSH AX ;save addr
  1275. CALL ebrack1 ;! (
  1276. CALL exstr ;get string expr
  1277. JMP pexec3 ;"complete it
  1278. pgetdir CALL ebrack1 ;! ( : GETDIR
  1279. CALL exint ;get int expr
  1280. CALL epushax ;* PUSH AX
  1281. CALL ecomma ;! ,
  1282. CALL rdstrvar ;get string var
  1283. MOV.B AH,varsize ;max len-1
  1284. DEC.B AH
  1285. MOV AL,#$B1
  1286. CALL eword ;* MOV CL,max_len
  1287. MOV AX,#xgetdir
  1288. JMP pemit ;"end it
  1289. povrpath CALL ebrack1 ;! ( : OVRPATH
  1290. CALL exstr ;get string expr
  1291. MOV AX,#xovrpath
  1292. JMP pemit ;"end it
  1293. pdelete CALL ebrack1 ;! ( : DELETE
  1294. CALL rdstrvar ;get string var
  1295. CALL epushdi ;* PUSH DI
  1296. CALL ecomma ;! ,
  1297. CALL exint ;get int expr
  1298. CALL epushax ;* PUSH AX
  1299. CALL ecomma ;! ,
  1300. CALL exint ;get int expr
  1301. MOV AX,#xdelete
  1302. JMP pemit ;"end it
  1303. pinsert CALL ebrack1 ;! ( : INSERT
  1304. CALL exstr ;get string expr
  1305. CALL ecomma ;! ,
  1306. CALL rdstrvar ;get string var
  1307. CALL epushdi ;* PUSH DI
  1308. MOV.B AH,varsize ;component size - 1
  1309. DEC.B AH
  1310. MOV AL,#$B1
  1311. PUSH AX ;save it
  1312. CALL ecomma ;! ,
  1313. CALL exint ;get integer expr
  1314. POP AX ;restore
  1315. CALL eword ;* MOV CL,max_len
  1316. MOV AX,#xinsert
  1317. JMP pemit ;"end it
  1318. rdstrvar CALL varptr ;get string var: get var ptr
  1319. CMP.B varctp,#$08 ;string ?
  1320. CALL errnz ;no:
  1321. B $22 ;34:String variable expected
  1322. RET ;"
  1323. pstr CALL ebrack1 ;! ( : STR
  1324. CALL exnum ;get num expr
  1325. CMP.B CL,#$0A ;integer ?
  1326. JNZ pstnoint ;real: is already on stack !
  1327. CALL epushax ;* PUSH AX
  1328. pstnoint CALL ccolon ;: ?
  1329. JNZ pstdef1 ;:no formatting
  1330. PUSH CX ;save type
  1331. CALL exint ;get int expr
  1332. CALL epushax ;* PUSH AX
  1333. POP CX ;restore type
  1334. CMP.B CL,#$0A ;integer ?
  1335. JZ pstnxt ;yes: no second parm
  1336. CALL ccolon ;: ?
  1337. JNZ pstdef3 ;no: get default
  1338. PUSH CX ;save type
  1339. CALL exint ;get int expr
  1340. CALL epushax ;* PUSH AX
  1341. POP CX ;restore type
  1342. JMP.b pstnxt ;'
  1343. pstdef1 XOR AX,AX ;set default
  1344. CMP.B CL,#$0A ;integer ?
  1345. JZ pstdef2 ;:yes
  1346. MOV AL,#$12 ;real: 18 chars
  1347. pstdef2 CALL emovaxi ;* MOV AX,i
  1348. CALL epushax ;* PUSH AX
  1349. CMP.B CL,#$0A ;integer ?
  1350. JZ pstnxt ;:yes
  1351. pstdef3 MOV AX,#$FFFF ;default for second parm:
  1352. CALL emovaxi ;* MOV AX,#FFFF
  1353. CALL epushax ;* PUSH AX
  1354. pstnxt CALL ecomma ;! ,
  1355. PUSH CX ;save type
  1356. CALL rdstrvar ;get string var
  1357. MOV.B AH,varsize ;component size-1
  1358. DEC.B AH
  1359. MOV AL,#$B1
  1360. CALL eword ;* MOV CL,max_len
  1361. POP CX ;restore type
  1362. MOV AX,#xstrint ;(str integer)
  1363. CMP.B CL,#$0A ;integer ?
  1364. JZ pstemit ;:yes
  1365. MOV AX,#xstrreal ;(str real)
  1366. pstemit JMP pemit ;"emit call, check )
  1367. pval CALL ebrack1 ;! ( : VAL
  1368. CALL exstr ;get string expression
  1369. CALL ecomma ;! ,
  1370. CALL varptr ;get dest var ptr
  1371. MOV.B CL,varctp ;test type
  1372. CMP.B CL,#$0A ;integer ?
  1373. JZ pvalint ;:yes
  1374. CMP.B CL,#$09 ;real
  1375. JZ pvalreal ;:yes
  1376. CALL err ;27:Integer or real var expected
  1377. B $1B ;'
  1378. pvalint CMP varsize,#$02 ;test component size
  1379. JNZ pvalerr ;byte: error
  1380. pvalreal PUSH CX ;save type
  1381. CALL epushdi ;* PUSH DI
  1382. CALL ecomma ;! ,
  1383. CALL varptr ;get status var ptr
  1384. CMP.B varctp,#$0A ;integer ?
  1385. JNZ pvalerr ;no: error
  1386. CMP varsize,#$02 ;byte ?
  1387. JZ pvalok ;word:ok
  1388. pvalerr CALL err ;24:Int var expected
  1389. B $18 ;'
  1390. pvalok POP CX ;restore type
  1391. MOV AX,#xvalint ;(val integer)
  1392. CMP.B CL,#$0A ;integer ?
  1393. JZ pstemit ;:yes
  1394. MOV AX,#xvalreal ;(val real)
  1395. JMP pstemit ;"emit call, check )
  1396. pgotoxy CALL ebrack1 ;! ( : GOTOXY
  1397. CALL exint ;get integer expr
  1398. CALL epushax ;* PUSH AX
  1399. MOV AX,#xgotoxy
  1400. pgxy2 PUSH AX ;save addr
  1401. CALL ecomma ;! ,
  1402. CALL exint ;get integer expr
  1403. POP AX ;restore addr
  1404. JMP pemit ;"emit call, check )
  1405. prndmize MOV AX,#xrndmize ;RANDOMIZE
  1406. JMP ecall ;"emit call
  1407. pnew MOV AX,#xnew ;NEW
  1408. pnew2 PUSH AX ;save addr
  1409. CALL ebrack1 ;! (
  1410. CALL varptr ;get var ptr
  1411. CMP.B varctp,#$04 ;pointer var ?
  1412. JNZ prelerr ;no: error
  1413. MOV BP,lower ;get type ptr
  1414. CALL getparm ;get type parms
  1415. MOV AX,var2size ;get its component size
  1416. CALL emovcxi ;* MOV CX,compo_size
  1417. POP AX ;restore addr
  1418. JMP pemit ;"emit call, check )
  1419. pgetmem MOV AX,#xgetmem ;GETMEM
  1420. pgm2 PUSH AX ;save addr
  1421. CALL ebrack1 ;! (
  1422. CALL varptr ;get var ptr
  1423. CMP.B varctp,#$04 ;pointer ?
  1424. JNZ prelerr ;no: error
  1425. CALL epushdi ;* PUSH DI
  1426. CALL ecomma ;! ,
  1427. CALL exint ;get int expr
  1428. POP AX ;restore addr
  1429. JMP pemit ;"emit call, check )
  1430. pdispose MOV AX,#xdispose ;DISPOSE
  1431. JMP pnew2 ;"like New
  1432. pfreemem MOV AX,#xfreemem ;FREEMEM
  1433. JMP pgm2 ;"like Getmem
  1434. pmark MOV AX,#xmark ;MARK
  1435. JMP.b prel2 ;'like Release
  1436. prelease MOV AX,#xrelease ;RELEASE
  1437. prel2 PUSH AX ;save addr
  1438. CALL ebrack1 ;! (
  1439. CALL varptr ;get var ptr
  1440. POP AX ;restore addr
  1441. CMP.B varctp,#$04 ;pointer ?
  1442. JNZ prelerr ;no: error
  1443. JMP pemit ;'emit call, check )
  1444. prelerr CALL err ;28:Pointer var expected
  1445. B $1C ;"
  1446. pmove CALL ebrack1 ;! ( : MOVE
  1447. CALL varptr ;get src var ptr
  1448. CALL epushdi ;* PUSH DI
  1449. CALL ecomma ;! ,
  1450. CALL varptr ;get dest var ptr
  1451. CALL epushdi ;* PUSH DI
  1452. MOV AX,#xmove
  1453. JMP pgxy2 ;"get int expr, end it
  1454. pfillchr CALL ebrack1 ;! ( : FILLCHAR
  1455. CALL varptr ;get dest var ptr
  1456. CALL epushdi ;* PUSH DI
  1457. CALL ecomma ;! ,
  1458. CALL exint ;get int expr
  1459. CALL epushax ;* PUSH AX
  1460. CALL ecomma ;! ,
  1461. CALL exscal ;get scalar expr
  1462. MOV AX,#xfillchr
  1463. JMP pemit ;"end it
  1464. pexit XOR AX,AX ;EXIT: clear flag
  1465. JMP exit ;"do it
  1466. phalt CALL cbrack1 ;HALT: ( ?
  1467. JNZ phlt2 ;no: normal
  1468. CALL exint ;get int expr
  1469. CALL ebrack2 ;! )
  1470. JMP.b phlt3 ;'
  1471. phlt2 CALL ecode ;* XOR AX,AX
  1472. B $02,$33,$C0
  1473. phlt3 MOV AX,#progend
  1474. JMP ejump ;"emit jump
  1475. pmsdos CALL ebrack1 ;! ( : MSDOS
  1476. MOV BX,#$0021 ;int number 21
  1477. PUSH BX ;save it
  1478. JMP.b pint2 ;'like INTR
  1479. pintr CALL ebrack1 ;! ( : INTR
  1480. CALL rdintcn ;read integer constant
  1481. PUSH BX ;save it
  1482. CALL ecomma ;! ,
  1483. pint2 CALL varptr ;get var ptr
  1484. MOV AX,#xsetregs ;(set registers from rec)
  1485. CALL ecall ;* CALL xsetregs
  1486. POP AX ;interrupt number
  1487. MOV.B AH,AL
  1488. MOV AL,#$CD ;* INT nn
  1489. CALL eword
  1490. MOV AX,#xgetregs ;(get registers back)
  1491. JMP pemit ;"emit call, check )
  1492. pportw MOV AL,#$EF ;PORTW: opcode OUT
  1493. JMP.b pprt2 ;'
  1494. pport MOV AL,#$EE ;PORT: opcode OUTB
  1495. pprt2 PUSH AX ;save opcode
  1496. CALL esqr1 ;! [
  1497. CALL exint ;get int expr
  1498. CALL esqr2 ;! ]
  1499. CALL epushax ;* PUSH AX (port number)
  1500. CALL eassign ;! :=
  1501. CALL exint ;get int expr
  1502. CALL ecode ;* POP DX
  1503. B $01,$5A
  1504. POP AX ;restore opcode
  1505. JMP ebyte ;"emit OUT [DX],AX
  1506. pcrtinit MOV AX,#xcrtinit ;CRTINIT
  1507. JMP.b pdelemit ;'
  1508. pcrtexit MOV AX,#xcrtexit ;CRTEXIT
  1509. JMP.b pdelemit ;'
  1510. pclrscr MOV AX,#xclrscr ;CLRSCR
  1511. JMP.b pdelemit ;'
  1512. pclreol MOV AX,#xclreol ;CLREOL
  1513. JMP.b pdelemit ;'
  1514. pnrmvid MOV AX,#xnormvid ;NORMVIDEO, HIGHVIDEO
  1515. JMP.b pdelemit ;'
  1516. plowvid MOV AX,#xlowvid ;LOWVIDEO
  1517. JMP.b pdelemit ;'
  1518. pinsline MOV AX,#xinsline ;INSLINE
  1519. JMP.b pdelemit ;'
  1520. pdelline MOV AX,#xdelline ;DELLINE
  1521. pdelemit JMP ecall ;"emit call
  1522. pdelay MOV AX,#xdelay ;DELAY
  1523. pdel2 PUSH AX ;save addr
  1524. CALL ebrack1 ;! (
  1525. CALL exint ;get int expr
  1526. POP AX ;restore addr
  1527. JMP pemit ;"emit, check )
  1528. pwindow MOV AX,#xwindow ;WINDOW
  1529. pwind4 PUSH AX ;save addr
  1530. CALL ebrack1 ;! (
  1531. pwind3 CALL exint ;get int expr
  1532. CALL epushax ;* PUSH AX
  1533. CALL ecomma ;! ,
  1534. pwind2 CALL exint ;get int expr
  1535. CALL epushax ;* PUSH AX
  1536. CALL ecomma ;! ,
  1537. CALL exint ;get int expr
  1538. CALL epushax ;* PUSH AX
  1539. POP AX ;restore addr
  1540. JMP pgxy2 ;"get int, end it
  1541. ptextcol MOV AX,#xtxtcol ;TEXTCOLOR
  1542. JMP pdel2 ;"(int)
  1543. ptextbg MOV AX,#xtxtbg ;TEXTBACKGROUND
  1544. JMP pdel2 ;"(int)
  1545. pgraphbg MOV AX,#xgrbg ;GRAPHBACKGROUND
  1546. JMP pdel2 ;"(int)
  1547. ppalette MOV AX,#xpalette ;PALETTE
  1548. JMP pdel2 ;"(int)
  1549. phirscol MOV AX,#xhirscol ;HIRESCOLOR
  1550. JMP pdel2 ;"(int)
  1551. pgrcolmd MOV AX,#xgrcolmd ;GRAPHCOLORMODE
  1552. pgremit JMP ecall ;'emit call
  1553. pgrmode MOV AX,#xgrmode ;GRAPHMODE
  1554. JMP pgremit ;'emit call
  1555. phires MOV AX,#xhires ;HIRES
  1556. JMP pgremit ;"emit call
  1557. ptxtmode CALL cbrack1 ;TEXTMODE
  1558. JZ ptxtmd2 ;( ? yes: get mode
  1559. MOV AX,#$00FF
  1560. CALL emovaxi ;* MOV AX,#00FF
  1561. JMP.b ptxtdef ;'
  1562. ptxtmd2 CALL exint ;get int expr
  1563. CALL ebrack2 ;! )
  1564. ptxtdef MOV AX,#xtxtmode
  1565. JMP ecall ;"emit call
  1566. pgrwind MOV AX,#xgrwindw ;GRAPHWINDOW
  1567. JMP pwind4 ;"like window
  1568. pplot CALL ebrack1 ;! ( : PLOT
  1569. MOV AX,#xplot
  1570. PUSH AX ;save it
  1571. JMP pwind2 ;"like window - only 3 parms
  1572. pdraw CALL ebrack1 ;! ( : DRAW
  1573. CALL exint ;get int expr
  1574. CALL epushax ;* PUSH AX
  1575. CALL ecomma ;! ,
  1576. MOV AX,#xdraw
  1577. PUSH AX ;save addr
  1578. JMP pwind3 ;"now like window
  1579. psound MOV AX,#xsound ;SOUND
  1580. JMP pdel2 ;"(int)
  1581. pnosound MOV AX,#xnosound ;NOSOUND
  1582. JMP ecall ;"emit call
  1583. exprsave CALL pushe1 ;push entry
  1584. CALL exprax ;read expression
  1585. CALL pope1 ;restore entry
  1586. exintrt RET ;"
  1587. exint CALL exprax ;get integer expression: rd expr
  1588. CMP.B CL,#$0A ;integer ?
  1589. JZ exintrt ;yes:ret
  1590. CALL err ;23:Integer expression expected
  1591. B $17 ;"
  1592. exnum CALL exprax ;get numeric expression: rd expr
  1593. CMP.B CL,#$0A ;integer ?
  1594. JZ exintrt ;yes: ret
  1595. CMP.B CL,#$09 ;real ?
  1596. JZ exintrt ;yes: ret
  1597. CALL err ;26:Int or real expression expected
  1598. B $1A ;"
  1599. exscal CALL exprax ;get scalar expression: rd expr
  1600. chksimpl CMP.B CL,#$0A ;scalar ?