assembly - C64汇编存储内存地址并增加它
问题描述
我现在学习 C64 的 KickAss 汇编程序,但我以前从未学习过任何 asm 或 8 位计算。我想打印大的 ascii 横幅(数字)。我想将“$ 0400”地址存储在内存中,当我增加行号时,我需要将其增加 36(因为屏幕是 40 字符宽度,所以我想跳到下一行),但我的问题是这是一个 2 字节的数字,所以我不能只添加它。这个演示工作“很好”,除了线增加,因为我不知道。
所以我需要的是:
- 如何在内存中存储 2 字节的内存地址?
- 我怎样才能增加内存地址并存储回来(2字节)?
- 如何将值存储到新地址(2 字节和索引寄存器只是一个)?
谢谢很多人!
BasicUpstart2(main)
*=$1000
currentLine:
.byte 00
main:
printNumber(num5)
rts
num5: .byte $E0, $E0, $E0, $E0, $00 // XXXX(null)
.byte $E0, $20, $20, $20, $00 // X (null)
.byte $E0, $20, $20, $20, $00 // X (null)
.byte $E0, $E0, $E0, $E0, $00 // XXXX(null)
.byte $20, $20, $20, $E0, $00 // X(null)
.byte $20, $20, $20, $E0, $00 // X(null)
.byte $E0, $E0, $E0, $E0, $00 // XXXX(null)
.macro printNumber(numberLabel)
{
ldx #0
lda #0
lda #0
loop:
lda numberLabel,x
beq checkNextline
sta $0400,x
inx
jmp loop
checkNextline:
inx
inc currentLine
lda currentLine
cmp #7
beq done
jmp loop
done:
}
// Expected output:
XXXX
X
X
XXXX
X
X
XXXX
// Current output:
XXXXX X XXXX X XXXXX
(where the X is the $E0 petscii char)
解决方案
clc
lda LowByte ; Load the lower byte
adc #LowValue ; Add the desired value
sta LowByte ; Write back the lowbyte
lda HiByte ; No load hi byte
adc #HiValue ; Add the value.
sta HiByte
推荐阅读
- java - 为什么 android studio 不识别 mp4 格式?
- c - 为什么这个程序会出现故障?
- azure - 从 Azure Web App (Linux) 提供 Angular PWA 失败,因为缺少 .webmanifest
- python-3.x - 如何在谷歌云上运行不可用的 503 服务?
- powershell - Powershell 使用 $true 和 $false 导入 csv
- python - 如何根据列表中的值打印给定值一定次数?
- javascript - 无法使计时器停止.. (js)
- smooth-scrolling - 如何使用 idiotWu 的平滑滚动库获得滚动偏移量?
- python - ModuleNotFoundError:没有名为“wanda”的模块
- django - Celery Beat 和 Django orm 无法正常工作