标题基本上就是它。
我有需要开和关的灯。有一个按钮指示它应该是哪一盏灯。因此,当按钮被按下或未被按下时,我修改了一个包含该灯的PORT地址的变量。要开灯,我必须在那个地址存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。
我该怎么做?
发布于 2011-09-14 11:35:17
假设这是HC11,您可能希望使用indexed addressing,如下所示:
LDX PoSelect ; load address from PoSelect to IX register
STAA 0,X ; store contents of A register to the address in IXhttps://stackoverflow.com/questions/7410538
复制相似问题