递增地址组件 MOS6502 的前两个字节
Incrementing the first two bytes of an address assembly MOS6502
这里我有一个问题,因为寄存器只有 8 位,我不能存储 16 位地址,所以我必须将它分成两个字节 es:
addr: %4300 将被划分为little endian
高字节:43
低字节:00
问题是我不能增加地址的高字节,只能增加低字节 34=]INC 指令.
例如:
LDA 00
ADC #01
STA %4300
编辑:
我想增加 内存地址 即 4300 美元但我只想增加前两个字节所以高字节,我不关心写一个值那个地址
示例:
LDA #00
ADC #1
; the result i want should be 00 and so on..
我该如何解决?
谢谢!
如果您想增加或更改地址的值 - 或任何数据 - 那么您需要知道该地址的地址。
乍一看这听起来有点令人困惑,但请记住,CPU 正在处理的所有内容都在其内存中 space 或寄存器中。
这包括编译器吐出的每条指令和值。因此,要增加地址的高字节($4300),您必须知道该数据的实际位置。
还有一点要知道,6502 是 'little-endian',因此指令先读取低字节,然后再读取高字节。所以在内存中,您的地址 00
实际上是 [=12=]
后跟 </code>.</p>
<p>现在,有许多不同的方法可以实现您的目标,但这里有一个简单的例子:</p>
<pre><code>cool_address: .res 2 ; We reserve 2 bytes somewhere in RAM
; and give it the label cool_address
; so we can easily access it.
...
LDA #[=10=] ; Put [=10=] into the Accumulator
STA cool_address ; Store the Accumulator in the 1st byte of address
LDA # ; Put into the Accumulator
STA cool_address+1 ; Store the Accumulator in the 2nd byte of address
; At this point, the 2 bytes at cool_address are
; 00 43
INC cool_address+1 ; Increment 2nd byte of address
; At this point, the 2 bytes at cool_address are
; 00 44
现在可以将标签 cool_address
赋予任何采用地址的指令,并且该指令将在地址 00
上运行。
这里我有一个问题,因为寄存器只有 8 位,我不能存储 16 位地址,所以我必须将它分成两个字节 es:
addr: %4300 将被划分为little endian
高字节:43
低字节:00
问题是我不能增加地址的高字节,只能增加低字节 34=]INC 指令.
例如:
LDA 00
ADC #01
STA %4300
编辑:
我想增加 内存地址 即 4300 美元但我只想增加前两个字节所以高字节,我不关心写一个值那个地址
示例:
LDA #00
ADC #1
; the result i want should be 00 and so on..
我该如何解决?
谢谢!
如果您想增加或更改地址的值 - 或任何数据 - 那么您需要知道该地址的地址。
乍一看这听起来有点令人困惑,但请记住,CPU 正在处理的所有内容都在其内存中 space 或寄存器中。
这包括编译器吐出的每条指令和值。因此,要增加地址的高字节($4300),您必须知道该数据的实际位置。
还有一点要知道,6502 是 'little-endian',因此指令先读取低字节,然后再读取高字节。所以在内存中,您的地址 00
实际上是 [=12=]
后跟 </code>.</p>
<p>现在,有许多不同的方法可以实现您的目标,但这里有一个简单的例子:</p>
<pre><code>cool_address: .res 2 ; We reserve 2 bytes somewhere in RAM
; and give it the label cool_address
; so we can easily access it.
...
LDA #[=10=] ; Put [=10=] into the Accumulator
STA cool_address ; Store the Accumulator in the 1st byte of address
LDA # ; Put into the Accumulator
STA cool_address+1 ; Store the Accumulator in the 2nd byte of address
; At this point, the 2 bytes at cool_address are
; 00 43
INC cool_address+1 ; Increment 2nd byte of address
; At this point, the 2 bytes at cool_address are
; 00 44
现在可以将标签 cool_address
赋予任何采用地址的指令,并且该指令将在地址 00
上运行。