Source code that moves the variables out of the direct page and runs VTL-2 in Joe H. Allen's EXORsim, should run in the EXORciser, and should be modifiable to run on a variety of systems. Can be assembled with my asm68c. The & and * variables are set automatically now because of the variable relocation.

形式
Asm
投稿日時
2022-08-13 10:09
公開期間
無期限
  1. * VTL-2
  2. * V-3.6
  3. * 9-23-76
  4. * BY GARY SHANNON
  5. * & FRANK MCCOY
  6. * COPYWRIGHT 1976, THE COMPUTER STORE
  7. *
  8. * Modifications for exorsim
  9. * and for moving variables out of direct page
  10. * by Joel Matthew Rees
  11. * Copyright 2022, Joel Matthew Rees
  12. * Modifications explained at
  13. * https://joels-programming-fun.blogspot.com/2022/08/vtl-2-part-2-moving-variables-out-of-direct-page.html
  14. *
  15. * DEFINE LOCATIONS IN MONITOR
  16. * INCH EQU $FF00 ; per VTL.ASM
  17. EINCH EQU $F012 ; exorsim mdos Input byte with echo unless AECHO is set
  18. * INCH EQU $F015 ; exorsim mdos Input char with echo (F012 -> strip bit 7)
  19. * POLCAT EQU $FF24 ; from VTL.ASM
  20. * OUTCH EQU $FF81 ; from VTL.ASM
  21. EOUTCH EQU $F018 ; exorsim mdos Output character with NULs
  22. * OUTS EQU $FF82 ; from VTL.ASM
  23. EPCRLF EQU $F021 ; Primarily for forced initialization in exorsim.
  24. *
  25. * FOR SBC6800
  26. BREAK EQU $1B ; BREAK KEY
  27. * For exorsim
  28. ACIACS EQU $FCF4 ; exorcisor
  29. ACIADA EQU $FCF5 ; exorcisor
  30. *
  31. * SET ASIDE FOUR BYTES FOR USER
  32. * DEFINED INTERUPT ROUTINE IF NEEDED
  33. ORG $0200
  34. * ZERO must be set at even $100 boundary for address math to work.
  35. ZERO RMB 4 ; INTERUPT VECTOR
  36. AT RMB 2 ; CANCEL & C-R
  37. *
  38. * GENERAL PURPOSE STORRGE
  39. VARS RMB 52 ; VARIABLES(A-Z)
  40. BRAK RMB 2 ; [
  41. SAVE10 RMB 2 ; BACK SLASH
  42. BRIK RMB 2 ; ]
  43. UP RMB 2 ; ^
  44. SAVE11 RMB 2
  45. *
  46. SAVE14 RMB 2 ; SPACE
  47. EXCL RMB 2 ; !
  48. QUOTE RMB 2 ; "
  49. DOLR RMB 2 ; #
  50. DOLLAR RMB 2 ; $
  51. REMN RMB 2 ; %
  52. AMPR RMB 2 ; &
  53. QUITE RMB 2 ; '
  54. PAREN RMB 2 ; (
  55. PARIN RMB 2 ; )
  56. STAR RMB 2 ; *
  57. PLUS RMB 2 ; +
  58. COMA RMB 2 ; ,
  59. MINS RMB 2 ; -
  60. PERD RMB 2 ; .
  61. SLASH RMB 2 ; /
  62. *
  63. SAVE0 RMB 2
  64. SAVE1 RMB 2
  65. SAVE2 RMB 2
  66. SAVE3 RMB 2
  67. SAVE4 RMB 2
  68. SAVE5 RMB 2
  69. SAVE6 RMB 2
  70. SAVE7 RMB 2
  71. SAVE8 RMB 2
  72. SAVE9 RMB 2
  73. COLN RMB 2 ; :
  74. SEMI RMB 2 ; ;
  75. LESS RMB 2 ; <
  76. EQAL RMB 2 ; =
  77. GRRT RMB 1 ; >
  78. DECB_1 RMB 1
  79. *
  80. DECBUF RMB 4
  81. * SAVOFF RMB 2 ; This is the only place I dare put this yet.
  82. LASTD RMB 1
  83. DELIM RMB 1
  84. LINLEN EQU 72
  85. LINBUF RMB LINLEN+1
  86. BUFOFF EQU LINBUF-ZERO ; Unmagic 87. Some assemblers will cough at this.
  87. *
  88. ORG $02F1
  89. STACK RMB 1
  90. *
  91. ORG $0300
  92. MI RMB 4 ; INTERUPT VECTORS
  93. NMI RMB 4
  94. PRGM EQU * ; PROGRAM STARTS HERE
  95. * Must have some RAM here.
  96. *
  97. ORG $7800
  98. *
  99. * The COLD boot can be removed or ignored to restore the original behavior,
  100. * but if you do that don't forget to set & (AMPR) and * (STAR) values
  101. * by hand immediately after STARTing.
  102. *
  103. * Also, instead of PROBEing, if you know the limits for a particular ROM
  104. * application, you can set STAR directly:
  105. * LDX #PRGM
  106. * STX AMPR
  107. * LDX #RAMLIM
  108. * STX STAR
  109. * START ...
  110. *
  111. COLD LDS #STACK ; S on 6800 is first free byte on stack.
  112. JSR TRMINI
  113. LDX #PRGM ; initialize program area base
  114. STX AMPR
  115. LDAA #$5A ; Probe RAM limit
  116. LDAB #$A5
  117. BRA PROBET
  118. PROBE STAA 0,X
  119. CMPA 0,X
  120. BNE NOTRAM
  121. STAB 0,X
  122. CMPB 0,X
  123. BNE NOTRAM
  124. INX ; all bits seem to be R/W.
  125. PROBET CPX #COLD
  126. BNE PROBE ; CPX on 6800 doesn't do less/greater very well.
  127. NOTRAM DEX
  128. STX STAR
  129. START LDS #STACK ; re-initialize at beginning of each evaluate
  130. CLRA ; delimiter
  131. LDX #OKM
  132. BSR STRGT
  133. *
  134. LOOP CLRA
  135. STAA DOLR
  136. STAA DOLR+1
  137. JSR CVTLN
  138. BCC STMNT ; NO LINE# THEN EXEC
  139. BSR EXEC
  140. BEQ START
  141. *
  142. LOOP2 BSR FIND ; FIND LINE
  143. EQSTRT BEQ START ; IF END THEN STOP
  144. LDX 0,X ; LOAD REAL LINE #
  145. STX DOLR ; SAVE IT
  146. LDX SAVE11 ; GET LINE
  147. INX ; BUMP PAST LINE #
  148. INX ; BUMP PAST LINE #
  149. INX ; BUMP PAST SPACE
  150. BSR EXEC ; EXECUTE IT
  151. BEQ LOOP3 ; IF ZERO, CONTINUE
  152. LDX SAVE11 ; FIND LINE
  153. LDX 0,X ; GET IT
  154. CPX DOLR ; HAS IT CHANGED?
  155. BEQ LOOP3 ; IF NOT GET NEXT
  156. *
  157. INX ; INCREMENT OLD LINE#
  158. STX EXCL ; SAVE FOR RETURN
  159. BRA LOOP2 ; CONTINUE
  160. *
  161. LOOP3 BSR FND3 ; FIND NEXT LINE
  162. BRA EQSTRT ; CONTINUE
  163. *
  164. EXEC STX SAVE7 ; EXECUTE LINE
  165. JSR VAR2
  166. INX
  167. *
  168. SKIP LDAA 0,X ; GET FIRST TERM
  169. BSR EVIL ; EVALUATE EXPRESSION
  170. OUTX LDX DOLR ; GET LINE #
  171. RTS
  172. *
  173. EVIL CMPA #$22 ; IF " THEN BRANCH
  174. BNE EVALU
  175. INX
  176. STRGT JMP STRING ; TO PRINT IT
  177. *
  178. STMNT STX SAVE8 ; SAVE LINE #
  179. STAA DOLR
  180. STAB DOLR+1
  181. LDX DOLR
  182. BNE SKP2 ; IF LINE# <> 0
  183. *
  184. LDX #PRGM ; LIST PROGRAM
  185. LST2 CPX AMPR ; END OF PROGRAM
  186. BEQ EQSTRT
  187. STX SAVE11 ; LINE # FOR CVDEC
  188. LDAA 0,X
  189. LDAB 1,X
  190. JSR PRNT2
  191. LDX SAVE11
  192. INX
  193. INX
  194. JSR PNTMSG
  195. JSR CRLF
  196. BRA LST2
  197. *
  198. NXTXT LDX SAVE11 ; GET POINTER
  199. INX ; BUMP PAST LINE#
  200. LOOKAG INX ; FIND END OF LINE
  201. TST 0,X
  202. BNE LOOKAG
  203. INX
  204. RTS
  205. *
  206. FIND LDX #PRGM ; FIND LINE
  207. FND2 STX SAVE11
  208. CPX AMPR
  209. BEQ RTS1
  210. LDAA 1,X
  211. SUBA DOLR+1
  212. LDAA 0,X
  213. SBCA DOLR
  214. BCC SET
  215. FND3 BSR NXTXT
  216. BRA FND2
  217. *
  218. SET LDAA #$FF ; SET NOT EQUAL
  219. RTS1 RTS
  220. *
  221. EVALU JSR EVAL ; EVALUATE LINE
  222. PSHB
  223. PSHA
  224. LDX SAVE7
  225. JSR CONVP
  226. PULA
  227. CMPB #'$ ; STRING?
  228. BNE AR1
  229. PULB
  230. JMP OUTCH ; THEN PRINT IT
  231. AR1 SUBB #'? ; PRINT?
  232. BNE AR11
  233. JMP PRNT ; THEN DO IT
  234. AR11 INCB ; MACHINE LANGUAGE?
  235. PULB
  236. BNE AR2
  237. SWI ; THEN INTERUPT
  238. *
  239. AR2 STAA 0,X ; STORE NEW VALUE
  240. STAB 1,X
  241. ADDB QUITE ; RANDOMIZER
  242. ADCA QUITE+1
  243. STAA QUITE
  244. STAB QUITE+1
  245. RTS
  246. *
  247. SKP2 BSR FIND ; FIND LINE
  248. BEQ INSRT ; IF NOT THERE
  249. LDX 0,X ; THEN INSERT
  250. CPX DOLR ; NEW LINE
  251. BNE INSRT
  252. *
  253. BSR NXTXT ; SETUP REGISTERS
  254. LDS SAVE11 ; FOR DELETE
  255. *
  256. DELT CPX AMPR ; DELETE OLD LINE
  257. BEQ FITIT
  258. LDAA 0,X
  259. PSHA
  260. INX
  261. INS
  262. INS
  263. BRA DELT
  264. *
  265. FITIT STS AMPR ; STORE NEW END
  266. *
  267. INSRT LDX SAVE8 ; COUNT NEW LINE LENGTH
  268. LDAB #$03
  269. TST 0,X
  270. BEQ GOTIT ; IF NO LINE THEN STOP
  271. CNTLN INCB
  272. INX
  273. TST 0,X
  274. BNE CNTLN
  275. *
  276. OPEN CLRA ; CALCULATE NEW END
  277. ADDB AMPR+1
  278. ADCA AMPR
  279. STAA SAVE10
  280. STAB SAVE10+1
  281. SUBB STAR+1
  282. SBCA STAR
  283. BCC RSTRT ; IF TOO BIG THEN STOP
  284. LDX AMPR
  285. LDS SAVE10
  286. STS AMPR
  287. *
  288. INX ; SLIDE OPEN GAP
  289. SLIDE DEX
  290. LDAB 0,X
  291. PSHB
  292. CPX SAVE11
  293. BNE SLIDE
  294. *
  295. DON LDS DOLR ; STORE LINE #
  296. STS 0,X
  297. LDS SAVE8 ; GET NEW LINE
  298. DES
  299. *
  300. MOVL INX ; INSERT NEW LINE
  301. PULB
  302. STAB 1,X
  303. BNE MOVL
  304. *
  305. GOTIT LDS #STACK
  306. JMP LOOP
  307. *
  308. RSTRT JMP START
  309. *
  310. PRNT PULB ; PRINT DECIMAL
  311. PRNT2 LDX #DECBUF ; CONVERT TO DECIMAL
  312. STX SAVE4
  313. LDX #PWRS10
  314. CVD1 STX SAVE5
  315. LDX 0,X
  316. STX SAVE6
  317. LDX #SAVE6
  318. JSR DIVIDE
  319. PSHA
  320. LDX SAVE4
  321. LDAA SAVE2+1
  322. ADDA #'0
  323. STAA 0,X
  324. INX
  325. STX SAVE4
  326. LDX SAVE5
  327. PULA
  328. INX
  329. INX
  330. TST 1,X
  331. BNE CVD1
  332. *
  333. LDX #DECB_1
  334. COM 5,X ; ZERO SUPPRESS
  335. ZRSUP INX
  336. LDAB 0,X
  337. CMPB #'0
  338. BEQ ZRSUP
  339. COM LASTD
  340. *
  341. PNTMSG CLRA ; ZERO FOR DELIM
  342. STRTMS STAA DELIM ; STORE DELIMTER
  343. *
  344. OUTMSG LDAB 0,X ; GENERAL PURPOSE PRINT
  345. INX
  346. CMPB DELIM
  347. BEQ CTLC
  348. JSR OUTCH
  349. BRA OUTMSG
  350. *
  351. CTLC JSR POLCAT ; POL FOR CHARACTER
  352. BCC RTS2
  353. BSR INCH2
  354. CMPB #BREAK ; BREAK KEY?
  355. BEQ RSTRT
  356. *
  357. INCH2 JMP INCH
  358. *
  359. STRING BSR STRTMS ; PRINT STRING LITERAL
  360. LDAA 0,X
  361. CMPA #';
  362. BEQ OUTD
  363. JMP CRLF
  364. *
  365. EVAL BSR GETVAL ; EVALUATE EXPRESSION
  366. *
  367. NXTRM PSHA
  368. LDAA 0,X ; END OF LINE?
  369. BEQ OUTN
  370. CMPA #')
  371. OUTN PULA
  372. BEQ OUTD
  373. BSR TERM
  374. LDX SAVE0
  375. BRA NXTRM
  376. *
  377. TERM PSHA ; GET VALUE
  378. PSHB
  379. LDAA 0,X
  380. PSHA
  381. INX
  382. BSR GETVAL
  383. STAA SAVE3
  384. STAB SAVE3+1
  385. STX SAVE0
  386. LDX #SAVE3
  387. PULA
  388. PULB
  389. *
  390. CMPA #'* ; SEE IF *
  391. BNE EVAL2
  392. PULA ; MULTIPLY
  393. MULTIP STAA SAVE2
  394. STAB SAVE2+1 ; 2'S COMPLEMENT
  395. LDAB #$10
  396. STAB SAVE1
  397. CLRA
  398. CLRB
  399. *
  400. MULT LSR SAVE2
  401. ROR SAVE2+1
  402. BCC NOAD
  403. MULTI BSR ADD
  404. NOAD ASL 1,X
  405. ROL 0,X
  406. DEC SAVE1
  407. BNE MULT ; LOOP TIL DONE
  408. RTS2 RTS
  409. *
  410. GETVAL JSR CVBIN ; GET VALUE
  411. BCC OUTV
  412. CMPB #'? ; OF LITERAL
  413. BNE VAR
  414. STX SAVE9 ; OR INPUT
  415. JSR INLN
  416. BSR EVAL
  417. LDX SAVE9
  418. OUTD INX
  419. OUTV RTS
  420. *
  421. VAR CMPB #'$ ; OR STRING
  422. BNE VAR1
  423. BSR INCH2
  424. CLRA
  425. INX
  426. RTS
  427. *
  428. VAR1 CMPB #'(
  429. BNE VAR2
  430. INX
  431. BRA EVAL
  432. *
  433. VAR2 BSR CONVP ; OR VARIABLE
  434. LDAA 0,X ; OR ARRAY ELEMENT
  435. LDAB 1,X
  436. LDX SAVE6 ; LOAD OLD INDEX
  437. RTS
  438. *
  439. ARRAY JSR EVAL ; LOCATE ARRAY ELEMENT
  440. ASLB
  441. ROLA
  442. ADDB AMPR+1
  443. ADCA AMPR
  444. BRA PACK
  445. *
  446. CONVP LDAB 0,X ; GET LOCATION
  447. INX
  448. PSHB
  449. CMPB #':
  450. BEQ ARRAY ; OF VARIABLE OR
  451. CLRA ; ARRAY ELEMENT
  452. ANDB #$3F ; mask out-of-variable-range
  453. ADDB #$02 ; bump past "interrupt vectors"
  454. ASLB ; make into offset (would be address in DP)
  455. * Assemblers get funny about the syntax we need here.
  456. * I need to fix my assembler, too -- add some (now) standard syntax.
  457. * For now:
  458. * ADDB #(ZERO)MOD$100 ; ZERO must be on $100 boundary so we don't need this!
  459. * ADCA #ZERO/$100
  460. LDAA #ZERO/$100 ; override CLRA above. Some assemblers will cough here.
  461. *
  462. PACK STX SAVE6 ; STORE OLD INDEX
  463. STAA SAVE4
  464. STAB SAVE4+1
  465. LDX SAVE4 ; LOAD NEW INDEX
  466. PULB
  467. RTS
  468. *
  469. EVAL2 CMPA #'+ ; ADDITION
  470. BNE EVAL3
  471. PULA
  472. ADD ADDB 1,X
  473. ADCA 0,X
  474. RTS
  475. *
  476. EVAL3 CMPA #'- ; SUBTRACTION
  477. BNE EVAL4
  478. PULA
  479. SUBTR SUBB 1,X
  480. SBCA 0,X
  481. RTS
  482. *
  483. EVAL4 CMPA #'/ ; SEE IF IT'S DIVIDE
  484. BNE EVAL5
  485. PULA
  486. BSR DIVIDE
  487. STAA REMN
  488. STAB REMN+1
  489. LDAA SAVE2
  490. LDAB SAVE2+1
  491. RTS
  492. *
  493. EVAL5 SUBA #'= ; SEE IF EQUAL TEST
  494. BNE EVAL6
  495. PULA
  496. BSR SUBTR
  497. BNE NOTEQ
  498. TSTB
  499. BEQ EQL
  500. NOTEQ LDAB #$FF
  501. EQL BRA COMBOUT
  502. *
  503. EVAL6 DECA ; SEE IF LESS THAN TEST
  504. PULA
  505. BEQ EVAL7
  506. *
  507. SUB2 BSR SUBTR
  508. ROLB
  509. COMOUT CLRA
  510. ANDB #$01
  511. RTS
  512. *
  513. EVAL7 BSR SUB2 ; GT TEST
  514. COMBOUT COMB
  515. BRA COMOUT
  516. *
  517. PWRS10 FCB $27 ; 10000
  518. FCB $10
  519. FCB $03 ; 1000
  520. FCB $E8
  521. FCB $00 ; 100
  522. FCB $64
  523. FCB $00 ; 10
  524. FCB $0A
  525. FCB $00 ; 1
  526. FCB $01
  527. *
  528. DIVIDE CLR SAVE1 ; DEVIDE 16-BITS
  529. GOT INC SAVE1
  530. ASL 1,X
  531. ROL 0,X
  532. BCC GOT
  533. ROR 0,X
  534. ROR 1,X
  535. CLR SAVE2
  536. CLR SAVE2+1
  537. DIV2 BSR SUBTR
  538. BCC OK
  539. BSR ADD
  540. CLC
  541. FCB $9C ; WHAT? (Waste CPX <$0D to skip SEC.)
  542. OK SEC ; $0D
  543. ROL SAVE2+1
  544. ROL SAVE2
  545. DEC SAVE1
  546. BEQ DONE
  547. LSR 0,X
  548. ROR 1,X
  549. BRA DIV2
  550. *
  551. TSTN LDAB 0,X ; TEST FOR NUMERIC
  552. CMPB #$3A
  553. BPL NOTDEC
  554. CMPB #'0
  555. BGE DONE
  556. NOTDEC SEC
  557. RTS
  558. DONE CLC
  559. DUN RTS
  560. *
  561. CVTLN BSR INLN
  562. *
  563. CVBIN BSR TSTN ; CONVERT TO BINARY
  564. BCS DUN
  565. CONT CLRA
  566. CLRB
  567. CBLOOP ADDB 0,X
  568. ADCA #$00
  569. SUBB #'0
  570. SBCA #$00
  571. STAA SAVE1
  572. STAB SAVE1+1
  573. INX
  574. PSHB
  575. BSR TSTN
  576. PULB
  577. BCS DONE
  578. ASLB
  579. ROLA
  580. ASLB
  581. ROLA
  582. ADDB SAVE1+1
  583. ADCA SAVE1
  584. ASLB
  585. ROLA
  586. BRA CBLOOP
  587. *
  588. INLN6 CMPB #'@ ; CANCEL
  589. BEQ NEWLIN
  590. INX ; '.'
  591. CPX #ZERO+LINLEN+2 ; (Here's part of what we had to fix for moving the variables.)
  592. BNE INLN2
  593. NEWLIN BSR CRLF
  594. *
  595. INLN LDX #ZERO+2 ; INPUT LINE FROM TERMINAL
  596. INLN5 DEX
  597. CPX #ZERO ; Make this explicit to enable variables moved out of DP.
  598. BEQ NEWLIN ; (Was implicit zero compare X from DEX, now explicit.)
  599. INLN2 JSR INCH ; INPUT CHARACTER
  600. STAB BUFOFF-1,X ; STORE IT
  601. CMPB #$5F ; BACKSPACE?
  602. BEQ INLN5
  603. *
  604. INLIN3 CMPB #$0D ; CARRIAGE RETURN
  605. BMI INLN2
  606. BNE INLN6
  607. *
  608. INLIN4 CLR BUFOFF-1,X ; CLEAR LAST CHAR
  609. LDX #LINBUF
  610. BRA LF
  611. *
  612. * CRLF JSR EPCRLF
  613. CRLF LDAB #$0D ; CARR-RET
  614. BSR OUTCH2
  615. LF LDAB #$0A ; LINE FEED
  616. OUTCH2 JMP OUTCH
  617. *
  618. OKM FCB $0D
  619. FCB $0A
  620. FCC 'OK'
  621. FCB $00
  622. *
  623. TRMINI LDAB #40
  624. TRMILP JSR EPCRLF
  625. DECB
  626. BNE TRMILP
  627. RTS
  628. *
  629. * RECEIVER POLLING
  630. POLCAT LDAB ACIACS
  631. ASRB
  632. RTS
  633. *
  634. * INPUT ONE CHAR INTO B ACCUMULATOR
  635. INCH PSHA
  636. JSR EINCH
  637. TAB
  638. PULA
  639. RTS
  640. *
  641. * OUTPUT ONE CHAR
  642. OUTCH PSHA
  643. TBA
  644. JSR EOUTCH
  645. PULA
  646. RTS
  647. *
  648. ORG COLD
  649. *
  650. END
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト