Assembly 递增地址程序集MOS6502的前两个字节
这里我遇到了一个问题,因为寄存器只有8位,我无法存储16位地址,所以我必须将其分成两个字节E: 地址:%4300将被划分为小端点 高字节:43 低字节:00 问题是我不能使用简单的INC指令增加地址的高字节,而只能增加低字节 例如:Assembly 递增地址程序集MOS6502的前两个字节,assembly,6502,Assembly,6502,这里我遇到了一个问题,因为寄存器只有8位,我无法存储16位地址,所以我必须将其分成两个字节E: 地址:%4300将被划分为小端点 高字节:43 低字节:00 问题是我不能使用简单的INC指令增加地址的高字节,而只能增加低字节 例如: LDA $4300 ADC #01 STA %4300 编辑: 我想增加内存地址,即$4300,但我只想增加前两个字节,因此高位字节,我不想为该地址写入值 例如: LDA #$4300 ADC #1 ; the result i want should be $
LDA $4300
ADC #01
STA %4300
编辑:
我想增加内存地址,即$4300,但我只想增加前两个字节,因此高位字节,我不想为该地址写入值
例如:
LDA #$4300
ADC #1
; the result i want should be $4400 and so on..
我怎样才能解决这个问题
谢谢 如果要增加或更改地址或任何数据段的值,则需要知道该地址的地址 乍一看,这听起来可能有点混乱,但请记住,CPU正在处理的所有内容要么在其内存空间中,要么在寄存器中 这包括编译器输出的所有指令和值。因此,要增加地址的高位字节($4300),您必须知道数据的实际位置 还有一件事要知道,6502是“小端”,所以指令先读取低字节,然后读取高字节。所以在内存中,您的地址
$4300
实际上是一个$00
,后跟一个$43
现在,有许多不同的方法来实现您的目标,但这里有一个简单的例子:
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 #$00 ; Put $00 into the Accumulator
STA cool_address ; Store the Accumulator in the 1st byte of address
LDA #$43 ; Put $43 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\u address
赋予任何带有地址的指令,并且该指令将在地址$4400
上运行。为什么不能将Ross的答案与两个广泛分离的地址一起使用,例如inc$4300
/bne
/inc$4400
?哪两个地址包含两个字节的数据,您希望初始和最终状态是什么?