簡體   English   中英

PET CBM C64 MOS6510 Assembly 用計算出的屏幕地址在屏幕上打印出字母?

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

我是 C64 匯編程序的新手,我對保存和加載內存區域的過程有疑問。 我關心以下問題:

lda #$01
sta $0400

將字母 A 放在屏幕左上角

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

有了這個,我可以使用 x 寄存器作為計數器,並且可以比較我使用循環的頻率。

但現在我有一個 16 位計算(屏幕起始地址加 xxx)並將結果存儲在內存地址中,如 $4000 和 $4001。 如何使用此值作為新的屏幕地址在屏幕上的計算區域打印出字母 a?

好的,現在我明白 (indirect),Y 的意思了 我的解決方案現在是這樣的:

.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 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM