The registers on the NES are all 8-bit, so they can't represent absolute addresses (and the CPU doesn't combine them in any way to form a 16-bit value), so the only way to do this is using indirect indexed addressing.Doogie wrote:How do I tell the NES (In asm) to store a value at an address that is held in a variable
To do this, the address in question must be stored in a zero page location (not in a register, like in your example). Unfortunately, the 6502 will always add the Y register to this address, so if you don't plan on using indexes, you have to set it to 0.
Code: Select all
;set the destination address
lda #$3F
sta $00
lda #$04
sta $01
ldy #$00
;write the value
lda #$55
sta ($00), yCode: Select all
;set the destination address
lda #$00
sta $00
lda #$04
sta $01
ldy #$3F
;write the value
lda #$55
sta ($00), y