My SBC is working and now I come to the second interesting part, the programming.
I have connected an LCD and can output texts there. Welcome message, status message...
But what is the best way to store this texts in ROM?
My first idea was to simply place texts where they are needed
Code:
message_w6502sbc: .asciiz "W6502SBC Welcome"
first variant: subroutine
Code:
do_strout:
stx TEMP_VEC
sta TEMP_VEC+1
ldy #0
strprint:
lda (TEMP_VEC),y
beq strreturn
jsr do_chrout
iny
jmp strprint
strreturn:
rts
call with
Code:
lda #>message_w6502sbc
ldx #<message_w6502sbc
jsr do_strout
This can even be shortend with a macro, like
Code:
.macro msg_out(msg)
lda #>msg
ldx #<msg
jsr do_strout
.endmacro
called with
Code:
msg_out(message_w6502sbc)
second variant
Text in a block with an address array.
Code:
.org $FD00
messages:
msg_w6502sbc.equ 0
msg_ready.equ 3
.word message_w6502sbc
.word message_ready
message_w6502sbc: .asciiz "W6502SBC Welcome"
message_ready: .asciiz "W6502SBC ready:"
Access via the index and a TempVector in the ZP
Code:
do_msgout:
asl ; *2
tay ; into the y register
lda messages,y ; load lo address of msg
sta TEMP_VEC ; into the lo st vector
iny ; increase y
lda messages,y ; load hi address of msg
sta TEMP_VEC+1 ; into the hi str vector
ldy #0 ; y = 0
jmp strprint ; output string, second part of do_strout
call with
Code:
lda #msg_w6502sbc
jsr do_msgout
This is a slower variant, but the calls are very short. You even don't need a macro for it.
Is variant 2 worth it? It saves one instruction when called, but costs 6 instructions more when executed.
I haven't considered backing up and restoring the registers yet.
I tend to prefer the first solution.
What do you mean?
How do you do this?
Is there perhaps a better way?
_________________
don't count on me, i'm engineer (Animotion)
my arduino pages:
http://rcarduino.de