首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带标签的6502寻址模式

带标签的6502寻址模式
EN

Stack Overflow用户
提问于 2018-06-23 20:43:35
回答 1查看 1.2K关注 0票数 3

我正在查看这个站点的一些代码示例:

http://www.6502asm.com/

看一看,我看到它们有一些说明,它们没有直接使用内存位置,而是使用标签,例如,在alive.asm中:

代码语言:javascript
复制
lda ypos,x

而ypos是

代码语言:javascript
复制
ypos:
dcb $00,$02,$20,$02,$40,$02,$60,$02
dcb $80,$02,$a0,$02,$c0,$02,$e0,$02
dcb $00,$03,$20,$03,$40,$03,$60,$03
dcb $80,$03,$a0,$03,$c0,$03,$e0,$03
dcb $00,$04,$20,$04,$40,$04,$60,$04
dcb $80,$04,$a0,$04,$c0,$04,$e0,$04
dcb $00,$05,$20,$05,$40,$05,$60,$05
dcb $80,$05,$a0,$05,$c0,$05,$e0,$05

我知道标签根据汇编程序的不同而不同,但我假设它是经过这个列表的,但是它的特殊性如何工作呢?

EN

回答 1

Stack Overflow用户

发布于 2018-06-25 08:33:00

下面是关于指令lda ypos,x的详细信息:

  1. 如果ypos位于零页之外(等于或超过0x0100):
代码语言:javascript
复制
- Opcode is 0xBD: it uses an _**indexed absolute**_ addressing mode using the index register X, also called _**absolute,X**_ mode  
- it computes an address by adding the content of X register to the 2-bytes address represented by the label `ypos`, then it loads the A register (accumulator) with the byte located at the computed address
- its size is **3 bytes**; it takes **4 CPU cycles** + 1 cycle if page boundary is crossed, i.e. if the high byte of `ypos` is different from the high byte of the compute address `ypos + X`.
- it updates only the status **flags N and Z** (Negative and Zero)

  1. 如果ypos位于零页内(在0x00和0xFF之间),那么它可能依赖于您的汇编程序(检查操作码):它要么使用索引的绝对寻址模式,然后按照前面的描述工作,要么:。
    • Opcode是0xB5:它使用索引零页寻址模式,使用索引寄存器X,也称为零点,X模式。
    • 它通过将X寄存器的内容添加到标签ypos表示的1字节地址中计算地址,包装在0x00-0xFF范围内,然后用位于计算地址的字节加载A寄存器(累加器)。 注意:要非常小心,因为如果在ypos中定义的值超出了零页,则可能不是预期的行为。您的汇编程序中可能有特定的语法来强制使用绝对的X寻址模式。
    • 它的大小是2字节;它需要4 CPU周期
    • 它只更新状态标志N和Z (负和零)

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51004893

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档