TPSRC10 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518
  1. CALL upcase ;UpCase
  2. OR.B AL,AL ;0 ?
  3. CALL perrz ;yes:
  4. B $37 ;55:String constant exceeds line
  5. XOR AL,#$40 ;make it a control char
  6. INC DI ;next char
  7. icssto2 MOV.B [BX],AL ;store in buffer
  8. INC BX
  9. INC.B CH ;count length
  10. JMP icsloop ;'get next element
  11. icsnum INC DI ;read #char
  12. PUSH BX ;save dest ptr, counter
  13. PUSH CX
  14. MOV BX,DI ;pos of number
  15. CALL asccard ;read integer
  16. MOV DI,BX ;set new position
  17. POP CX ;restore
  18. POP BX
  19. CALL perrb ;error:
  20. B $38 ;56:Error in int constant
  21. JMP icssto2 ;'store it, continue
  22. icsend MOV CL,#$08 ;string
  23. CMP.B CH,#$01 ;length = 1 ?
  24. JNZ icend ;:no
  25. MOV.B BL,wordbuf ;get char
  26. XOR.B BH,BH ;clear high byte
  27. MOV CL,#$0C ;char
  28. icend JMP skipdi ;'get next word
  29. icnum MOV BX,DI ;numeric constant: beg pos
  30. CMP AL,#$24 ;$ ?
  31. JZ icnint ;yes: integer constant
  32. CALL number ;char in 0..9 ?
  33. JNB icnscan ;:yes
  34. XOR AX,AX ;set flag: invalid
  35. DEC AX
  36. RET ;'
  37. icnscan INC DI ;next char
  38. MOV.B AL,[DI] ;get it
  39. CALL number ;in 0..9 ?
  40. JNB icnscan ;yes: loop
  41. CALL upcase ;UpCase
  42. CMP AL,#$45 ;E ?
  43. JZ icnreal ;yes: real constant
  44. CMP AL,#$2E ;. ?
  45. JNZ icnint ;no: integer constant
  46. INC DI ;test next char: .. ?
  47. MOV.B AL,[DI]
  48. CMP AL,#$2E ;. ?
  49. JZ icnint ;:yes, integer constant
  50. CMP AL,#$29 ;) ? (.) = ])
  51. JZ icnint ;yes: integer constant
  52. icnreal MOV DI,#creal1 ;dest buffer
  53. CALL ascreal2 ;read real number
  54. MOV DI,BX ;set new position
  55. CALL perrb ;error:
  56. B $39 ;57:Error in real const
  57. MOV CL,#$09 ;real
  58. JMP icend ;'end it
  59. icnint CALL asccard ;read integer const
  60. MOV DI,BX ;set new pos
  61. MOV BX,AX ;get result
  62. CALL perrb ;ok ? no:
  63. B $38 ;56:Error in integer constant
  64. MOV CL,#$0A ;integer
  65. JMP icend ;"end it
  66. ecode PUSH AX ;Emit inline code
  67. PUSH BP ;(stored as inline string)
  68. MOV BP,SP ;stack frame
  69. XCHG BX,[BP]$04 ;get return addr
  70. CS:
  71. MOV.B AH,[BX] ;get length
  72. INC BX ;next byte
  73. ecodelp CS: ;get byte
  74. MOV.B AL,[BX]
  75. CALL ebyte ;emit it
  76. INC BX ;next one
  77. DEC.B AH
  78. JNZ ecodelp ;:another
  79. XCHG BX,[BP]$04 ;restore ret, BX
  80. POP BP ;restore
  81. POP AX
  82. RET ;"
  83. estring MOV.B AL,CH ;Emit string, CH=length
  84. CALL ebyte ;emit length
  85. estr2 MOV BX,#wordbuf ;buffer ptr
  86. estrlp OR.B CH,CH ;test length
  87. JZ estrret ;:null string
  88. MOV.B AL,[BX] ;get char
  89. CALL ebyte ;emit it
  90. INC BX ;next one
  91. DEC.B CH
  92. JMP estrlp ;'
  93. estrret RET ;"
  94. epushax CALL ecode ;* PUSH AX
  95. B $01,$50
  96. RET ;"
  97. epopax CALL ecode ;* POP AX
  98. B $01,$58
  99. RET ;"
  100. epushdi CALL ecode ;* PUSH DI
  101. B $01,$57
  102. RET ;"
  103. emovaxi CALL ecode ;* MOV AX,#..
  104. B $01,$B8
  105. JMP.b eword ;"emit immediate value in AX
  106. CALL ecode ;* MOV BX,#..
  107. B $01,$BB
  108. JMP.b eword ;"emit immediate
  109. emovcxi CALL ecode ;* MOV CX,#..
  110. B $01,$B9
  111. JMP.b eword ;"emit immediate
  112. emovdxi CALL ecode ;* MOV DX,#..
  113. B $01,$BA
  114. JMP.b eword ;"emit immediate
  115. emovdii CALL ecode ;* MOV DI,#..
  116. B $01,$BF
  117. JMP.b eword ;"emit immediate
  118. ecall CALL ecode ;* CALL ..
  119. B $01,$E8
  120. JMP.b ejmp2 ;'emit offset
  121. ejump CALL ecode ;* JMP ..
  122. B $01,$E9
  123. ejmp2 SUB AX,pc ;dest-PC-2 -> offset
  124. DEC AX
  125. DEC AX
  126. JMP.b eword ;"emit offset word
  127. emitdx MOV AX,DX ;emit DX
  128. eword CALL ebyte ;emit AX
  129. PUSH AX ;save it
  130. MOV.B AL,AH ;emit high byte
  131. CALL ebyte ;emit byte
  132. POP AX ;restore
  133. RET ;"
  134. ebyte CMP.B flgpshax,#$00 ;Emit byte in AL
  135. JZ ebes ;:no PUSH AX
  136. PUSH AX ;save
  137. MOV AL,#$50 ;* PUSH AX
  138. CALL ebemit
  139. POP AX
  140. MOV.B flgpshax,#$00 ;reset flag
  141. ebes CMP.B flgpshes,#$00 ;emit PUSH ES ?
  142. JZ ebdi ;:no
  143. PUSH AX ;save
  144. MOV AL,#$06 ;* PUSH ES
  145. CALL ebemit
  146. POP AX ;restore
  147. MOV.B flgpshes,#$00 ;reset flag
  148. ebdi CMP.B flgpshdi,#$00 ;emit PUSH DI ?
  149. JZ ebemit ;:no
  150. PUSH AX ;save
  151. MOV AL,#$57 ;* PUSH DI
  152. CALL ebemit
  153. POP AX ;restore
  154. MOV.B flgpshdi,#$00 ;reset flag
  155. ebemit PUSH BX ;save
  156. CMP.B cpmode,#$01 ;find runtime error ?
  157. JZ ebfind ;:yes
  158. MOV BX,cdptr ;code ptr-code pos of buffer
  159. SUB BX,cdbufpt
  160. ADD BX,cdbegpt ;+ beg of code buffer
  161. MOV ES,destseg ;dest segment
  162. ES:
  163. MOV.B [BX],AL ;store byte
  164. JMP.b ebend ;'
  165. ebfind MOV BX,pc ;PC = error pos ?
  166. CMP BX,errpos2
  167. JZ ebfound ;:yes - found !
  168. ebend INC cdptr ;inc code pointers
  169. INC pc
  170. MOV BX,pc ;get PC
  171. INC.B BH ;overflow ?
  172. JZ eberr ;:yes
  173. OR.B BL,BL ;256 bytes done ?
  174. JNZ ebnochk ;:no
  175. CALL chkovrfl ;test for overflow
  176. ebnochk POP BX ;restore BX
  177. RET ;'
  178. eberr CALL err ;98:Memory overflow
  179. B $62 ;'
  180. ebfound CALL err ;C8:Error position found
  181. B $C8 ;"
  182. codflush CMP.B cpmode,#$02 ;Flush code buffer
  183. JB cfret ;not to file:ret
  184. MOV CX,cdptr ;code pointer
  185. SUB CX,cdbufpt ;= code pos of buffer ?
  186. STC
  187. JZ cfret ;yes: nothing to flush
  188. MOV AH,#$40 ;write byte block
  189. MOV BX,dstfile ;dest file handle
  190. MOV DX,cdbegpt ;beginning of code buffer
  191. PUSH DS ;save DS
  192. MOV DS,destseg ;dest segment
  193. CALL dos ;write buffer
  194. POP DS ;restore DS
  195. JB cferr ;:error
  196. CMP AX,CX ;length = expected ?
  197. JZ cfok ;:yes
  198. cferr CALL err ;C9:File error
  199. B $C9 ;'
  200. cfok MOV AX,cdptr ;code ptr -> code pos of buffer
  201. MOV cdbufpt,AX
  202. cfret RET ;"
  203. ptcjmppc MOV AX,pc ;Patch jump address
  204. ptcjmp SUB AX,BX ;dest (AX)-src (BX)-2
  205. DEC AX
  206. DEC AX
  207. ptcjmp2 PUSH BX ;save dest
  208. SUB BX,pc ;dest-PC+code ptr
  209. ADD BX,cdptr
  210. CALL patch ;patch it
  211. POP BX ;restore
  212. RET ;"
  213. patch CMP.B cpmode,#$01 ;Patch word AX at pos BX
  214. JZ ptret ;find error:ret
  215. CMP BX,cdbufpt ;>= code pos of buffer ?
  216. JB ptlist ;no: put it into patch list
  217. PUSH BX ;save pos
  218. SUB BX,cdbufpt ;-code pos of buffer
  219. ADD BX,cdbegpt ;+beg of code buffer
  220. MOV ES,destseg ;dest segment
  221. ES:
  222. MOV [BX],AX ;patch it in memory
  223. POP BX ;restore
  224. ptret RET ;'
  225. ptlist PUSH CX ;save regs
  226. PUSH DI ;patch list is sorted to
  227. PUSH SI ;minimize disk accesses
  228. PUSH SS ;SS -> ES
  229. POP ES
  230. MOV SI,ptcbeg ;start of patch list
  231. MOV DI,ptctop ;top of patch list
  232. ptsearch CMP SI,DI ;at the end ?
  233. JZ ptstore ;yes: put it there
  234. SS:
  235. CMP BX,[SI] ;put it here ?
  236. JB ptins ;:yes
  237. ADD SI,#$04 ;go to next entry
  238. JMP ptsearch ;'continue searching
  239. ptins MOV CX,DI ;calculate count to shift
  240. SUB CX,SI
  241. MOV SI,DI ;end position
  242. ADD DI,#$04 ;-> end pos+4
  243. DEC DI
  244. DEC SI
  245. PUSH DS ;save DS
  246. PUSH SS ;SS -> DS
  247. POP DS
  248. STD ;make space for new entry
  249. REPZ
  250. MOVS.B
  251. POP DS ;restore DS
  252. INC SI ;point to dest pos
  253. ptstore SS: ;store in patch list:
  254. MOV [SI],BX ;address
  255. SS:
  256. MOV [SI]$02,AX ;value to be patched
  257. ADD ptctop,#$04 ;add 4 to patch top
  258. MOV CX,ptctop ;patch list top = end of
  259. CMP CX,ptcend ;patch list space ?
  260. JNZ ptnofl ;:no
  261. CALL ptcflush ;flush patch list
  262. ptnofl POP SI ;restore registers
  263. POP DI
  264. POP CX
  265. RET ;"
  266. ptcflush CMP.B cpmode,#$02 ;Patch code in file
  267. JB ptfret ;no file - ret
  268. PUSH AX ;save regs
  269. PUSH BX
  270. PUSH CX
  271. PUSH DX
  272. PUSH BP
  273. MOV AX,#$4201 ;seek relative
  274. MOV BX,dstfile ;dest file handle
  275. XOR CX,CX ;get current pos in file
  276. XOR DX,DX
  277. CALL dos
  278. PUSH AX ;save it
  279. PUSH DX
  280. MOV BP,ptcbeg ;start of patch list
  281. ptflp CMP BP,ptctop ;end reached ?
  282. JZ ptfend ;:yes
  283. MOV AX,#$4200 ;seek absolute
  284. MOV BX,dstfile ;dest file handle
  285. MOV DX,cdfoff ;file offset
  286. MOV CX,cdfoff1
  287. ADD DX,[BP]$00 ;+ patch addr
  288. ADC CX,#$00 ;carry
  289. CALL dos ;do seek
  290. MOV AX,[BP]$02 ;get value to patch
  291. MOV ptcbuf1,AX ;store in buffer
  292. MOV AH,#$40 ;write patch value
  293. MOV BX,dstfile ;dest file handle
  294. MOV CX,#$0002 ;2 bytes
  295. MOV DX,#ptcbuf1 ;buffer ofs
  296. CALL dos
  297. CALL errb
  298. B $C9 ;C):File error
  299. ADD BP,#$04 ;next patch list entry
  300. JMP ptflp ;'
  301. ptfend MOV AX,ptcbeg ;clear patch list:
  302. MOV ptctop,AX ;beg -> top
  303. MOV AX,#$4200 ;seek absolute
  304. MOV BX,dstfile ;dest file handle
  305. POP CX ;restore current pos
  306. POP DX
  307. CALL dos ;set it again
  308. POP BP ;restore regs
  309. POP DX
  310. POP CX
  311. POP BX
  312. POP AX
  313. ptfret RET ;"
  314. pushe2 MOV SI,#parm2 ;save entry 2 on stack
  315. JMP.b pshe1 ;'
  316. pushe1 MOV SI,#indflg ;save entry 1 on stack
  317. pshe1 POP retbuf ;ret addr
  318. MOV cxbuf,CX ;save CX
  319. MOV CX,SS ;SS -> ES
  320. MOV ES,CX
  321. MOV CX,#$000F ;15 bytes
  322. SUB SP,CX ;make space on stack
  323. MOV DI,SP ;dest: stack
  324. CLD
  325. REPZ
  326. MOVS.B ;move it
  327. psheend MOV CX,cxbuf ;restore CX
  328. JMP [retbuf] ;"return
  329. pope2 MOV DI,#parm2 ;restore entry 2 from stack
  330. JMP.b pope ;'
  331. pope1 MOV DI,#indflg ;restore entry 1 from stack
  332. pope POP retbuf ;ret addr
  333. MOV cxbuf,CX ;save CX
  334. MOV SI,SP ;SP -> source
  335. MOV CX,DS ;DS -> ES
  336. MOV ES,CX
  337. MOV CX,SS ;SS -> DS
  338. MOV DS,CX
  339. MOV CX,#$000F ;15 bytes
  340. CLD
  341. REPZ
  342. MOVS.B ;move it
  343. MOV CX,ES ;restore DS
  344. MOV DS,CX
  345. MOV SP,SI ;remove entry from stack
  346. JMP psheend ;"return
  347. copye2 MOV DI,#parm2 ;copy entry 2 from stack
  348. JMP.b cpe ;'
  349. MOV DI,#indflg ;copy entry 1 from stack
  350. cpe PUSH CX ;save CX
  351. MOV SI,SP ;source: on stack
  352. ADD SI,#$04 ;skip ret addr, CX
  353. MOV CX,DS ;DS -> ES
  354. MOV ES,CX
  355. MOV CX,SS ;SS -> DS
  356. MOV DS,CX
  357. MOV CX,#$000F ;15 bytes
  358. CLD
  359. REPZ
  360. MOVS.B ;copy it
  361. MOV CX,ES ;restore DS
  362. MOV DS,CX
  363. POP CX ;restore CX
  364. RET ;"
  365. symbyte MOV BP,symtop ;store AL in symtab
  366. DEC BP ;down one byte
  367. MOV.B [BP]$00,AL ;store it
  368. MOV symtop,BP ;set new symtab top
  369. RET ;"
  370. symword MOV BP,symtop ;store AX in symtab
  371. DEC BP ;down two bytes
  372. DEC BP
  373. MOV [BP]$00,AX ;store it
  374. MOV symtop,BP ;set new symtab top
  375. RET ;"
  376. symoffs MOV AX,symtop2 ;Write symtab offset
  377. SUB AX,symtop ;last entry-current+2
  378. ADD AX,#$0002
  379. CALL symword ;store offset
  380. MOV AX,symtop ;symtab top ->
  381. MOV symtop2,AX ;symtab top at beg of definition
  382. JMP chkovrfl ;"test size
  383. stotype MOV AX,#$0800 ;store type
  384. CALL symword ;store tag: subtype
  385. MOV AX,symtop ;symtab top
  386. MOV vartp,AX ;-> type ptr
  387. MOV BX,#parm1end ;source buffer
  388. MOV BP,symtop ;destination
  389. stotlp DEC BX ;go down
  390. DEC BX ;write size, upper bound,
  391. DEC BP ;lower bound, component type
  392. DEC BP
  393. MOV AX,[BX] ;get word
  394. MOV [BP]$00,AX ;store it
  395. CMP BX,#varctp ;end ?
  396. JNZ stotlp ;:not yet
  397. MOV symtop,BP ;set new top
  398. CALL symoffs ;write offset
  399. XOR AX,AX ;ok
  400. RET ;"
  401. getparm MOV BX,#maxsize ;Get var parms -> entry 2
  402. JMP.b gvp2 ;'
  403. getvprm MOV AX,[BP]-$06 ;Get var parms
  404. MOV indptflg,AX ;var segment
  405. MOV AX,[BP]-$04 ;var offset
  406. MOV varofs,AX
  407. MOV BP,[BP]-$02 ;type pointer
  408. getvprm2 MOV BX,#parm1end ;to entry 1
  409. gvp2 PUSH CX ;save
  410. MOV CX,#$0004 ;8 bytes
  411. gvplp DEC BP ;go down
  412. DEC BP ;copy size, upper & lower bound,
  413. DEC BX ;component type
  414. DEC BX
  415. MOV AX,[BP]$00 ;copy entry -> buffer
  416. MOV [BX],AX
  417. LOOP gvplp ;:another
  418. POP CX ;restore
  419. RET ;"
  420. rdsymnew MOV AX,#$0100 ;'Read symbol
  421. JMP.b rsy1 ;'no numbers, verify in symtab
  422. rdsym0 MOV AX,#$0001 ;numbers allowed
  423. JMP.b rsy1 ;'
  424. rdsym XOR AX,AX ;no numbers
  425. rsy1 PUSH AX ;save flag
  426. CALL rdword ;read word
  427. POP AX ;restore flag
  428. OR.B AL,AL ;numbers allowed ?
  429. MOV AL,wrdbuf1 ;first char ?
  430. JZ rsynonum ;:no
  431. CALL number ;0..9 ?
  432. JNB rsynum ;yes: ok
  433. rsynonum CALL alpha ;valid char ?
  434. CALL errb ;no:
  435. B $3A ;58:Illegal char in ID
  436. rsynum OR.B AH,AH ;verify in symbol table ?
  437. JNZ rsynotst ;:no
  438. CALL dupvar ;test if duplicate
  439. rsynotst CALL dupkey ;test if keyword
  440. MOV BP,symtop ;destination
  441. MOV.B BL,wordbuf ;word length
  442. XOR.B BH,BH ;-> count
  443. DEC BP ;go down
  444. MOV.B [BP]$00,BL ;store length
  445. rsysto DEC BP ;go down
  446. MOV.B AL,[BX]wordbuf ;get char from buffer
  447. MOV.B [BP]$00,AL ;store in symtab
  448. DEC BX ;go back
  449. JNZ rsysto ;:another char
  450. MOV symtop,BP ;set new symtab top
  451. rsynext MOV DI,wrdend ;go to end of word
  452. JMP skipdi ;"get next word
  453. rdword CMP.B wordflg,#$FF ;read word: word available ?
  454. JNZ rdwret ;yes: ret
  455. XOR BX,BX
  456. MOV DI,chptr ;char ptr: source
  457. MOV.B AL,[DI] ;get char
  458. CALL alphanum ;char in alphanum ?
  459. JB rdwother ;:no
  460. rdwlp CMP.B BL,#$7F ;end of buffer ?
  461. JZ rdwfull ;:yes - don't store
  462. CMP AL,#$61 ;do UpCase
  463. JB rdwupper ;:no
  464. SUB AL,#$20
  465. rdwupper INC BX ;go to next pos
  466. MOV.B [BX]wordbuf,AL ;store char in buffer
  467. rdwfull INC DI ;next char from source
  468. MOV.B AL,[DI] ;get it
  469. CALL alphanum ;in alphanum ?
  470. JNB rdwlp ;yes: loop back
  471. JMP.b rdwend ;'no: end
  472. rdwother INC DI ;go to next pos
  473. INC BX
  474. MOV.B [BX]wordbuf,AL ;store char
  475. MOV.B AL,[DI] ;next char
  476. CMP AL,#$2E ;. ?
  477. JZ rdwchar2 ;:yes
  478. CMP AL,#$3D ;= ?
  479. JZ rdwchar2 ;:yes
  480. CMP AL,#$3E ;> ?
  481. JNZ rdwend ;:no
  482. rdwchar2 INC DI ;store that char
  483. INC BX
  484. MOV.B [BX]wordbuf,AL
  485. rdwend MOV.B wordbuf,BL ;store word length
  486. MOV wrdend,DI ;store end addr of word
  487. MOV.B wordflg,#$FE ;word available
  488. rdwret RET ;"
  489. search CALL srchall ;search whole symbol table
  490. JNZ rdwret ;not found:ret
  491. JMP skipdi ;"get next word
  492. srchvar MOV BX,fence ;current var fence
  493. JMP.b src1 ;'(BX=search limit)
  494. srchall MOV BX,ptcbeg ;start of symtab
  495. src1 MOV DX,CX ;type wanted
  496. CMP.B DL,wordflg ;= type of current word ?
  497. JZ srcsame ;:yes
  498. PUSH BX ;save fence
  499. CALL rdword ;read word
  500. POP BX ;restore
  501. MOV.B wordflg,DL ;store type wanted
  502. CALL srchsym ;search in symbol table
  503. JB srcnofnd ;:not found
  504. MOV typept,AL ;store type returned
  505. MOV sympos,BP ;store pos in symbol table
  506. srcsame MOV BP,sympos ;get symtab pos
  507. MOV DI,wrdend ;get end pos of word
  508. MOV CX,DX ;type -> CX
  509. CMP.B CH,typept ;compare type
  510. RET ;'
  511. srcnofnd XOR AX,AX ;type returned: none
  512. MOV typept,AL
  513. DEC AX ;not found
  514. RET ;"
  515. srchsym MOV.B CL,wordbuf ;word length
  516. XOR.B CH,CH ;-> count
  517. MOV BP,symtop2 ;symtab position
  518. PUSH SS ;SS -> ES
  519. POP ES
  520. CLD ;forward search
  521. srchloop CMP BP,BX ;fence reached ?
  522. JZ srsynf ;yes: not found
  523. ADD BP,[BP]$00 ;add offset
  524. MOV.B AL,[BP]-$01 ;get tag byte
  525. OR.B AL,AL ;0 ?
  526. JZ srchloop ;yes: invisible entry
  527. CMP AL,#$08 ;subtype ?
  528. JZ srchloop ;yes: invisible
  529. MOV AX,[BP]-$03 ;string length
  530. CMP.B AL,CL ;= searched ?
  531. JNZ srchloop ;:no
  532. CMP.B AH,DL ;= wanted type ?
  533. JNZ srchloop ;:no
  534. MOV DI,BP ;calculate string position
  535. SUB DI,#$03
  536. SUB DI,CX ;- count
  537. MOV SI,#wrdbuf1 ;word ptr
  538. MOV AX,CX ;save count
  539. REPZ ;do comparison
  540. CMPS.B
  541. XCHG AX,CX ;restore count
  542. JNZ srchloop ;not the same: continue
  543. MOV.B AL,[BP]-$01 ;get type
  544. SUB BP,#$03 ;set ptr to beg of string
  545. SUB BP,CX ;= beg of entry
  546. CLC ;found !
  547. RET ;'
  548. srsynf STC ;not found
  549. RET ;"
  550. ckey CALL rdword ;check keyword: read word
  551. POP BX ;return addr
  552. CS:
  553. MOV.B DL,[BX] ;get offset between words
  554. CS:
  555. MOV DI,[BX]$01 ;get pointer
  556. ADD BX,#$03 ;skip inline parms
  557. PUSH BX ;restore ret addr
  558. ckey2 XOR.B DH,DH ;distance between keywords
  559. MOV BX,#wordbuf ;word ptr
  560. PUSH CS ;CS -> ES
  561. POP ES
  562. CLD ;forward search
  563. ckloop CS:
  564. MOV.B CL,[DI] ;get length
  565. XOR.B CH,CH
  566. JCXZ cknf ;nothing - end of list
  567. INC CX ;-> count
  568. MOV SI,BX ;source
  569. REPZ
  570. CMPS.B ;compare words
  571. JZ ckfound ;:equal
  572. ADD DI,CX ;add remaining count
  573. ADD DI,DX ;add offset
  574. JMP ckloop ;'try next keyword
  575. cknf DEC CX ;flag: not found
  576. RET ;'
  577. ckfound MOV BX,DI ;position in keyword table
  578. CALL rsynext ;get next word
  579. CS:
  580. MOV AX,[BX] ;get word from keyword table
  581. ckret RET ;"
  582. ctoken CALL rdword ;Check keyword: read word
  583. POP BX ;return address
  584. CS:
  585. MOV DI,[BX] ;inline parm: pointer
  586. INC BX ;skip inline parm
  587. INC BX
  588. PUSH BX ;restore ret
  589. MOV SI,#wordbuf ;word ptr
  590. MOV.B CL,[SI] ;get length of keyword
  591. XOR.B CH,CH ;-> count
  592. INC CX
  593. PUSH CS ;CS -> ES
  594. POP ES
  595. CLD ;compare words
  596. REPZ
  597. CMPS.B
  598. JNZ ckret ;:not the same - ret
  599. JMP rsynext ;"ok, get next word
  600. dupkey MOV BX,#keytable ;new ID = keyword ?
  601. dkloop CS: ;pointer: list of keyword areas
  602. MOV.B DL,[BX] ;get offset
  603. CMP.B DL,#$FF ;end of table ?
  604. JZ dkret ;:yes
  605. PUSH BX ;save pointer
  606. CS:
  607. MOV DI,[BX]$01 ;get pointer into table
  608. CALL ckey2 ;check it
  609. POP BX ;restore pointer
  610. CALL errz ;yes:
  611. B $35 ;53:Reserved word
  612. INC BX ;next entry
  613. INC BX
  614. INC BX
  615. JMP dkloop ;'do next one
  616. dkret RET ;"
  617. dupvar MOV BX,fence ;Duplicate ID ?
  618. MOV.B DL,recnum ;expected type
  619. CALL srchsym ;search in symbol table
  620. JB dkret ;:ret
  621. CALL err ;43:Duplicate ID or label
  622. B $2B ;"
  623. csqr1 MOV DI,chptr ;Check [, (.
  624. CMP.B [DI],#$5B ;[ ?
  625. JZ chkskip ;yes: skip it
  626. CMP.B [DI],#$28 ;( ?
  627. JNZ chkret ;no: ret
  628. INC DI ;next char
  629. CMP.B [DI],#$2E ;. ?
  630. JMP.b chkcskip ;'check it
  631. csqr2 MOV DI,chptr ;Check ], .)
  632. CMP.B [DI],#$5D ;] ?
  633. JZ chkskip ;yes: skip it
  634. CMP.B [DI],#$2E ;. ?
  635. JNZ chkret ;no: ret
  636. INC DI ;next char
  637. CMP.B [DI],#$29 ;) ?
  638. JMP.b chkcskip ;'check it
  639. ccolon MOV AL,#$3A ;: ?
  640. JMP.b chkal ;'check it
  641. csemi MOV AL,#$3B ;semicolon ?
  642. JMP.b chkal ;'check it
  643. ccomma MOV AL,#$2C ;, ?
  644. JMP.b chkal ;'check it
  645. cdot MOV AL,#$2E ;. ?
  646. JMP.b chkal ;'check it
  647. cbrack1 MOV AL,#$28 ;( ?
  648. JMP.b chkal ;'check it
  649. cbrack2 MOV AL,#$29 ;) ?
  650. JMP.b chkal ;'check it
  651. cequal MOV AL,#$3D ;= ?
  652. JMP.b chkal ;'check it
  653. cptr MOV AL,#$5E ;^ ?
  654. chkal MOV DI,chptr ;current char = AL ?
  655. CMP.B AL,[DI] ;compare
  656. chkcskip JNZ chkret ;no: ret
  657. chkskip INC DI ;skip it
  658. JMP.b skipdi ;'read next word
  659. NOP
  660. chkret RET ;"
  661. esqr1 CALL csqr1 ;expect [: check [
  662. CALL errnz ;no:
  663. B $08 ;8:[ expected
  664. RET ;"
  665. esqr2 CALL csqr2 ;expect ]: check ]
  666. CALL errnz ;no:
  667. B $09 ;9:] expected
  668. RET ;"
  669. ecolon CALL ccolon ;expect :
  670. CALL errnz ;no:
  671. B $02 ;2:':' expected
  672. ecolret RET ;"
  673. esemi CALL csemi ;expect semicolon
  674. JZ ecolret ;yes: ret
  675. esemierr CALL err ;1:Semicolon expected
  676. B $01 ;'
  677. esemi2 CALL csemi ;expect semicolon
  678. JZ ecolret ;yes: ret
  679. CMP.B semiflg,#$00 ;flag set ?
  680. JZ esemierr ;yes: error 1
  681. CALL err ;41:Unknown ID or syntax error
  682. B $29 ;"
  683. ecomma CALL ccomma ;expect ,
  684. CALL errnz ;no:
  685. B $03 ;3:',' expected
  686. RET ;"
  687. ebrack1 CALL cbrack1 ;expect (
  688. CALL errnz ;no:
  689. B $04 ;4:'(' expected
  690. RET ;"
  691. ebrack2 CALL cbrack2 ;expect )
  692. CALL errnz ;no:
  693. B $05 ;5:')' expected
  694. RET ;"
  695. eequal CALL cequal ;expect =
  696. CALL errnz ;no:
  697. B $06 ;6:'=' expected
  698. RET ;"
  699. eassign CALL ctoken ;expect :=
  700. W tkassign ;check token
  701. CALL errnz ;no:
  702. B $07 ;7:':=' expected
  703. RET ;"
  704. expof CALL ctoken ;expect OF
  705. W tkof ;check token
  706. CALL errnz ;no:
  707. B $0F ;15:OF expected
  708. RET ;"
  709. ;This routine skips spaces until next word is reached.
  710. skip MOV DI,chptr ;get next word: get char ptr
  711. skipdi MOV.B semiflg,#$00 ;flag for semicolon error
  712. MOV.B wordflg,#$FF ;search flag
  713. skloop MOV AX,[DI] ;get char (two, actually)
  714. CMP AL,#$20 ;space, control ?
  715. JBE skspace ;yes: skip spaces
  716. CMP AL,#$7B ; '{' ?
  717. JZ skcom2 ;yes: comment
  718. CMP AX,#$2A28 ; '(*' ?
  719. JZ skcom ;yes: comment
  720. MOV chptr,DI ;set char pointer
  721. XOR AX,AX ;ok
  722. RET ;'
  723. skspace CALL getchar ;skip spaces: get char
  724. JMP skloop ;'loop back
  725. skcom CALL getchar ;Comment: get char
  726. skcom2 PUSH DX ;save
  727. MOV.B DL,[DI] ;comment type
  728. CMP.B [DI]$01,#$24 ;$ ?
  729. JZ cdirec ;yes: compiler directive
  730. skcomlp CALL getchar ;get char
  731. skcom3 MOV AX,[DI] ;test two chars
  732. CMP.B DL,#$2A ; '(*' ?
  733. JNZ skcomcur ;:no
  734. CMP AX,#$292A ;now '*)' ?
  735. JNZ skcomlp ;no: loop back
  736. CALL getchar ;end of comment - get char
  737. JMP.b skcomend ;'continue scanning
  738. skcomcur CMP AL,#$7D ; '}' ?
  739. JNZ skcomlp ;no: loop back
  740. skcomend POP DX ;restore
  741. JMP skspace ;"continue scanning
  742. cdirec PUSH BX ;Compiler directive: save regs
  743. PUSH CX
  744. PUSH DX
  745. CALL getchar ;get char
  746. cdlop CALL getchar ;get char
  747. MOV.B AL,[DI] ;get directive
  748. CALL upcase ;UpCase
  749. CMP AL,#$49 ;I ? I/O-error handling, Include
  750. MOV DX,#$0001 ;flag
  751. JZ cdplus ;:yes +-
  752. CMP AL,#$52 ;R ? Range checking
  753. MOV DX,#$0002
  754. JZ cdplus ;:yes +-
  755. CMP AL,#$42 ;B ? I/O-mode (CON or TRM)
  756. MOV DX,#$0004
  757. JZ cdplus ;:yes +-
  758. CMP AL,#$43 ;C ? Control C and S
  759. MOV DX,#$0008
  760. JZ cdplus ;:yes +-
  761. CMP AL,#$55 ;U ? User Interrupt
  762. MOV DX,#$0010
  763. JZ cdplus ;:yes +-
  764. CMP AL,#$4B ;K ? Stack check
  765. MOV DX,#$0020
  766. JZ cdplus ;:yes +-
  767. CMP AL,#$56 ;V ? Type checking
  768. MOV DX,#$0040
  769. JZ cdplus ;:yes +-
  770. CMP AL,#$44 ;D ? Device checking
  771. MOV DX,#$0080
  772. JZ cdplus ;:yes +-
  773. CMP AL,#$47 ;G ? Input file buffer size
  774. MOV BX,#cinpsize ;dest var: buffer size
  775. JZ cdnum ;:yes #
  776. CMP AL,#$50 ;P ? Output file buffer size
  777. MOV BX,#coutsize ;dest var: buffer size
  778. JZ cdnum ;:yes #
  779. CMP AL,#$46 ;F ? Max number open files
  780. MOV BX,#cmaxfil ;dest var: max files
  781. JZ cdnum ;:yes #
  782. XOR DX,DX ;no flag
  783. CMP AL,#$41 ;A ? Absolute code
  784. JZ cdplus ;:yes +-
  785. CMP AL,#$57 ;W ? WITH nesting
  786. JZ cdignore ;:yes #
  787. CMP AL,#$58 ;X ? Array optimization
  788. JZ cdplus ;:yes +-
  789. CMP AL,#$4F ;O ?
  790. JZ cdignore ;:yes #
  791. cderr CALL perr ;remember pos
  792. B $5D ;'93:Invalid compiler directive
  793. cdend POP DX ;restore regs
  794. POP CX
  795. POP BX
  796. JMP skcom3 ;'continue scanning comment
  797. cdplus CALL getchar ;+/- directive: get char
  798. MOV.B AL,[DI] ;read it
  799. XOR CX,CX ;clear flag
  800. CMP AL,#$2B ; '+' ?
  801. JZ cdset ;:yes
  802. DEC CX ;set flag
  803. CMP AL,#$2D ; '-' ?
  804. JZ cdset ;:yes
  805. CMP DX,#$01 ;include ?
  806. JZ cdinclsk ;yes: do it
  807. JMP cderr ;'Invalid compiler directive
  808. cdset MOV AX,direct ;old directives
  809. XOR AX,CX ;invert if reset bit
  810. OR AX,DX ;set / reset bit
  811. XOR AX,CX ;invert if reset bit
  812. MOV direct,AX ;set new directive
  813. CALL getchar ;get char
  814. cdnext MOV.B AL,[DI] ; ',' ?
  815. CMP AL,#$2C
  816. JNZ cdend ;no: end directive
  817. JMP cdlop ;'yes: loop back
  818. cdignore CALL getchar ;Ignore directive: get char
  819. MOV.B AL,[DI]
  820. CALL alphanum ;valid char ?
  821. JNB cdignore ;yes: continue
  822. JMP cdnext ;'another directive ?
  823. cdnum CALL getchar ;Get number: get char
  824. PUSH BX ;save dest ptr
  825. MOV BX,DI ;position
  826. CALL asccard ;read integer
  827. MOV DI,BX ;new position
  828. POP BX ;dest ptr
  829. JB cderr ;:error
  830. OR AX,AX ;0 ?
  831. JZ cderr ;yes: error
  832. MOV [BX],AX ;store result
  833. JMP cdnext ;'another directive ?
  834. cdinclsk CMP.B [DI],#$20 ;Set include file: space ?
  835. JNZ cdincl ;no: do it
  836. CALL getchar ;get char
  837. JMP cdinclsk ;'skip spaces
  838. cdincl CMP.B inclflg,#$00 ;include file active ?
  839. CALL errnz ;yes:
  840. B $60 ;96:Illegal nesting of include files
  841. MOV BX,DI ;position
  842. CALL kpasext ;parse filename, default .PAS
  843. PUSH BX ;save pos
  844. MOV DI,#inclpn ;copy path name
  845. CALL fnscdi ;-> include filename buffer
  846. POP DI ;restore pos
  847. MOV AX,#$3D00 ;open file
  848. MOV DX,#inclpn ;name ptr
  849. PUSH DS ;DS -> ES
  850. POP ES
  851. CALL dos ;open it
  852. CALL errb ;90:File not found
  853. B $5A
  854. MOV incfile,AX ;store file handle
  855. MOV AX,direct ;save compiler directives
  856. MOV direcin,AX
  857. XOR AX,AX ;clear vars:
  858. MOV bufpt,AX ;buffer ptr
  859. MOV bufend,AX ;buffer end
  860. MOV frelpos,AX ;relative pos in file
  861. MOV.B inclflg,#$FF ;set include flag
  862. CALL disline ;display line number
  863. JMP cdend ;"restore regs, continue scanning
  864. getchar MOV.B AL,[DI] ;Get char
  865. INC DI ;go to next one
  866. OR.B AL,AL ;end of line ?
  867. JZ getln ;:yes
  868. RET ;'
  869. getln PUSH BX ;save regs
  870. PUSH CX
  871. PUSH DX
  872. CMP.B srcend,#$00 ;last line ?
  873. CALL perrnz ;yes:
  874. B $5B ;91:Unexpected end of source
  875. INC lincnt ;count lines
  876. MOV DI,#pnbuf ;destination: line buffer
  877. MOV CX,#$007F ;up to 127 chars
  878. CMP.B inclflg,#$00 ;from include file ?
  879. JNZ fileline ;:yes
  880. MOV BX,srcptr ;pointer into text
  881. MOV srclnbeg,BX ;-> beginning of source line
  882. memline MOV.B AL,[BX] ;get char
  883. CMP AL,#$1A ;^Z ?
  884. JZ memeof ;yes: mark end of source
  885. INC BX ;next char
  886. CMP AL,#$0D ;CR ?
  887. JZ memlf ;yes: end of line
  888. MOV.B [DI],AL ;store in buffer
  889. INC DI ;next pos
  890. LOOP memline ;:another char
  891. JMP.b memsto ;'end it
  892. memlf CMP.B [BX],#$0A ;LF ?
  893. JNZ memsto ;no: forget it
  894. INC BX ;yes: skip it
  895. JMP.b memsto ;'set new pos
  896. memeof MOV srcend,AL ;set flag: end of source
  897. memsto MOV srcptr,BX ;store new pos in buffer
  898. JMP.b filesto ;'mark end of line
  899. fileline MOV BX,bufpt ;buffer pointer
  900. MOV AX,frelpos ;relative pos in file
  901. ADD AX,BX ;+ buffer offset
  902. SUB AX,bufend ;- buffer end
  903. MOV srclnbg,AX ;-> pos of line begin
  904. fileloop CALL getincl ;get char from include file
  905. CMP AL,#$1A ;^Z ?
  906. JZ fileeof ;:yes, close include
  907. INC BX ;next char
  908. CMP AL,#$0D ;CR ?
  909. JZ filelf ;yes: end of line
  910. MOV.B [DI],AL ;store char in buffer
  911. INC DI ;next pos
  912. LOOP fileloop ;:another char
  913. JMP.b filelf2 ;'end it
  914. filelf CALL getincl ;get char from include file
  915. CMP AL,#$0A ;LF ?
  916. JNZ filelf2 ;no: forget it
  917. INC BX ;skip
  918. filelf2 MOV bufpt,BX ;store buffer ptr
  919. JMP.b filesto ;'mark end of line
  920. fileeof MOV.B inclflg,#$00 ;clear include flag
  921. MOV AX,direcin ;restore directives to
  922. MOV direct,AX ;state before include
  923. MOV AH,#$3E ;close
  924. MOV BX,incfile ;file handle
  925. CALL dos
  926. filesto MOV.B [DI],#$00 ;store a 0 at the end
  927. MOV DI,#pnbuf ;go to beg of buffer
  928. CALL disline1 ;display line number
  929. POP DX ;restore regs
  930. POP CX
  931. POP BX
  932. RET ;"
  933. getincl CMP BX,bufend ;Get char from include file
  934. JB ginend ;:not yet end of buffer
  935. PUSH CX ;save
  936. MOV AH,#$3F ;read byte block
  937. MOV BX,incfile ;file handle
  938. MOV CX,#$0080 ;128 bytes
  939. MOV DX,#inclbuf ;buffer ptr
  940. MOV SI,#$0080 ;?
  941. CALL dos ;read buffer
  942. POP CX ;restore
  943. JNB ginok ;:ok
  944. XOR AX,AX ;nothing read
  945. ginok MOV BX,#inclbuf ;start of buffer
  946. OR AX,AX ;anything read ?
  947. JNZ ginnoeof ;:yes
  948. MOV.B [BX],#$1A ;store ^Z
  949. INC AX ;1 char
  950. ginnoeof ADD frelpos,AX ;relative pos in file
  951. ADD AX,BX ;pos of buffer end
  952. MOV bufend,AX
  953. ginend MOV.B AL,[BX] ;get char
  954. RET ;"
  955. disline1 TEST.B lincnt,#$0F ;Display line number
  956. JZ disline ;:once every 16 lines
  957. RET ;'
  958. disline PUSH AX ;save regs
  959. PUSH BX
  960. PUSH CX
  961. PUSH DX
  962. MOV AL,#$0D ;write CR
  963. CALL conput
  964. CMP.B inclflg,#$00 ;include ?
  965. JZ dismem ;:no
  966. MOV AL,#$49 ;I
  967. JMP.b disincl ;'
  968. dismem MOV AL,#$20 ;space
  969. disincl CALL conput ;write it
  970. MOV AL,#$20 ;write space
  971. CALL conput
  972. MOV AX,lincnt ;get line number
  973. CALL knum1 ;display it
  974. CALL xkeypres ;Keypressed
  975. OR.B AL,AL ;test flag
  976. JZ disret ;:no
  977. CALL prints ;write string
  978. B " *** Abort compilation",$00
  979. CALL yorn ;Y or N ?
  980. JZ disok ;no: continue
  981. CALL err ;CA:Compilation aborted
  982. B $CA ;'
  983. disok MOV CX,#$0020 ;clear 32 bytes
  984. disera CALL prints ;write BS space BS
  985. B $08," ",$08,$00
  986. LOOP disera ;:another
  987. disret POP DX ;restore regs
  988. POP CX
  989. POP BX
  990. POP AX
  991. RET ;"
  992. ;*** Start of Tables ***
  993. ;Standard definitions
  994. W $000E,$02FC
  995. B "INTEGER",$07,$00,$03
  996. W $000B,$0308
  997. B "CHAR",$04,$00,$03
  998. W $000B,$0314
  999. B "REAL",$04,$00,$03
  1000. W $000E,$0320
  1001. B "BOOLEAN",$07,$00,$03
  1002. W $000B,$0338
  1003. B "BYTE",$04,$00,$03
  1004. W $000C,$0001
  1005. B $0B,"TRUE",$04,$00,$02
  1006. W $000D,$0000
  1007. B $0B,"FALSE",$05,$00,$02
  1008. W $000E,$7FFF
  1009. B $0A,"MAXINT",$06,$00,$02
  1010. W $000D,$0000
  1011. B $0A,"BLACK",$05,$00,$02
  1012. W $000C,$0001
  1013. B $0A,"BLUE",$04,$00,$02
  1014. B $0D,$00,$02,$00
  1015. B $0A,"GREEN",$05,$00,$02
  1016. W $000C,$0003
  1017. B $0A,"CYAN",$04,$00,$02
  1018. W $000B,$0004
  1019. B $0A,"RED",$03,$00,$02
  1020. W $000F,$0005
  1021. B $0A,"MAGENTA",$07,$00,$02
  1022. W $000D,$0006
  1023. B $0A,"BROWN",$05,$00,$02
  1024. W $0011,$0007
  1025. B $0A,"LIGHTGRAY",$09,$00,$02
  1026. W $0010,$0008
  1027. B $0A,"DARKGRAY",$08,$00,$02
  1028. W $0011,$0009
  1029. B $0A,"LIGHTBLUE",$09,$00,$02
  1030. W $0012,$000A
  1031. B $0A,"LIGHTGREEN",$0A,$00,$02
  1032. W $0011,$000B
  1033. B $0A,"LIGHTCYAN",$09,$00,$02
  1034. W $0010,$000C
  1035. B $0A,"LIGHTRED",$08,$00,$02
  1036. W $0014,$000D
  1037. B $0A,"LIGHTMAGENTA",$0C,$00,$02
  1038. W $000E,$000E
  1039. B $0A,"YELLOW",$06,$00,$02
  1040. W $000D,$000F
  1041. B $0A,"WHITE",$05,$00,$02
  1042. W $000D,$0010
  1043. B $0A,"BLINK",$05,$00,$02
  1044. W $000C,$0000
  1045. B $0A,"BW40",$04,$00,$02
  1046. W $000C,$0002
  1047. B $0A,"BW80",$04,$00,$02
  1048. W $000B,$0001
  1049. B $0A,"C40",$03,$00,$02
  1050. W $000B,$0003
  1051. B $0A,"C80",$03,$00,$02
  1052. W $000E
  1053. W $2182,$DAA2,$490F ; 3.1415926536E+00
  1054. B $09,"PI",$02,$00,$02
  1055. W $0011,$FF00
  1056. W conbufln
  1057. W $0338
  1058. B "BUFLEN",$06,$00,$04
  1059. W $0012,$FF00
  1060. W hptop
  1061. W $0344
  1062. B "HEAPPTR",$07,$00,$04
  1063. W $0011,$FF00
  1064. W stdout
  1065. W $032C
  1066. B "OUTPUT",$06,$00,$04
  1067. W $0010,$FF00
  1068. W stdin
  1069. W $032C
  1070. B "INPUT",$05,$00,$04
  1071. W $000E,$FF00
  1072. W filcon
  1073. W $032C
  1074. B "CON",$03,$00,$04
  1075. W $000E,$FF00
  1076. W filcon
  1077. W $032C
  1078. B "TRM",$03,$00,$04
  1079. W $000E,$FF00
  1080. W filkbd
  1081. W $032C
  1082. B "KBD",$03,$00,$04
  1083. W $000E,$FF00
  1084. W fillst
  1085. W $032C
  1086. B "LST",$03,$00,$04
  1087. W $000E,$FF00
  1088. W filaux
  1089. W $032C
  1090. B "AUX",$03,$00,$04
  1091. W $000E,$FF00
  1092. W filusr
  1093. W $032C
  1094. B "USR",$03,$00,$04
  1095. W $0011,$FF00
  1096. W cbreak
  1097. W $0320
  1098. B "CBREAK",$06,$00,$04
  1099. W $0013,$FF00
  1100. W vkbdstat
  1101. W $02FC
  1102. B "CONSTPTR",$08,$00,$04
  1103. W $0013,$FF00
  1104. W vkbdget
  1105. W $02FC
  1106. B "CONINPTR",$08,$00,$04
  1107. W $0014,$FF00
  1108. W vconput
  1109. W $02FC
  1110. B "CONOUTPTR",$09,$00,$04
  1111. W $0014,$FF00
  1112. W vprnput
  1113. W $02FC
  1114. B "LSTOUTPTR",$09,$00,$04
  1115. W $0014,$FF00
  1116. W vauxput
  1117. W $02FC
  1118. B "AUXOUTPTR",$09,$00,$04
  1119. W $0013,$FF00
  1120. W vauxget
  1121. W $02FC
  1122. B "AUXINPTR",$08,$00,$04
  1123. W $0014,$FF00
  1124. W vusrput
  1125. W $02FC
  1126. B "USROUTPTR",$09,$00,$04
  1127. W $0013,$FF00
  1128. W vusrget
  1129. W $02FC
  1130. B "USRINPTR",$08,$00,$04
  1131. W $0013,$FF00
  1132. W verror
  1133. W $02FC
  1134. B "ERRORPTR",$08,$00,$04 ;"
  1135. ; Standard types
  1136. ; link type lower upper size tag: invisible
  1137. B $0C,$00,$0A,$00,$00,$80,$FF,$7F,$02,$00,$00,$00 ;integer
  1138. B $0C,$00,$0C,$00,$00,$00,$FF,$00,$01,$00,$00,$00 ;char
  1139. B $0C,$00,$09,$00,$00,$00,$00,$00,$06,$00,$00,$00 ;real
  1140. B $0C,$00,$0B,$00,$00,$00,$01,$00,$01,$00,$00,$00 ;boolean
  1141. B $0C,$00,$06,$00,$00,$00,$00,$00,$CC,$00,$00,$00 ;text file
  1142. B $0C,$00,$0A,$00,$00,$00,$FF,$00,$01,$00,$00,$00 ;byte
  1143. B $0C,$00,$04,$00,$00,$00,$00,$00,$04,$00,$00,$00 ;pointer
  1144. B $0C,$00,$08,$00,$00,$00,$00,$00,$09,$00,$00,$00 ;string
  1145. B $0C,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;untyped file
  1146. B $0C,$00,$07,$00,$00,$00,$00,$00,$4C,$00,$00,$00 ;"typed file
  1147. ;Patch table to patch in pointers to type entries
  1148. ;Offsets relative to 9277
  1149. varpatch W $0002,$0010,$001B,$0026,$0034,$01A0,$01B1,$01C3,$01D4
  1150. W $01E4,$01F2,$0200,$020E,$021C,$022A,$0249,$025C,$026F
  1151. W $0283,$0297,$02AB,$02BE,$02D2,$02E5,$0238
  1152. ;"
  1153. keytable B $00 ;Pointers into keyword table
  1154. W tkprog ;(offset between entries, pointer)
  1155. B $01
  1156. W tklabel
  1157. B $02
  1158. W tkbegin
  1159. B $04
  1160. W tkto
  1161. B $05
  1162. W tkmul2
  1163. B $05
  1164. W tkadd2
  1165. B $02
  1166. W tkcmp2
  1167. B $FF ;"end of table
  1168. tkprog B $07,"PROGRAM" ;Keyword table
  1169. tkend B $03,"END"
  1170. tkforwrd B $07,"FORWARD"
  1171. tkext B $08,"EXTERNAL"
  1172. tkpacked B $06,"PACKED"
  1173. tkarray B $05,"ARRAY"
  1174. tkfile B $04,"FILE"
  1175. tkset B $03,"SET"
  1176. tkrec B $06,"RECORD"
  1177. tkstr B $06,"STRING"
  1178. tkof B $02,"OF"
  1179. tkabs B $08,"ABSOLUTE"
  1180. tkthen B $04,"THEN"
  1181. tkelse B $04,"ELSE"
  1182. tkdo B $02,"DO"
  1183. tkuntil B $05,"UNTIL"
  1184. tknot B $03,"NOT"
  1185. tknil B $03,"NIL",$00 ;'
  1186. tktext B $04,"TEXT" ;other reserved words
  1187. tk2dot B $02,".."
  1188. tkassign B $02,":=" ;'
  1189. tklabel B $05,"LABEL",$01 ;definition part
  1190. B $05,"CONST",$02 ;byte at the end = token
  1191. B $04,"TYPE",$03
  1192. tkvar B $03,"VAR",$04
  1193. B $05,"BEGIN",$08
  1194. tkover B $07,"OVERLAY",$07
  1195. tkproc B $09,"PROCEDURE",$05
  1196. B $08,"FUNCTION",$06,$00 ;'
  1197. tkbegin B $05,"BEGIN" ;program part
  1198. W block ;word = vector to compiler routine
  1199. B $02,"IF"
  1200. W if
  1201. B $05,"WHILE"
  1202. W while
  1203. B $06,"REPEAT"
  1204. W repeat
  1205. B $03,"FOR"
  1206. W for
  1207. tkcase B $04,"CASE"
  1208. W case
  1209. B $04,"GOTO"
  1210. W goto
  1211. B $04,"WITH"
  1212. W with
  1213. B $06,"INLINE"
  1214. W inline
  1215. B $00 ;'
  1216. tkto B $02,"TO" ;keywords used with FOR
  1217. B $7D,$41,$49,$00 ;JGE / INC CX / DEC CX
  1218. B $06,"DOWNTO"
  1219. B $7E,$49,$41,$08 ;JNG / DEC CX / INC CX
  1220. B $00 ;'
  1221. tkmem B $03,"MEM",$01 ;special arrays
  1222. B $04,"MEMW",$02 ;(not reserved)
  1223. B $00 ;'
  1224. ;Code descriptors: parameters for the code generator
  1225. ;+0:operation #
  1226. ;+1:opcode immediate form
  1227. ;+2:standard opcode
  1228. ;+4:option bits
  1229. ; 1:XCHG CX,AX needed
  1230. ; 2:no immediate form available
  1231. ; 4:no var form available
  1232. ; 8:CWD needed
  1233. ;" 10:XCHG DX,AX needed at end
  1234. tkmul B $01,"*" ;Multiplication ops
  1235. B $00,$00,$F7,$E9,$02 ;no imme, IMUL CX
  1236. B $01,"/"
  1237. B $01,$00,$00,$00,$00 ;real only !
  1238. tkmul2 B $03,"AND" ;AND AX,CX
  1239. B $02,$25,$23,$C1,$00
  1240. B $03,"MOD" ;IDIV CX
  1241. B $03,$00,$F7,$F9,$1B ;no imme, both XCHG, CWD
  1242. B $03,"DIV" ;IDIV CX
  1243. B $04,$00,$F7,$F9,$0B ;no imme, XCHG CX,AX, CWD
  1244. B $03,"SHL" ;SHL AX,CL
  1245. B $05,$00,$D3,$E0,$07 ;no imme, no var, XCHG CX,AX
  1246. B $03,"SHR" ;SHR AX,CL
  1247. B $06,$00,$D3,$E8,$07 ;no imme, no var, XCHG CX,AX
  1248. B $00 ;'
  1249. tkadd B $01,"+" ;Addition ops
  1250. B $00,$05,$03,$C1,$00 ;ADD AX,CX
  1251. B $01,"-" ;SUB AX,CX
  1252. B $01,$2D,$2B,$C1,$01 ;XCHG CX,AX
  1253. tkadd2 B $02,"OR" ;OR AX,CX
  1254. B $02,$0D,$0B,$C1,$00
  1255. B $03,"XOR" ;XOR AX,CX
  1256. B $03,$35,$33,$C1,$00
  1257. B $00 ;'
  1258. tkcmp B $01,"=" ;Comparison ops
  1259. B $00,$74 ;table offset, branch op: JZ
  1260. B $02,"<>"
  1261. B $08,$75 ;JNZ
  1262. B $02,">="
  1263. B $10,$7D ;JGE
  1264. B $02,"<="
  1265. B $18,$7E ;JNG
  1266. B $01,">"
  1267. B $20,$7F ;JG
  1268. B $01,"<"
  1269. B $28,$7C ;JL
  1270. tkcmp2 B $02,"IN"
  1271. B $FF,$00 ;special
  1272. B $00 ;'
  1273. cmpcode B $00,$3D,$3B,$C1,$01 ;"CMP AX,CX; XCHG CX,AX
  1274. stdprocs B $07,"WRITELN" ;Standard procedures
  1275. W pwriteln ;vector to COMPILER routine
  1276. B $05,"WRITE"
  1277. W pwrite
  1278. B $06,"READLN"
  1279. W preadln
  1280. B $04,"READ"
  1281. W pread
  1282. B $06,"DELETE"
  1283. W pdelete
  1284. B $06,"INSERT"
  1285. W pinsert
  1286. B $06,"GOTOXY"
  1287. W pgotoxy
  1288. B $06,"ASSIGN"
  1289. W passign
  1290. B $05,"RESET"
  1291. W preset
  1292. B $07,"REWRITE"
  1293. W prewrite
  1294. B $06,"APPEND"
  1295. W pappend
  1296. B $05,"CLOSE"
  1297. W pclose
  1298. B $05,"ERASE"
  1299. W perase
  1300. B $06,"RENAME"
  1301. W prename
  1302. B $04,"SEEK"
  1303. W pseek
  1304. B $08,"LONGSEEK"
  1305. W pseek
  1306. B $03,"NEW"
  1307. W pnew
  1308. B $04,"MARK"
  1309. W pmark
  1310. B $07,"RELEASE"
  1311. W prelease
  1312. B $06,"GETMEM"
  1313. W pgetmem
  1314. B $07,"DISPOSE"
  1315. W pdispose
  1316. B $07,"FREEMEM"
  1317. W pfreemem
  1318. B $03,"STR"
  1319. W pstr
  1320. B $03,"VAL"
  1321. W pval
  1322. B $09,"BLOCKREAD"
  1323. W pblockrd
  1324. B $0A,"BLOCKWRITE"
  1325. W pblockwr
  1326. B $05,"CHDIR"
  1327. W pchdir
  1328. B $05,"MKDIR"
  1329. W pmkdir
  1330. B $05,"RMDIR"
  1331. W prmdir
  1332. B $06,"GETDIR"
  1333. W pgetdir
  1334. B $07,"OVRPATH"
  1335. W povrpath
  1336. B $09,"RANDOMIZE"
  1337. W prndmize
  1338. B $04,"MOVE"
  1339. W pmove
  1340. B $08,"FILLCHAR"
  1341. W pfillchr
  1342. B $04,"EXIT"
  1343. W pexit
  1344. B $04,"HALT"
  1345. W phalt
  1346. B $05,"PORTW"
  1347. W pportw
  1348. B $04,"PORT"
  1349. W pport
  1350. B $05,"FLUSH"
  1351. W pflush
  1352. B $08,"TRUNCATE"
  1353. W ptruncat
  1354. B $07,"EXECUTE"
  1355. W pexecute
  1356. B $05,"CHAIN"
  1357. W pchain
  1358. B $04,"INTR"
  1359. W pintr
  1360. B $05,"MSDOS"
  1361. W pmsdos
  1362. B $07,"CRTINIT"
  1363. W pcrtinit
  1364. B $07,"CRTEXIT"
  1365. W pcrtexit
  1366. B $06,"CLRSCR"
  1367. W pclrscr
  1368. B $06,"CLREOL"
  1369. W pclreol
  1370. B $09,"HIGHVIDEO"
  1371. W pnrmvid
  1372. B $09,"NORMVIDEO"
  1373. W pnrmvid
  1374. B $08,"LOWVIDEO"
  1375. W plowvid
  1376. B $07,"INSLINE"
  1377. W pinsline
  1378. B $07,"DELLINE"
  1379. W pdelline
  1380. B $05,"DELAY"
  1381. W pdelay
  1382. B $06,"WINDOW"
  1383. W pwindow
  1384. B $09,"TEXTCOLOR"
  1385. W ptextcol
  1386. B $0E,"TEXTBACKGROUND"
  1387. W ptextbg
  1388. B $0E,"GRAPHCOLORMODE"
  1389. W pgrcolmd
  1390. B $09,"GRAPHMODE"
  1391. W pgrmode
  1392. B $05,"HIRES"
  1393. W phires
  1394. B $08,"TEXTMODE"
  1395. W ptxtmode
  1396. B $0F,"GRAPHBACKGROUND"
  1397. W pgraphbg
  1398. B $07,"PALETTE"
  1399. W ppalette
  1400. B $0A,"HIRESCOLOR"
  1401. W phirscol
  1402. B $0B,"GRAPHWINDOW"
  1403. W pgrwind
  1404. B $04,"PLOT"
  1405. W pplot
  1406. B $04,"DRAW"
  1407. W pdraw
  1408. B $05,"SOUND"
  1409. W psound
  1410. B $07,"NOSOUND"
  1411. W pnosound
  1412. B $00 ;"
  1413. stdfuncs B $03,"CHR" ;Standard functions
  1414. W fchr ;vector to COMPILER routine
  1415. B $03,"ORD"
  1416. W ford
  1417. B $04,"COPY"
  1418. W fcopy
  1419. B $06,"LENGTH"
  1420. W flength
  1421. B $03,"POS"
  1422. W fpos
  1423. B $06,"CONCAT"
  1424. W fconcat
  1425. B $04,"SUCC"
  1426. W fsucc
  1427. B $04,"PRED"
  1428. W fpred
  1429. B $06,"UPCASE"
  1430. W fupcase
  1431. B $05,"TRUNC"
  1432. W ftrunc
  1433. B $05,"ROUND"
  1434. W fround
  1435. B $03,"ODD"
  1436. W fodd
  1437. B $03,"ABS"
  1438. W fabs
  1439. B $03,"SQR"
  1440. W fsqr
  1441. B $04,"SQRT"
  1442. W fsqrt
  1443. B $03,"SIN"
  1444. W fsin
  1445. B $03,"COS"
  1446. W fcos
  1447. B $06,"ARCTAN"
  1448. W farctan
  1449. B $02,"LN"
  1450. W fln
  1451. B $03,"EXP"
  1452. W fexp
  1453. B $06,"RANDOM"
  1454. W frandom
  1455. B $03,"INT"
  1456. W fint2
  1457. B $04,"FRAC"
  1458. W ffrac
  1459. B $0A,"PARAMCOUNT"
  1460. W fparmcnt
  1461. B $08,"PARAMSTR"
  1462. W fparmstr
  1463. B $02,"LO"
  1464. W flo
  1465. B $02,"HI"
  1466. W fhi
  1467. B $04,"SWAP"
  1468. W fswap
  1469. B $08,"IORESULT"
  1470. W fiores
  1471. B $03,"EOF"
  1472. W feof
  1473. B $04,"EOLN"
  1474. W feoln
  1475. B $07,"SEEKEOF"
  1476. W fseekeof
  1477. B $08,"SEEKEOLN"
  1478. W fseekeol
  1479. B $08,"FILESIZE"
  1480. W ffilsize
  1481. B $0C,"LONGFILESIZE"
  1482. W flfilsiz
  1483. B $07,"FILEPOS"
  1484. W ffilpos
  1485. B $0B,"LONGFILEPOS"
  1486. W flfilpos
  1487. B $0A,"KEYPRESSED"
  1488. W fkeypres
  1489. B $08,"MAXAVAIL"
  1490. W fmaxavl
  1491. B $08,"MEMAVAIL"
  1492. W fmemavl
  1493. B $05,"PORTW"
  1494. W fportw
  1495. B $04,"PORT"
  1496. W fport
  1497. B $04,"ADDR"
  1498. W faddr
  1499. B $03,"PTR"
  1500. W fptr
  1501. B $03,"OFS"
  1502. W fofs
  1503. B $03,"SEG"
  1504. W fseg
  1505. B $06,"SIZEOF"
  1506. W fsizeof
  1507. tkdseg B $04,"DSEG"
  1508. W fdseg
  1509. tkcseg B $04,"CSEG"
  1510. W fcseg
  1511. B $04,"SSEG"
  1512. W fsseg
  1513. B $06,"WHEREX"
  1514. W fwherex
  1515. B $06,"WHEREY"
  1516. W fwherey ;"
  1517. ;*** End of Turbo 3.0 ***
  1518. B $00