How do i store the contents of a register, to an address specified by a variable in memory?
-
29-10-2019 - |
Frage
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???
Keine korrekte Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow