• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Deriving a new dialect of Very Tiny Language from VTL-2 6800 version


Commit MetaInfo

Revisionb8e195c4ec493b879649ac61a6026c666d1fb784 (tree)
Time2022-09-25 22:00:21
AuthorJoel Matthew Rees <joel.rees@gmai...>
CommiterJoel Matthew Rees

Log Message

starting on better 6809/coco version

Change Summary

Incremental Difference

--- a/VTL_6809_coco.asm
+++ b/VTL_6809_coco.asm
@@ -1,130 +1,111 @@
1-* VTL-2 for 6809
2-* derived from VTL-2 for 6801
1+ OPT 6809
2+* VTL-2 for 6809
3+* A transliteration of VTL-2 for 6801
34 * V-3.6
45 * 9-23-76
56 * BY GARY SHANNON
67 * & FRANK MCCOY
78 * COPYWRIGHT 1976, THE COMPUTER STORE
89 *
9-* Transliterations and modifications
10+* Transliteration and modifications for Color Computer
11+* including original modifications for MC-10
1012 * by Joel Matthew Rees
1113 * Copyright 2022, Joel Matthew Rees
1214 *
1315 * Modifications explained at
14-* (URL)
16+* https://joels-programming-fun.blogspot.com/2022/09/vtl-2-part-5-transliterating-to-6809.html
17+*
18+* Note that this is a travesty of a program,
19+* since it is 6809 code, but does not make any use of the 6809's added resources.
20+*
1521 *
1622 * DEFINE LOCATIONS IN MONITOR
17-* These are defined for the Color Computer target at the end of the source.
1823 * INCH EQU $FF00 ; per VTL.ASM
24+* EINCH EQU $F012 ; exorsim mdos Input byte with echo unless AECHO is set
25+* INCH EQU $F015 ; exorsim mdos Input char with echo (F012 -> strip bit 7)
1926 * POLCAT EQU $FF24 ; from VTL.ASM
2027 * OUTCH EQU $FF81 ; from VTL.ASM
28+* EOUTCH EQU $F018 ; exorsim mdos Output character with NULs
2129 * OUTS EQU $FF82 ; from VTL.ASM
30+* EPCRLF EQU $F021 ; Primarily for forced initialization in exorsim.
2231 *
2332 * FOR SBC6800:
2433 *BREAK EQU $1B ; BREAK KEY
25-* For MC-10:
34+* For MC-10 and Color Computer:
2635 BREAK EQU $03
27-*
28-* In the 6809, there are several ways to approach the VTL trick of
29-* aliasing the variable names to their ASCII codes as addresses
30-*
31-* A way that would completely ignore the features (and benefits) of the 6809
32-* might be to just follow the original VTL-2 source in putting the variables all
33-* down at the bottom of the address space (and setting the DP register register to zero).
34-* This approach would conflict with some hardware and a lot of system software.
35-*
36-* A similar method would be to use the DP as the base of the variable area.
37-* In some ways, this would allow a greater flexibility, although I understand
38-* you would still find conflicts. It would also require a bit of glue code,
39-* since Motorola did not mirror the direct page mode in the index modes.
40-* And there would be system conflicts in system/BIOS/monitors that
41-* don't save and switch DP on interrupts.
42-*
43-* A third way would be similar to what I did to move the variables
44-* out of the direct page on the 6800 source --
45-* the variables would still be at absolute addresses, but by keeping those addresses
46-* free from entanglement with the code there would give greater host flexibility.
47-*
48-* A fourth approach would be to use the Y or U register as the base of the variable space.
49-* The base itself could be kept in a direct page variable, allowing the index to be used
50-* for other things, as well.
51-* (A similar approach could be taken with the 6801, with a lot of shuffling X.
52-* Because the 6809 has several index regisers, shuffling is not so much of a problem here.)
53-*
54-* If Motorola had only mirrored the DP mode in the index modes (like they mirrored the
55-* extended mode to get absolute memory indirect), the DP would be the slam-dunk.
56-* (But Microsoft would have ignored the DP register anyway, making for conflicts with BASIC.)
57-*
58-* I'm inclined to use the DP as the base, just to show how to do it.
59-* But I know there will be a lot of designs where that will cause problems,
60-* particularly the Tandy/RS Color Computer, the most available target I have at present.
61-*
62-* So I'm going to go with using Y as the base, which means saving and restoring it
63-* when I use it for something else.
64-*
65-* Some of the interpreter variables belong conceptually in the direct page,
66-* but I'm going to essentially ignore the direct page in this transliteration,
67-* so I'll move the interpreter variables back to mixed in with the programmer variables.
68-*
69-* ORG $C0 ; Move this according to your environment's needs.
70-* DPBASE EQU $C0 ; Change this to move the registers.
36+* For exorsim
37+*ACIACS EQU $FCF4 ; exorcisor
38+*ACIADA EQU $FCF5 ; exorcisor
39+*
40+* A few interpreter variables in the direct page won't hurt, said the spider to the fly.
41+* (See SNDDUR and PLYTMR in particular.)
42+* (Really need to move these. Use DP after all? IRQ, at least, uses extended mode addressing.)
43+* (Yes, I can hear voices of complaint that it's not as "tight" as it could be.)
44+* (This allows us to save more ROM space and uses DP that would otherwise go wasted.)
45+* (Trade-offs.)
46+* (It also helps us understand the code, so we can do a better 6809 transliteration.)
47+* (I hope the names are meaningful.)
48+*
49+* In .c10 format, the following as ORG and RMBs caused object code output,
50+* which will prevent the code from loading on the MC-10.
51+* Changed to EQU for the MC10 and left this way for the initial CoCo code.
52+*
53+* Does not really make specific use of the DP register.
54+* ORG $C0 ; Move this according to your environment's needs, but not on CoCo.
55+* Change this to move the registers:
56+DPBASE EQU $C4 ; PIA mask at $C2? Avoid it, anyway.
7157 * PARSET RMB 2 ; Instead of SAVE0 in TERM/NXTRM
72-* PARSET EQU DPBASE+2
58+PARSET EQU DPBASE+2
7359 * CVTSUM RMB 2 ; Instead of SAVE1 in CBLOOP
74-* CVTSUM EQU PARSET+2
60+CVTSUM EQU PARSET+2
7561 * MLDVCT EQU CVTSUM ; Instead of SAVE1 in mul/div (1 byte only)
76-* MLDVCT EQU CVTSUM
62+MLDVCT EQU CVTSUM
7763 * DIVQUO RMB 2 ; Instead of SAVE2 in DIV
78-* DIVQUO EQU MLDVCT+2
64+DIVQUO EQU MLDVCT+2
7965 * MPLIER EQU DIVQUO ; Instead of SAVE2 in MULTIP
80-* MPLIER EQU DIVQUO
66+MPLIER EQU DIVQUO
8167 * EVALPT RMB 2 ; Instead of SAVE3
82-* EVALPT EQU MPLIER+2
68+EVALPT EQU MPLIER+2
8369 * CNVPTR RMB 2 ; Instead of SAVE4
84-* CNVPTR EQU EVALPT+2
70+CNVPTR EQU EVALPT+2
8571 * VARADR RMB 2 ; Instead of SAVE6
86-* VARADR EQU CNVPTR+2
72+VARADR EQU CNVPTR+2
8773 * OPRLIN RMB 2 ; Instead of SAVE7
88-* OPRLIN EQU VARADR+2
74+OPRLIN EQU VARADR+2
8975 * EDTLIN RMB 2 ; Instead of SAVE8
90-* EDTLIN EQU OPRLIN+2
76+EDTLIN EQU OPRLIN+2
9177 * INSPTR RMB 2 ; Instead of SAVE10 (maybe? Will some VTL programs want it back?)
92-* INSPTR EQU EDTLIN+2
78+INSPTR EQU EDTLIN+2
9379 * SAVLIN RMB 2 ; Instead of SAVE11
94-* SAVLIN EQU INSPTR+2
95-* SRC RMB 2 ; For copy routine, register in 6809
96-* SRC EQU SAVLIN+2
80+SAVLIN EQU INSPTR+2
81+* SRC RMB 2 ; For copy routine
82+SRC EQU SAVLIN+2
9783 * DST RMB 2 ; ditto
98-* DST EQU SRC+2
99- SETDP 0
100-* Just these DP variables:
101-* STKMRK EQU DST+2
102-USTKMK EQU $F8 ; to restore the stack on each pass.
103-SSTKMK EQU USTKMK+2
104-ZEROMK EQU SSTKMK+2
105-
106-* DPALLOC EQU STKMRK+2 ; total storage declared in the direct page
84+DST EQU SRC+2
85+STKMRK EQU DST+2 ; to restore the stack on each pass.
86+DPALLOC EQU STKMRK+2 ; total storage declared in the direct page
10787 *
88+*******!!!!!! CoCo: Check that we have avoided $00E2, as well, since it is used as PLYTMR by an interrupt routine.
89+* CoCo: Also, $008D is used as SNDDUR by BASIC.
10890 *
10991 * SET ASIDE FOUR BYTES FOR USER
110-* DEFINED INTERUPT ROUTINE IF NEEDED (not needed, but ...)
111- ORG $1600 ; Dodge BASIC and video use RAM.
112-* ZERO probably should be set at even $100 boundary for address math to work.
113-ZERO RMB 4 ; INTERUPT VECTOR in original
92+* DEFINED INTERUPT ROUTINE IF NEEDED
93+ZERO EQU $1600 ; Dodge BASIC and video use RAM.
94+ ORG ZERO
95+* ZERO probably no longer needs to be at even $100, but we'll put it there for good luck.
96+ RMB 4 ; INTERUPT VECTOR (probably not unnecessary? Implicit non-use in interpreter.)
11497 AT RMB 2 ; CANCEL & C-R
11598 *
11699 * GENERAL PURPOSE STORRGE
117100 VARS RMB 52 ; VARIABLES(A-Z)
118101 BRAK RMB 2 ; [
119-* SAVE10 has me worried about implicit linkage in VTL programs. Might need to just be here.
102+* SAVE10 has me worried about implicit linkage in VTL programs. Might need to leave it here.
120103 SAVE10 RMB 2 ; BACK SLASH
121-INSPTR EQU SAVE10 ; (Will some VTL programs want it here regardless?)
122104 BRIK RMB 2 ; ]
123105 UP RMB 2 ; ^
124106 SAVE11 RMB 2 ; Need something in each SAVE to reserve space
125-SAVLIN EQU SAVE11
126-* ; To keep the address math straight.
127-* ; always leave the SAVEs declared as they are.
107+* ; to keep the math straight.
108+* ; Leave the SAVEs declared as they are.
128109 *
129110 SAVE14 RMB 2 ; SPACE (originally unused)
130111 EXCL RMB 2 ; !
@@ -143,26 +124,16 @@ MINS RMB 2 ; -
143124 PERD RMB 2 ; .
144125 SLASH RMB 2 ; /
145126 *
146-SAVE0 RMB 2
147-PARSET EQU SAVE0 ; in TERM/NXTRM
148-SAVE1 RMB 2
149-CVTSUM EQU SAVE1 ; in CBLOOP
150-MLDVCT EQU CVTSUM ; in mul/div (1 byte only)
151-SAVE2 RMB 2
152-DIVQUO EQU SAVE2 ; in DIV
153-MPLIER EQU DIVQUO ; in MULTIP
154-SAVE3 RMB 2
155-EVALPT EQU SAVE3
156-SAVE4 RMB 2
157-CNVPTR EQU SAVE4
158-SAVE5 RMB 2 ; unused (stacked)
159-SAVE6 RMB 2
160-VARADR EQU SAVE6
161-SAVE7 RMB 2
162-OPRLIN EQU SAVE7
163-SAVE8 RMB 2
164-EDTLIN EQU SAVE8
165-SAVE9 RMB 2 ; unused (stacked)
127+SAVE0 RMB 2 ; unused
128+SAVE1 RMB 2 ; unused
129+SAVE2 RMB 2 ; unused
130+SAVE3 RMB 2 ; unused
131+SAVE4 RMB 2 ; unused
132+SAVE5 RMB 2 ; unused (PSH/PULX)
133+SAVE6 RMB 2 ; unused
134+SAVE7 RMB 2 ; unused
135+SAVE8 RMB 2 ; unused
136+SAVE9 RMB 2 ; unused (PSH/PULX)
166137 COLN RMB 2 ; :
167138 SEMI RMB 2 ; ;
168139 LESS RMB 2 ; <
@@ -177,67 +148,63 @@ LINLEN EQU 72
177148 LINBUF RMB LINLEN+1
178149 BUFOFF EQU LINBUF-ZERO ; Unmagic 87. Some assemblers will cough at this.
179150 *
180- ORG $16F0 ; parameter/temp stack below here
181-USTACK RMB 1
151+STACK EQU ZERO+$F0
152+ ORG STACK
153+ RMB 1 ; 6809 stack pointer points to last item pushed.
182154 *
183- ORG $1700 ; leave some buffer space
184-MI RMB 4 ; INTERUPT VECTORS (not for 6809)
155+VPRGM EQU STACK+$10 ; buffer zone, really
156+ ORG VPRGM
157+MI RMB 4 ; INTERUPT VECTORS ; again, probably not relevant here.
185158 NMI RMB 4
186-PRGM EQU * ; VTL PROGRAM STARTS HERE
159+PRGM EQU * ; PROGRAM STARTS HERE
187160 * Must have some RAM here.
188161 *
189- ORG $4000 ; for 16K system
162+CODESG EQU $3800 ; 16K-2K for breathing room in 16K system (2K for now, adjust later.)
163+ ORG CODESG
190164 *
191165 * The COLD boot can be removed or ignored to restore the original behavior,
192166 * but if you do that don't forget to set & (AMPR) and * (STAR) values
193-* by hand immediately after STARTing,
194-* and ' (QUITE) before trying to get a pseudo-random number.
167+* by hand immediately after STARTing.
195168 *
196169 * Also, instead of PROBEing, if you know the limits for a particular ROM
197-* application, you can set STAR directly, too:
170+* application, you can set STAR directly:
198171 * LDX #PRGM
199172 * STX AMPR
200173 * LDX #RAMLIM
201174 * STX STAR
202175 * START ...
203176 *
204-COLD STS SSTKMK ; Mark the stacks,
205- STU USTKMK ; but use BASIC's return stack.
206-* LDS #SSTACK ; (S/U on 6809 point to most recently pushed.)
207- LDU #USTACK
177+COLD STS STKMRK ; Mark the stack,
178+* LDS #STACK ; Maybe use BASIC's stack. (S on 6809 points to last pushed.)
208179 * JSR TRMINI
209- LEAX COLD,PCR
210- PSHU X ; probe termination address
211- LDY #ZERO
212- STY ZEROMK
213- LDD #PRGM-ZERO ; initialize program area base
214- STD AMPR,Y
215- LEAX D,Y
180+ LDX #PRGM ; initialize program area base
181+ STX AMPR
216182 LDA #$5A ; Probe RAM limit
217183 LDB #$A5
218184 BRA PROBET
219-PROBE STA ,X
220- CMPA ,X
185+PROBE STA 0,X
186+ CMPA 0,X
221187 BNE NOTRAM
222- STB ,X
223- CMPB ,X+
224- BNE NOTRAM
225-PROBET CMPX ,U ; all bits seem to be R/W.
188+ STB 0,X
189+ CMPB 0,X
190+ BNE NOTRAM ; all bits seem to be R/W.
191+ LEAX 1,X
192+PROBET CMPX #COLD
226193 BLO PROBE ; CMPX on 6809 works right.
227194 NOTRAM LEAX -1,X
228195 STX STAR
229196 START
230- LDS SSTKMK ; re-initialize at beginning of each evaluate
231- LDU USTKMK ; from mark instead of constant
197+* LDS #STACK ; re-initialize at beginning of each evaluate
198+ LDS STKMRK ; from mark instead of constant
232199 STS SEMI ; DBG Comment this out when we no longer need to see the stack pointer BASIC gives us.
233200 CLRA ; NUL delimiter
234- LEAX OKM,PCR
235- BSR STRGT
201+ LDX #OKM
202+ LBSR STRING
236203 *
237204 LOOP CLRA
238- STAA DOLR
239- STAA DOLR+1
240- JSR CVTLN
205+ STA DOLR
206+ STA DOLR+1
207+ LBSR CVTLN
241208 BCC STMNT ; NO LINE# THEN EXEC
242209 BSR EXEC
243210 BEQ START
@@ -247,17 +214,15 @@ EQSTRT BEQ START ; IF END THEN STOP
247214 LDX 0,X ; LOAD REAL LINE #
248215 STX DOLR ; SAVE IT
249216 LDX SAVLIN ; GET LINE
250- INX ; BUMP PAST LINE #
251- INX ; BUMP PAST LINE #
252- INX ; BUMP PAST SPACE
217+ LEAX 3,X ; BUMP PAST LINE # and SPACE
253218 BSR EXEC ; EXECUTE IT
254219 BEQ LOOP3 ; IF ZERO, CONTINUE
255- LDX SAVLIN ; FIND LINE
256- LDX 0,X ; GET IT
257- CPX DOLR ; HAS IT CHANGED?
220+ LDX [SAVLIN] ; FIND LINE
221+* LDX 0,X ; GET IT
222+ CMPX DOLR ; HAS IT CHANGED?
258223 BEQ LOOP3 ; IF NOT GET NEXT
259224 *
260- INX ; INCREMENT OLD LINE#
225+ LEAX 1,X ; INCREMENT OLD LINE#
261226 STX EXCL ; SAVE FOR RETURN
262227 BRA LOOP2 ; CONTINUE
263228 *
@@ -265,18 +230,18 @@ LOOP3 BSR FND3 ; FIND NEXT LINE
265230 BRA EQSTRT ; CONTINUE
266231 *
267232 EXEC STX OPRLIN ; EXECUTE LINE
268- JSR VAR2
269- INX
233+ LBSR VAR2
234+ LEAX 1,X
270235 *
271-SKIP LDAA 0,X ; GET FIRST TERM
236+SKIP LDA 0,X ; GET FIRST TERM
272237 BSR EVIL ; EVALUATE EXPRESSION
273238 OUTX LDX DOLR ; GET LINE #
274239 RTS
275240 *
276241 EVIL CMPA #$22 ; IF " THEN BRANCH
277242 BNE EVALU
278- INX
279-STRGT JMP STRING ; TO PRINT IT
243+ LEAX 1,X
244+STRGT LBRA STRING ; TO PRINT IT
280245 *
281246 STMNT STX EDTLIN ; SAVE LINE #
282247 STD DOLR
@@ -284,63 +249,60 @@ STMNT STX EDTLIN ; SAVE LINE #
284249 BNE SKP2 ; IF LINE# <> 0
285250 *
286251 LDX #PRGM ; LIST PROGRAM
287-LST2 CPX AMPR ; END OF PROGRAM
252+LST2 CMPX AMPR ; END OF PROGRAM
288253 BEQ EQSTRT
289254 STX SAVLIN ; LINE # FOR CVDEC
290255 LDD 0,X
291- JSR PRNT2
256+ LBSR PRNT2
292257 LDX SAVLIN
293- INX
294- INX
295- JSR PNTMSG
296- JSR CRLF
258+ LEAX 2,X
259+ LBSR PNTMSG
260+ LBSR CRLF
297261 BRA LST2
298262 *
299263 NXTXT LDX SAVLIN ; GET POINTER
300- INX ; BUMP PAST LINE#
301-LOOKAG INX ; FIND END OF LINE
264+ LEAX 1,X ; BUMP PAST LINE#
265+LOOKAG LEAX 1,X ; FIND END OF LINE
302266 TST 0,X
303267 BNE LOOKAG
304- INX
268+ LEAX 1,X
305269 RTS
306270 *
307271 FIND LDX #PRGM ; FIND LINE
308272 FND2 STX SAVLIN
309- CPX AMPR
273+ CMPX AMPR
310274 BEQ RTS1
311-* LDAA 1,X ; almost missed this.
275+* LDA 1,X ; almost missed this.
312276 * SUBA DOLR+1 ; This was necessary because no SUBD
313-* LDAA 0,X ; and CPX does not affect C flag on 6800
277+* LDA 0,X ; and CPX does not affect C flag on 6800
314278 * SBCA DOLR
315-* PSHB ; B does not seem to be in use.
279+* PSHS B ; B does not seem to be in use.
316280 LDD 0,X ; Use D because we think we want to keep X.
317281 SUBD DOLR
318-* PULB
282+* PULS B
319283 BCC SET
320284 FND3 BSR NXTXT
321285 BRA FND2
322286 *
323-SET LDAA #$FF ; SET NOT EQUAL
324-RTS1 RTS
287+SET LDA #$FF ; SET NOT EQUAL
288+RTS1
289+ RTS
325290 *
326-EVALU JSR EVAL ; EVALUATE LINE
327- PSHB
328- PSHA
291+EVALU LBSR EVAL ; EVALUATE LINE
292+ PSHS A,B ; A is pushed after B
329293 LDX OPRLIN
330- JSR CONVP
331- PULA
294+ LBSR CONVP
295+ PULS A
332296 CMPB #'$ ; STRING?
333297 BNE AR1
334- PULB
335- JMP OUTCH ; THEN PRINT IT
298+ PULS B
299+ LBRA OUTCH ; THEN PRINT IT
336300 AR1 SUBB #'? ; PRINT?
337- BNE AR11 ; was out of range.
338- JMP PRNT ; THEN DO IT
339-* BEQ PRNT ; When we bring it back within range.
301+ LBEQ PRNT
340302 AR11 INCB ; MACHINE LANGUAGE?
341- PULB
303+ PULS B
342304 BNE AR2
343- SWI ; THEN INTERUPT
305+ SWI ; THEN INTERUPT (Need to fix this for CoCo -- and for MC-10.)
344306 *
345307 AR2 STD 0,X ; STORE NEW VALUE
346308 BNE AR2RND ; Initialize/don't get stuck on zero.
@@ -351,31 +313,30 @@ AR2RND ADDB QUITE ; RANDOMIZER ; Adding the low byte to the high byte
351313 STD QUITE
352314 RTS
353315 *
354-SKP2 BSR FIND ; FIND LINE
316+SKP2
317+ BSR FIND ; FIND LINE
355318 BEQ INSRT ; IF NOT THERE
356319 LDX 0,X ; THEN INSERT
357- CPX DOLR ; NEW LINE
320+ CMPX DOLR ; NEW LINE
358321 BNE INSRT
359322 *
360323 BSR NXTXT ; SETUP REGISTERS
361324 * LDS SAVLIN ; FOR DELETE
362- STX SRC
325+ STX SRC ; Patience! we can use Y here after we make sure this runs.
363326 LDX SAVLIN
364327 STX DST
365328 *
366329 DELT LDX SRC
367- CPX AMPR ; DELETE OLD LINE
330+ CMPX AMPR ; DELETE OLD LINE
368331 BEQ FITIT
369- LDAA 0,X
370- INX
332+ LDA ,X+
371333 STX SRC
372334 * PSHA
373335 * INX
374336 * INS
375337 * INS
376338 LDX DST
377- STA 0,X
378- INX
339+ STA ,X+
379340 STX DST
380341 BRA DELT
381342 *
@@ -383,12 +344,13 @@ DELT LDX SRC
383344 FITIT LDX DST
384345 STX AMPR ; STORE NEW END
385346 *
386-INSRT LDX EDTLIN ; COUNT NEW LINE LENGTH
387- LDAB #$03
347+INSRT
348+ LDX EDTLIN ; COUNT NEW LINE LENGTH
349+ LDB #$03
388350 TST 0,X
389351 BEQ GOTIT ; IF NO LINE THEN STOP
390352 CNTLN INCB ; count bytes
391- INX
353+ LEAX 1,X
392354 TST 0,X ; Find trailing NUL
393355 BNE CNTLN
394356 *
@@ -396,33 +358,32 @@ OPEN CLRA ; CALCULATE NEW END
396358 ADDD AMPR
397359 STD INSPTR
398360 SUBD STAR
399- BCC RSTRT ; IF TOO BIG THEN STOP
361+ LBCC START ; IF TOO BIG THEN STOP
400362 LDX AMPR
401-* LDS INSPTR ; remember that the 6800/6801 stack is postdecrement push.
363+* LDS INSPTR ; Remember that the 6800/6801 stack is postdecrement push.
402364 * STS AMPR
403- LDD INSPTR ; remember that the 6800/6801 stack is postdecrement push.
365+ LDD INSPTR ; The 6809 stack is predecrement push, but that doesn't matter here.
404366 STD AMPR
405-*
406-* LDS AMPR
407367 STD DST
408- INX ; SLIDE OPEN GAP
409-SLIDE DEX ; going down
368+ LEAX 1,X ; SLIDE OPEN GAP
369+SLIDE LEAX -1,X ; going down
410370 STX SRC
411- LDAB 0,X
371+ LDB 0,X
412372 * PSHB ; stack blast it
413373 LDX DST
414- STAB 0,X ; mimic 6800 push
415- DEX
374+ STB 0,X ; mimic 6800 push
375+ LEAX -1,X
416376 STX DST
417377 LDX SRC
418- CPX SAVLIN
378+ CMPX SAVLIN
419379 BHI SLIDE
420380 *
421381 * DON LDS DOLR ; STORE LINE #
422382 * STS 0,X
423-DON LDD DOLR ; STORE LINE #
424- STD 0,X
425- STX DST ; will skip by offset store
383+DON
384+ LDD DOLR ; STORE LINE #
385+ STD 0,X ; Note MSB1st byte order implicit dependency here.
386+ STX DST ; will skip by offset on store
426387 * LDS EDTLIN ; GET NEW LINE
427388 * DES ; pre-increment
428389 LDD EDTLIN ; GET NEW LINE
@@ -432,107 +393,105 @@ DON LDD DOLR ; STORE LINE #
432393 * PULB
433394 * STAB 1,X ; (skips over low byte, BTW)
434395 MOVL LDX SRC
435- LDAB 0,X
436- INX
396+ LDB ,X+
437397 STX SRC
438398 LDX DST
439- INX ; skip over what was already stored (too tricky for words).
399+ LEAX 1,X ; skip over what was already stored (too tricky for words).
440400 STX DST
441- STAB 1,X ; note offset store
401+ STB 1,X ; note offset store
442402 BNE MOVL ; until NUL stored
443403 *
444404 GOTIT
445405 * LDS #STACK ; Ready for a new line of input.
446- LDS USTKMK ; restore from mark
447- JMP LOOP
406+ LDS STKMRK ; restore from mark
407+ LBRA LOOP
448408 *
449-RSTRT JMP START ; warm start over
409+* RSTRT LBRA START ; warm start over
450410 *
451-PRNT PULB ; PRINT DECIMAL
411+PRNT PULS B ; PRINT DECIMAL
452412 PRNT2 LDX #DECBUF ; CONVERT TO DECIMAL
453413 STX CNVPTR
454414 LDX #PWRS10
455-CVD1 PSHX
415+CVD1 PSHS X
456416 LDX 0,X
457417 STX VARADR
458418 LDX #VARADR
459- JSR DIVIDE
460- PSHA
419+ LBSR DIVIDE
420+ PSHS A
461421 LDX CNVPTR
462- LDAA DIVQUO+1
422+ LDA DIVQUO+1
463423 ADDA #'0
464- STAA 0,X
465- PULA
466- INX
424+ STA 0,X
425+ PULS A
426+ LEAX 1,X
467427 STX CNVPTR
468- PULX
469- INX
470- INX
428+ PULS X
429+ LEAX 2,X
471430 TST 1,X
472431 BNE CVD1
473432 *
474433 LDX #DECB_1
475434 COM 5,X ; ZERO SUPPRESS
476-ZRSUP INX
477- LDAB 0,X
435+ZRSUP LEAX 1,X
436+ LDB 0,X
478437 CMPB #'0
479438 BEQ ZRSUP
480439 COM LASTD
481440 *
482441 PNTMSG CLRA ; ZERO FOR DELIM
483-STRTMS STAA DELIM ; STORE DELIMTER
442+STRTMS STA DELIM ; STORE DELIMTER
484443 *
485-OUTMSG LDAB 0,X ; GENERAL PURPOSE PRINT
486- INX
444+OUTMSG LDB ,X+ ; GENERAL PURPOSE PRINT
487445 CMPB DELIM
488446 BEQ CTLC
489- JSR OUTCH
447+ LBSR OUTCH
490448 BRA OUTMSG
491449 *
492-CTLC JSR POLCAT ; POL FOR CHARACTER
493- BCC RTS2
494- BSR INCH2
450+CTLC
451+ LBSR POLCAT ; POL FOR CHARACTER
452+ BCC RTS2 ; return wherever we came from
453+ LBSR INCH
495454 CMPB #BREAK ; BREAK KEY?
496- BEQ RSTRT
455+ LBEQ START
497456 *
498-INCH2 JMP INCH
457+INCH2 LBRA INCH
499458 *
500459 STRING BSR STRTMS ; PRINT STRING LITERAL
501- LDAA 0,X
460+ LDA 0,X
502461 CMPA #';
503462 BEQ OUTD
504- JMP CRLF
463+ LBRA CRLF
505464 *
506465 EVAL BSR GETVAL ; EVALUATE EXPRESSION
507466 *
508-NXTRM PSHA
509- LDAA 0,X ; END OF LINE?
467+NXTRM PSHS A
468+ LDA 0,X ; END OF LINE?
510469 BEQ OUTN
511470 CMPA #')
512-OUTN PULA
471+OUTN PULS A
513472 BEQ OUTD
514473 BSR TERM
515474 LDX PARSET
516475 BRA NXTRM
517476 *
518-TERM PSHA ; GET VALUE
519- PSHB
520- LDAA 0,X
521- PSHA
522- INX
477+TERM PSHS A ; GET VALUE
478+ PSHS B
479+ LDA 0,X
480+ PSHS A
481+ LEAX 1,X
523482 BSR GETVAL
524483 STD EVALPT
525484 STX PARSET
526485 LDX #EVALPT
527- PULA
528- PULB
486+ PULS A
487+ PULS B
529488 *
530489 CMPA #'* ; SEE IF *
531490 BNE EVAL2
532- PULA ; MULTIPLY
491+ PULS A ; MULTIPLY
533492 MULTIP STD MPLIER ; 2'S COMPLEMENT
534- LDAB #$10
535- STAB MLDVCT
493+ LDB #$10
494+ STB MLDVCT
536495 CLRA
537496 CLRB
538497 *
@@ -546,27 +505,27 @@ NOAD ASL 1,X
546505 BNE MULT ; LOOP TIL DONE
547506 RTS2 RTS
548507 *
549-GETVAL JSR CVBIN ; GET VALUE
508+GETVAL LBSR CVBIN ; GET VALUE
550509 BCC OUTV
551510 CMPB #'? ; OF LITERAL
552511 BNE VAR
553- PSHX ; OR INPUT
554- JSR INLN
512+ PSHS X ; OR INPUT
513+ LBSR INLN
555514 BSR EVAL
556- PULX
557-OUTD INX
515+ PULS X
516+OUTD LEAX 1,X
558517 OUTV RTS
559518 *
560519 VAR CMPB #'$ ; OR STRING
561520 BNE VAR1
562- BSR INCH2
521+ LBSR INCH
563522 CLRA
564- INX
523+ LEAX 1,X
565524 RTS
566525 *
567526 VAR1 CMPB #'(
568527 BNE VAR2
569- INX
528+ LEAX 1,X
570529 BRA EVAL
571530 *
572531 VAR2 BSR CONVP ; OR VARIABLE
@@ -574,14 +533,14 @@ VAR2 BSR CONVP ; OR VARIABLE
574533 LDX VARADR ; LOAD OLD INDEX
575534 RTS
576535 *
577-ARRAY JSR EVAL ; LOCATE ARRAY ELEMENT
578- ASLD
536+ARRAY LBSR EVAL ; LOCATE ARRAY ELEMENT
537+ ASLB
538+ ROLA
579539 ADDD AMPR
580540 BRA PACK
581541 *
582-CONVP LDAB 0,X ; GET LOCATION
583- INX
584- PSHB
542+CONVP LDB ,X+ ; GET LOCATION
543+ PSHS B
585544 CMPB #':
586545 BEQ ARRAY ; OF VARIABLE OR
587546 CLRA ; ARRAY ELEMENT
@@ -593,24 +552,24 @@ CONVP LDAB 0,X ; GET LOCATION
593552 PACK STX VARADR ; STORE OLD INDEX
594553 STD CNVPTR
595554 LDX CNVPTR ; LOAD NEW INDEX
596- PULB
555+ PULS B
597556 RTS
598557 *
599558 EVAL2 CMPA #'+ ; ADDITION
600559 BNE EVAL3
601- PULA
560+ PULS A
602561 ADD ADDD 0,X
603562 RTS
604563 *
605564 EVAL3 CMPA #'- ; SUBTRACTION
606565 BNE EVAL4
607- PULA
566+ PULS A
608567 SUBTR SUBD 0,X
609568 RTS
610569 *
611570 EVAL4 CMPA #'/ ; SEE IF IT'S DIVIDE
612571 BNE EVAL5
613- PULA
572+ PULS A
614573 BSR DIVIDE
615574 STD REMN
616575 LDD DIVQUO
@@ -618,19 +577,19 @@ EVAL4 CMPA #'/ ; SEE IF IT'S DIVIDE
618577 *
619578 EVAL5 SUBA #'= ; SEE IF EQUAL TEST
620579 BNE EVAL6
621- PULA
622- BSR SUBTR
580+ PULS A
581+ SUBD 0,X ; missed this in the 6801 code!
623582 BNE NOTEQ
624583 TSTB
625584 BEQ EQL
626-NOTEQ LDAB #$FF
585+NOTEQ LDB #$FF
627586 EQL BRA COMBOUT
628587 *
629588 EVAL6 DECA ; SEE IF LESS THAN TEST
630- PULA
589+ PULS A
631590 BEQ EVAL7
632591 *
633-SUB2 BSR SUBTR
592+SUB2 SUBD 0,X
634593 ROLB
635594 COMOUT CLRA
636595 ANDB #$01
@@ -660,14 +619,15 @@ GOT INC MLDVCT
660619 ROR 1,X
661620 CLR DIVQUO
662621 CLR DIVQUO+1
663-DIV2 BSR SUBTR
622+DIV2 SUBD 0,X
664623 BCC OK
665624 ADDD 0,X
666- CLC
625+ ANDCC #$FE
667626 BRA DIVNOC ; instead of the trick
668-* The 6801 CPX affects all relevant flags, can't use this trick.
669-* FCB $9C ; CPX
670-OK SEC ; $0D
627+* The 6809 CMPX affects all relevant flags, can't use this trick.
628+* And the op-codes are different in the 6809, too.
629+* FCB $9C ; CMPX
630+OK ORCC #$01
671631 DIVNOC ROL DIVQUO+1
672632 ROL DIVQUO
673633 DEC MLDVCT
@@ -676,14 +636,14 @@ DIVNOC ROL DIVQUO+1
676636 ROR 1,X
677637 BRA DIV2
678638 *
679-TSTN LDAB 0,X ; TEST FOR NUMERIC
639+TSTN LDB 0,X ; TEST FOR NUMERIC
680640 CMPB #$3A
681641 BPL NOTDEC
682642 CMPB #'0
683643 BGE DONE
684-NOTDEC SEC
644+NOTDEC ORCC #$01
685645 RTS
686-DONE CLC
646+DONE ANDCC #$FE
687647 DUN RTS
688648 *
689649 CVTLN BSR INLN
@@ -697,30 +657,33 @@ CBLOOP ADDB 0,X
697657 SUBB #'0
698658 SBCA #$00
699659 STD CVTSUM
700- INX
701- PSHB
660+ LEAX 1,X
661+ PSHS B
702662 BSR TSTN
703- PULB
663+ PULS B
704664 BCS DONE
705- ASLD
706- ASLD
665+ ASLB
666+ ROLA
667+ ASLB
668+ ROLA
707669 ADDD CVTSUM
708- ASLD
670+ ASLB
671+ ROLA
709672 BRA CBLOOP
710673 *
711674 INLN6 CMPB #'@ ; CANCEL
712675 BEQ NEWLIN
713- INX ; '.'
714- CPX #ZERO+LINLEN+2 ; (Here's part of what we had to fix for moving the variables.)
676+ LEAX 1,X ; '.'
677+ CMPX #ZERO+LINLEN+2 ; (Here's part of what we had to fix for moving the variables.)
715678 BNE INLN2
716679 NEWLIN BSR CRLF
717680 *
718681 INLN LDX #ZERO+2 ; INPUT LINE FROM TERMINAL
719-INLN5 DEX
720- CPX #ZERO ; Make this explicit to enable variables moved out of DP.
682+INLN5 LEAX -1,X
683+ CMPX #ZERO ; Make this explicit to enable variables moved out of DP.
721684 BEQ NEWLIN ; (Was implicit zero compare X from DEX, now explicit.)
722-INLN2 JSR INCH ; INPUT CHARACTER
723- STAB BUFOFF-1,X ; STORE IT
685+INLN2 LBSR INCH ; INPUT CHARACTER
686+ STB BUFOFF-1,X ; STORE IT
724687 CMPB #$5F ; BACKSPACE?
725688 BEQ INLN5
726689 *
@@ -733,9 +696,9 @@ INLIN4 CLR BUFOFF-1,X ; CLEAR LAST CHAR
733696 BRA LF
734697 *
735698 * CRLF JSR EPCRLF
736-CRLF LDAB #$0D ; CARR-RET
699+CRLF LDB #$0D ; CARR-RET
737700 BSR OUTCH2
738-LF LDAB #$0A ; LINE FEED
701+LF LDB #$0A ; LINE FEED
739702 OUTCH2 BRA OUTCH
740703 *
741704 OKM FCB $0D
@@ -749,21 +712,18 @@ OKM FCB $0D
749712 * BNE TRMILP
750713 * RTS
751714 *
752-* MC-10 BASIC ROM vectors
753-INCHV EQU $FFDC ; Scan keyboard
754-OUTCHV EQU $FFDE ; Write char to screen
715+* Color Computer BASIC ROM vectors
716+INCHV EQU $A000 ; Scan keyboard
717+OUTCHV EQU $A002 ; Write char to screen
755718 *
756719 * RECEIVER POLLING
757-POLCAT PSHA
758- PSHX
759- LDX INCHV ; at any rate, don't wait.
760- JSR 0,X ;
761- TAB ; MC-10 ROM says NUL is not input.
762- SEC
720+POLCAT PSHS A
721+ JSR [INCHV] ; at any rate, don't wait.
722+ TFR A,B ; because the source I'm working with expects it in B
723+ ORCC #$01
763724 BNE POLCATR ; Don't wait.
764- CLC
765-POLCATR PULX
766- PULA
725+ ANDCC #$FE
726+POLCATR PULS A
767727 RTS
768728 *POLCAT LDAB ACIACS
769729 * ASRB
@@ -772,17 +732,14 @@ POLCATR PULX
772732 * INPUT ONE CHAR INTO B ACCUMULATOR
773733 INCH BSR POLCAT
774734 BCC INCH ; Wait here.
775- BSR OUTCH
735+ BSR OUTCH ; echo
776736 RTS
777737 *
778738 * OUTPUT ONE CHAR
779-OUTCH PSHA
780- PSHX
781- LDX OUTCHV
782- TBA
783- JSR 0,X
784- PULX
785- PULA
739+OUTCH PSHS B,A
740+ TFR B,A
741+ JSR [OUTCHV]
742+ PULS A,B
786743 RTS
787744 *
788745 ORG COLD