gpt4 book ai didi

assembly - 用汇编写入内存(Z80/Gameboy)

转载 作者:行者123 更新时间:2023-12-02 22:05:29 24 4
gpt4 key购买 nike

我正在尝试以编程方式将字符写入内存,以便可以将其显示在屏幕上。如何使用 Gameboy 的 Z80 组件获取一个值(例如 65)并将其写入内存?

据我所知,这只是将寄存器加载到内存地址的情况:

ld [hl], b

我的代码似乎与将字符写入内存无关。我得到的输出是“BBBBBBBB”。

周围的代码如下。

printnum:
ld a, 0 ; cursor position
ld b, 65 ; ASCII 'A'
ld hl, Number ; set pointer to address of Number
overwrite:
ld [hl], b ; set dereference to 'A' ???
inc hl ; increment pointer
inc a ; increment acc
cp 7 ; are we done?
jp z, overwrite ; continue if not

; V output to screen V
ld hl, Number
ld de, _SCRN0+3+(SCRN_VY_B*7) ;
ld bc, NumberEnd-Number
call mem_CopyVRAM

ret ; done
Number:
DB "BBBBBBBB" ; placeholder
NumberEnd:

最佳答案

Gameboy 代码在 ROM:只读存储器中执行。因此,覆盖数字的循环没有任何效果(尝试写入 ROM 只是保留现有值)。如果您想要写入缓冲区,您需要确保它位于 RAM 中。

关于assembly - 用汇编写入内存(Z80/Gameboy),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34517657/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com