Deriving a new dialect of Very Tiny Language from VTL-2 6800 version
Revision | d061fffd61d9e27f8c9f3d459a1e6e1a3871daef (tree) |
---|---|
Time | 2022-09-25 21:45:57 |
Author | Joel Matthew Rees <joel.rees@gmai...> |
Commiter | Joel Matthew Rees |
Moved DP to avoid conflicts (this is the one that had functional expressions)
@@ -33,7 +33,9 @@ BREAK EQU $03 | ||
33 | 33 | *ACIACS EQU $FCF4 ; exorcisor |
34 | 34 | *ACIADA EQU $FCF5 ; exorcisor |
35 | 35 | * |
36 | -* A few interpreter variables in the direct page won't hurt. | |
36 | +* A few interpreter variables in the direct page won't hurt, said the snake oil vendor. | |
37 | +* (See SNDDUR and PLYTMR in particular.) | |
38 | +* (Really need to move these. Use DP after all? IRQ, at least, uses extended mode addressing.) | |
37 | 39 | * (Yes, I can hear voices of complaint that it's not as "tight" as it could be.) |
38 | 40 | * (This allows us to save more ROM space and uses DP that would otherwise go wasted.) |
39 | 41 | * (Trade-offs.) |
@@ -47,7 +49,7 @@ BREAK EQU $03 | ||
47 | 49 | * Does not really make specific use of the DP register. |
48 | 50 | * ORG $C0 ; Move this according to your environment's needs. |
49 | 51 | * Change this to move the registers: |
50 | -DPBASE EQU $D0 ; PIA mask at $C2? Avoid it, anyway. | |
52 | +DPBASE EQU $C4 ; PIA mask at $C2? Avoid it, anyway. | |
51 | 53 | * PARSET RMB 2 ; Instead of SAVE0 in TERM/NXTRM |
52 | 54 | PARSET EQU DPBASE+2 |
53 | 55 | * CVTSUM RMB 2 ; Instead of SAVE1 in CBLOOP |
@@ -79,6 +81,9 @@ DST EQU SRC+2 | ||
79 | 81 | STKMRK EQU DST+2 ; to restore the stack on each pass. |
80 | 82 | DPALLOC EQU STKMRK+2 ; total storage declared in the direct page |
81 | 83 | * |
84 | +*******!!!!!! Check that we have avoided $00E2, as well, since it is used as PLYTMR by an interrupt routine. | |
85 | +* Also, $008D is used as SNDDUR by BASIC. | |
86 | +* | |
82 | 87 | * SET ASIDE FOUR BYTES FOR USER |
83 | 88 | * DEFINED INTERUPT ROUTINE IF NEEDED |
84 | 89 | ZERO EQU $1600 ; Dodge BASIC and video use RAM. |
@@ -180,35 +185,42 @@ PROBE STA 0,X | ||
180 | 185 | CMPB 0,X |
181 | 186 | BNE NOTRAM ; all bits seem to be R/W. |
182 | 187 | LEAX 1,X |
183 | - STX $400 ; DBG | |
184 | 188 | PROBET CMPX #COLD |
185 | 189 | BLO PROBE ; CMPX on 6809 works right. |
186 | 190 | NOTRAM LEAX -1,X |
187 | 191 | STX STAR |
188 | - STX $402 ; DBG | |
192 | +* STX $402 ; DBG | |
189 | 193 | START |
194 | + STX $400 ; DBG | |
190 | 195 | * LDS #STACK ; re-initialize at beginning of each evaluate |
191 | 196 | LDS STKMRK ; from mark instead of constant |
192 | 197 | STS SEMI ; DBG Comment this out when we no longer need to see the stack pointer BASIC gives us. |
193 | 198 | CLRA ; NUL delimiter |
194 | 199 | LDX #OKM |
195 | - STX $404 ; DBG | |
200 | +* STX $404 ; DBG | |
196 | 201 | LBSR STRING |
197 | - BRA * ; DBG | |
202 | +* BRA * ; DBG | |
198 | 203 | * |
199 | 204 | LOOP CLRA |
200 | 205 | STA DOLR |
201 | 206 | STA DOLR+1 |
202 | - JSR CVTLN | |
207 | + INC $40D ; DBG | |
208 | + STA $420 ; DBG | |
209 | + LBSR CVTLN | |
210 | + INC $40E ; DBG | |
211 | + STA $421 ; DBG | |
203 | 212 | BCC STMNT ; NO LINE# THEN EXEC |
204 | 213 | BSR EXEC |
205 | 214 | BEQ START |
206 | 215 | * |
207 | 216 | LOOP2 BSR FIND ; FIND LINE |
208 | 217 | EQSTRT BEQ START ; IF END THEN STOP |
218 | + DEC $42A ; DBG | |
209 | 219 | LDX 0,X ; LOAD REAL LINE # |
220 | + STX $42B ; DBG | |
210 | 221 | STX DOLR ; SAVE IT |
211 | 222 | LDX SAVLIN ; GET LINE |
223 | + STX $42D ; DBG | |
212 | 224 | LEAX 3,X ; BUMP PAST LINE # and SPACE |
213 | 225 | BSR EXEC ; EXECUTE IT |
214 | 226 | BEQ LOOP3 ; IF ZERO, CONTINUE |
@@ -264,23 +276,29 @@ LOOKAG LEAX 1,X ; FIND END OF LINE | ||
264 | 276 | RTS |
265 | 277 | * |
266 | 278 | FIND LDX #PRGM ; FIND LINE |
279 | + DEC $425 ; DBG | |
267 | 280 | FND2 STX SAVLIN |
268 | 281 | CMPX AMPR |
269 | 282 | BEQ RTS1 |
283 | + DEC $426 ; DBG | |
270 | 284 | * LDA 1,X ; almost missed this. |
271 | 285 | * SUBA DOLR+1 ; This was necessary because no SUBD |
272 | 286 | * LDA 0,X ; and CPX does not affect C flag on 6800 |
273 | 287 | * SBCA DOLR |
274 | -* PSHB ; B does not seem to be in use. | |
288 | +* PSHS B ; B does not seem to be in use. | |
275 | 289 | LDD 0,X ; Use D because we think we want to keep X. |
276 | 290 | SUBD DOLR |
277 | -* PULB | |
291 | +* PULS B | |
278 | 292 | BCC SET |
293 | + DEC $427 ; DBG | |
279 | 294 | FND3 BSR NXTXT |
295 | + DEC $428 ; DBG | |
280 | 296 | BRA FND2 |
281 | 297 | * |
282 | 298 | SET LDA #$FF ; SET NOT EQUAL |
283 | -RTS1 RTS | |
299 | +RTS1 | |
300 | + CLR $429 ; DBG (Z FLAG SET) | |
301 | + RTS | |
284 | 302 | * |
285 | 303 | EVALU LBSR EVAL ; EVALUATE LINE |
286 | 304 | PSHS A,B ; A is pushed after B |
@@ -307,8 +325,11 @@ AR2RND ADDB QUITE ; RANDOMIZER ; Adding the low byte to the high byte | ||
307 | 325 | STD QUITE |
308 | 326 | RTS |
309 | 327 | * |
310 | -SKP2 BSR FIND ; FIND LINE | |
328 | +SKP2 | |
329 | + DEC $422 ; DBG | |
330 | + BSR FIND ; FIND LINE | |
311 | 331 | BEQ INSRT ; IF NOT THERE |
332 | + DEC $423 ; DBG | |
312 | 333 | LDX 0,X ; THEN INSERT |
313 | 334 | CMPX DOLR ; NEW LINE |
314 | 335 | BNE INSRT |
@@ -337,7 +358,10 @@ DELT LDX SRC | ||
337 | 358 | FITIT LDX DST |
338 | 359 | STX AMPR ; STORE NEW END |
339 | 360 | * |
340 | -INSRT LDX EDTLIN ; COUNT NEW LINE LENGTH | |
361 | +INSRT | |
362 | + INC $423 ; DBG | |
363 | + LDX EDTLIN ; COUNT NEW LINE LENGTH | |
364 | + STX $430 ; DBG | |
341 | 365 | LDB #$03 |
342 | 366 | TST 0,X |
343 | 367 | BEQ GOTIT ; IF NO LINE THEN STOP |
@@ -345,19 +369,21 @@ CNTLN INCB ; count bytes | ||
345 | 369 | LEAX 1,X |
346 | 370 | TST 0,X ; Find trailing NUL |
347 | 371 | BNE CNTLN |
372 | + STX $432 ; DBG | |
373 | + STB $434 ; DBG | |
348 | 374 | * |
349 | 375 | OPEN CLRA ; CALCULATE NEW END |
350 | 376 | ADDD AMPR |
351 | 377 | STD INSPTR |
378 | + STD $437 ; DBG | |
352 | 379 | SUBD STAR |
353 | 380 | LBCC START ; IF TOO BIG THEN STOP |
354 | 381 | LDX AMPR |
355 | -* LDS INSPTR ; remember that the 6800/6801 stack is postdecrement push. | |
382 | + STX $435 | |
383 | +* LDS INSPTR ; Remember that the 6800/6801 stack is postdecrement push. | |
356 | 384 | * STS AMPR |
357 | - LDD INSPTR ; remember that the 6800/6801 stack is postdecrement push. | |
385 | + LDD INSPTR ; The 6809 stack is predecrement push, but that doesn't matter here. | |
358 | 386 | STD AMPR |
359 | -* | |
360 | -* LDS AMPR | |
361 | 387 | STD DST |
362 | 388 | LEAX 1,X ; SLIDE OPEN GAP |
363 | 389 | SLIDE LEAX -1,X ; going down |
@@ -374,13 +400,16 @@ SLIDE LEAX -1,X ; going down | ||
374 | 400 | * |
375 | 401 | * DON LDS DOLR ; STORE LINE # |
376 | 402 | * STS 0,X |
377 | -DON LDD DOLR ; STORE LINE # | |
378 | - STD 0,X | |
379 | - STX DST ; will skip by offset store | |
403 | +DON | |
404 | + STX $439 ; DBG | |
405 | + LDD DOLR ; STORE LINE # | |
406 | + STD 0,X ; Note MSB1st byte order implicit dependency here. | |
407 | + STX DST ; will skip by offset on store | |
380 | 408 | * LDS EDTLIN ; GET NEW LINE |
381 | 409 | * DES ; pre-increment |
382 | 410 | LDD EDTLIN ; GET NEW LINE |
383 | 411 | STD SRC |
412 | + STD $43B ; DBG | |
384 | 413 | * |
385 | 414 | *MOVL INX ; INSERT NEW LINE (skip over LINE # hi byte) |
386 | 415 | * PULB |
@@ -396,7 +425,10 @@ MOVL LDX SRC | ||
396 | 425 | * |
397 | 426 | GOTIT |
398 | 427 | * LDS #STACK ; Ready for a new line of input. |
428 | + STS $41C ; DBG | |
399 | 429 | LDS STKMRK ; restore from mark |
430 | + STS $41E ; DBG | |
431 | + STX $43D ; DBG | |
400 | 432 | LBRA LOOP |
401 | 433 | * |
402 | 434 | * RSTRT LBRA START ; warm start over |
@@ -433,27 +465,27 @@ ZRSUP LEAX 1,X | ||
433 | 465 | * |
434 | 466 | PNTMSG CLRA ; ZERO FOR DELIM |
435 | 467 | STRTMS STA DELIM ; STORE DELIMTER |
436 | - DEC $408 ; DBG | |
468 | +* DEC $408 ; DBG | |
437 | 469 | * |
438 | 470 | OUTMSG LDB ,X+ ; GENERAL PURPOSE PRINT |
439 | - INC $409 ; DBG | |
440 | - STB $40A ; DBG | |
471 | +* INC $409 ; DBG | |
472 | +* STB $40A ; DBG | |
441 | 473 | CMPB DELIM |
442 | 474 | BEQ CTLC |
443 | 475 | LBSR OUTCH |
444 | - STB $40C ; DBG | |
476 | +* STB $40C ; DBG | |
445 | 477 | BRA OUTMSG |
446 | 478 | * |
447 | 479 | CTLC |
448 | - INC $420 ; DBG | |
480 | +* INC $420 ; DBG | |
449 | 481 | LBSR POLCAT ; POL FOR CHARACTER |
450 | - INC $421 ; DBG | |
482 | +* INC $421 ; DBG | |
451 | 483 | BCC RTS2 ; return wherever we came from |
452 | - INC $422 ; DBG | |
453 | - STB $423 ; DBG | |
484 | +* INC $422 ; DBG | |
485 | +* STB $423 ; DBG | |
454 | 486 | LBSR INCH |
455 | 487 | CMPB #BREAK ; BREAK KEY? |
456 | - STB $424 ; DBG | |
488 | +* STB $424 ; DBG | |
457 | 489 | LBEQ START |
458 | 490 | * |
459 | 491 | INCH2 LBRA INCH |
@@ -747,7 +779,7 @@ INCH BSR POLCAT | ||
747 | 779 | * |
748 | 780 | * OUTPUT ONE CHAR |
749 | 781 | OUTCH PSHS B,A |
750 | - TFR A,B | |
782 | + TFR B,A | |
751 | 783 | JSR [OUTCHV] |
752 | 784 | * INC $410 ; DBG |
753 | 785 | * STA &411 ; DBG |