如何将寄存器的内容存储到内存中变量指定的地址?
标题基本就是这样了。
我有需要打开和关闭的灯。有一个按钮可以指示它应该是哪种灯。因此,当按下或未按下按钮时,我会修改包含该灯的端口地址的变量。要打开灯,我必须在该地址存储 00 美元。例如:
;**********************************************************
;LED1on subroutine
;
; This will turn LED 1 on, and then return.
LED1on
LDAA #$00 ; Load $00 into accumulator a (the value to turn the light on)
STAA $PORTA ; Store the loaded value into PORTA, PORTA is a MACRO that =$0000
RTS ; Return to sender
所以我想做的是有一个变量,PoSelect=$0000。并用它来代替。
;**********************************************************
;LED1on subroutine
;
; This will turn LED 1 on, and then return.
LED1on
LDAA #$00 ; Load $00 into accumulator a (the value to turn the light on)
STAA PoSelect ; PoSelect is a variable that contains a port address
RTS
然而,这只是将“累加器 a”的内容存储到变量 PoSelect 中。我想要做的是将“累加器 a”的内容存储到变量 PoSelect 中存储的地址中。本质上像指针一样使用变量 PoSelect。
我该怎么办?
The title is basically it.
I have lights that i need to switch on and off. There is a button that dictates which light it should be. So when the button is pressed or not pressed, i modify a variable that contains the PORT address of that light. To turn a light on i have to store $00 at that address. For instance:
;**********************************************************
;LED1on subroutine
;
; This will turn LED 1 on, and then return.
LED1on
LDAA #$00 ; Load $00 into accumulator a (the value to turn the light on)
STAA $PORTA ; Store the loaded value into PORTA, PORTA is a MACRO that =$0000
RTS ; Return to sender
So what i want to do is have a variable, PoSelect=$0000. And use it instead.
;**********************************************************
;LED1on subroutine
;
; This will turn LED 1 on, and then return.
LED1on
LDAA #$00 ; Load $00 into accumulator a (the value to turn the light on)
STAA PoSelect ; PoSelect is a variable that contains a port address
RTS
This however just stores the contents of 'accumulator a' into the variable PoSelect. What i want to do, is store the contents of 'accumulator a' into the address that is stored at the variable PoSelect. Essentially using the variable PoSelect like a pointer.
How do i do that???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设这是 HC11,您可能需要使用索引寻址,像这样的东西:
Assuming this is HC11, you might want to use indexed addressing, something like: