如何将寄存器的内容存储到内存中变量指定的地址?

发布于 2024-12-04 08:25:13 字数 1035 浏览 0 评论 0原文

标题基本就是这样了。

我有需要打开和关闭的灯。有一个按钮可以指示它应该是哪种灯。因此,当按下或未按下按钮时,我会修改包含该灯的端口地址的变量。要打开灯,我必须在该地址存储 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

且行且努力 2024-12-11 08:25:13

假设这是 HC11,您可能需要使用索引寻址,像这样的东西:

LDX         PoSelect      ; load address from PoSelect to IX register
STAA        0,X           ; store contents of A register to the address in IX

Assuming this is HC11, you might want to use indexed addressing, something like:

LDX         PoSelect      ; load address from PoSelect to IX register
STAA        0,X           ; store contents of A register to the address in IX
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文