我正在为NES学习程序集,并且编写了以下程序:
.org $8000 ; set code to start of rom
Start: ; make a label called start
lda #$ff ; set acc to 0xff
sta $0000 ; store address 0x0000 to acc which is 0xff
jmp Start ; jump to label start
Run Code Online (Sandbox Code Playgroud)
我用NESASM3编译了程序,编译成功,然后在仿真器中运行它,当我转到仿真器中的内存查看器时,查看地址$ 0000,它是01,而不是FF,就像我编程的那样。
我目前正在为 NES 制作一个模拟器(像许多其他模拟器一样),并在针对 Kevtris 的 Nestest ROM 测试我的模拟时(在这里找到: https: //wiki.nesdev.com/w/index.php/Emulator_tests),有这是我在nestest日志的指令877处遇到的一个奇怪的错误(这个: http: //www.qmtpro.com/~nes/misc/nestest.log,在CE42行)。
该指令是一条 PLA,它从堆栈中取出累加器,同时堆栈指针位于 $7E 的开头。(我使用 1 字节值作为堆栈指针,因为它从 0x0100 到 0x01FF ,所以当我写 $7E 谈论堆栈时,它是 0x017E ,而不是 Zeropage ;))
因此,当 PLA 在第 877 行执行时,堆栈指针移动到 $7F 并检索第一个字节并将其存储到累加器中。
问题就在这里:在嵌套日志上,该字节是 0x39 ,然后,在也是 PLA 的指令 878 上,在 $80(堆栈指针递增 + 1)处检索到的字节是 0xCE,这已经反转了低字节和高字节。
写入堆栈 (0xCE39) 的值源自 CE37 行的 JSR 指令,以下是我对 JSR 操作码的实现:
uint8_t JSR(){
get() ; // fetch the data of the opcode , like an absolute address operand or a value
uint16_t newPC = …
Run Code Online (Sandbox Code Playgroud) I have a snippet that clears memory before initializing a game in NES 6502 assembly. When I leave the code inside the reset proc like so, it works:
.proc reset
SEI
CLD
LDX #0
ClearRAM:
STA $000,x
STA $100,x
STA $200,x
STA $300,x
STA $400,x
STA $500,x
STA $600,x
STA $700,x
INX
BNE ClearRAM
.endproc
Run Code Online (Sandbox Code Playgroud)
However, if I try to move this ClearRAM snippet inside a scoped proc:
.scope Memory
.proc clear
LDX #0
ClearRAM:
STA $000,x
STA $100,x
STA …
Run Code Online (Sandbox Code Playgroud) 我目前正在开发NES(6502)组装游戏,但不了解如何进行精灵移动,这里我认为它应该如何工作:
(loop)
LDA $200 ;will load into the A register the content of address $200,wich contain the Y postion of my sprite
INA ;Increment the A register wich would increment the content of A wich is the Y position of my sprite..?
Run Code Online (Sandbox Code Playgroud)
但是似乎您无法增加A寄存器累加器,因为在尝试使用INA指令进行汇编时出现错误。但是我想使用地址$ 200的内容,而不是在其中选择一个值,我不知道如何使子画面移动。
谢谢!
我开始利用业余时间为一个潜在的 NES 游戏项目学习 6502 汇编,但在设置控制器输入的读取时遇到了一些问题。我的背景是 C 语言,所以我熟悉内存及其工作原理,但汇编中的流程控制仍然让我无法理解。
因为我是新手,所以我认为我应该从简单开始并使用https://www.vbforums.com/showthread.php?858965-NES-6502-Programming-Tutorial-Part-5中描述的逐个按钮方法-控制器命令。这很好用,但确实重复且冗长。
有没有一种更优雅的方法来做到这一点,但又不完全超出我的能力?在没有帮助的情况下,我不知道如何集成其他来源的代码。
https://wiki.nesdev.com/w/index.php/Controller_reading_code看起来很有希望,但我并没有真正理解它来使用它。
感谢您的时间。
我正在制作 NES 游戏。我正在定义几个常量来帮助我管理精灵。我有
spriteyposition = $0200
spritetile = $0201
spriteattribute = $0202
spritexposition = $0203
sprite1 = $00
sprite2 = $04
sprite3 = $08
sprite4 = $0c
sprite5 = $10
sprite6 = $14
sprite7 = $18
sprite8 = $1c
Run Code Online (Sandbox Code Playgroud)
我的用例如下:
我想修改精灵1的y位置
我愿意:
ldx sprite1
lda spriteyposition, x
adc #$8
sta spriteyposition, x
Run Code Online (Sandbox Code Playgroud)
在我的用例中 spriteyposition 应该是一个内存指针,但我有一种感觉,汇编程序将其视为常规数字
我如何将 spriteyposition 称为内存地址而不是数字?