PET CBM C64 MOS6510 Assembly Print out letter on screen with calculated screen address?

197 views Asked by At

I'm new to assembler programming for the C64 and I have a question about the procedure for saving and loading memory areas. I am concerned with the following:

lda #$01
sta $0400

Puts the letter A to the top left on the screen

ldx #$00
lda #$01
sta $0400, x

with this I can use x register as an counter and can compare how often I will use a loop.

But now I have a 16-Bit calculate (Screen start address plus xxx) and store the result inside a memory address like $4000 und $4001. How can I use this value as the new screen address to print out the letter a on the calculated area on the screen?

1

There are 1 answers

0
DiscMix On

OK, now I understand the meaning of (indirect),Y My solution looks now like this:

.var lines = $28       //40 characters
.var currentPos = $fd  //save screen address

calcLine:  
ldx #$05               //counter 5 backward
ldy #$00               //Sets carry to 0
lda #lines             //A=40 
asl                    //A=80 

calc:
clc 
adc #lines             //A=120 (or $78 in hex) 
bcc next               //If carry, then increase
iny

next:
dex
cpx #$00
bne calc
sta currentPos     //If carry, then increase 
sty currentPos+1   //Save value if carry

//add screen start address ($0400)
clc
lda currentPos+1
adc #$04
sta currentPos+1

lda #$42    //the sign

sta (currentPos),y