Skip to content

Commit 3767aba

Browse files
committed
Pass print "color" in ZP variable instead of the stack.
This makes the code smaller.
1 parent 13c249b commit 3767aba

4 files changed

Lines changed: 12 additions & 14 deletions

File tree

src/interp/atari/print_tab.asm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
; ---------------------------------------------
2929

3030
.import putc, stack_l, print_str_tmp1
31-
.importzp sptr, next_instruction, tmp1, tmp2
31+
.importzp sptr, next_instruction, tmp1, tmp2, PRINT_ARG
3232

3333
.include "target.inc"
3434

@@ -72,6 +72,7 @@ ok:
7272

7373
inc sptr
7474
ldy #0 ; Print color = 0
75+
sty PRINT_ARG
7576
jmp print_str_tmp1 ; Print string in tmp1
7677
.endproc
7778

src/interp/print_str.asm

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,27 @@
2929

3030
.import putc, stack_l
3131
.importzp tmp1, tmp2, tmp3, next_instruction, sptr
32+
.exportzp PRINT_ARG
3233
.export print_str_tmp1
3334

35+
PRINT_ARG = tmp3
36+
3437
.segment "RUNTIME"
3538

36-
.proc EXE_PRINT_COLOR_STR ; PRINT string in AX
37-
pha
38-
lda stack_l, y
39-
inc sptr
40-
tay
41-
pla
42-
.byte $2C ; Skip 2 bytes over next "LDY"
43-
.endproc
44-
.proc EXE_PRINT_STR ; PRINT string in AX
39+
.proc EXE_PRINT_STR ; PRINT string in AX, with color 0
4540
ldy #0
41+
sty PRINT_ARG
42+
::EXE_PRINT_COLOR_STR: ; PRINT string in AX with given color
4643
sta tmp1
4744
stx tmp1+1
4845
ptmp: ; Prints string in TMP1
49-
sty tmp3
5046
ldy #0
5147
lda (tmp1), y ; LENGTH
5248
beq nil
5349
sta tmp2
5450
loop: iny
5551
lda (tmp1), y
56-
eor tmp3
52+
eor PRINT_ARG
5753
jsr putc
5854
cpy tmp2
5955
bne loop

src/parse.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
; From vars.asm
3737
.exportzp var_count, label_count
3838
; From runtime.asm
39-
.importzp IOCHN, COLOR, IOERROR
39+
.importzp IOCHN, COLOR, IOERROR, PRINT_ARG
4040
.import putc
4141
; From interpreter.asm
4242
.importzp DEGFLAG, DEGFLAG_DEG, DEGFLAG_RAD, saved_cpu_stack

src/syntax/basic.syn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ SYMBOLS {
9898

9999
BASIC_TOP = importzp
100100
IOERROR = importzp
101+
PRINT_ARG = importzp
101102
MEMTOP = import
102103
CLEAR_DATA = import
103104
ATEOL = 155
@@ -297,7 +298,7 @@ PRINT_SEP_EOL:
297298

298299
# - One item to print, converted to string:
299300
PRINT_ONE_STR:
300-
"Color" T_EXPR emit { TOK_PUSH } PRINT_ONE emit TOK_PRINT_COLOR_STR
301+
"Color" T_EXPR emit { TOK_BYTE_POKE, PRINT_ARG } PRINT_ONE emit TOK_PRINT_COLOR_STR
301302
PRINT_ONE emit TOK_PRINT_STR
302303
pass
303304

0 commit comments

Comments
 (0)