Source for VTL-2 that has semicolons added for leader characters for comments, to be compatible with my asm68c assembler and other assemblers that allow whitespace in operand expressions

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

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト