Source code that runs VTL-2 in Joe H. Allen's EXORsim, and should run it in the EXORciser. Can be assembled with my asm68c. Be sure, after you get it running, to set the & and * variables appropriately -- something like &=300 and *=8192.

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

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト