| |
cbmeeks
Registered: Oct 2005 Posts: 78 |
Indirect addressing driving me crazy
Why does this not work? I have moved my screen location to $3800. So that I may draw down the right side (for a horizontal scroller), I need to skip every 40 chars. So I thought I would do it in a lookup table. But I can't get this to work.
ldy #0
ldx #5
lda TileCharLookupA, x // lookup for char in 4x4 tile. X contains tile #
sta (ScreenRightSide), y
.pc = $C100 "Various Lookups"
TileCharLookupA: .for(var i=0; i < 40; i++) .byte i * 4
TileCharLookupC: .for(var i=0; i < 40; i++) .byte [i * 4] + 2
ScreenRightSide: .word $3827
Now, if I put $3827 (position 39,0) in zeropage (like $4B/$4C) and STA ($4B), y it works.
Can the indirect addressing only work in ZP?
Thanks |
|
| |
Martin Piper
Registered: Nov 2007 Posts: 726 |
Instructions in the form:
LDA (XX),y
Reads the two byte lo/hi address in zero page starting at XX. Then add on Y to the address.
It only works in zero page since it only uses two bytes for the instruction.
This is different to the form:
STA XXXX,y
Where it takes the 16 bit address straight from the instruction then adds on Y, so it uses three bytes in total.
|
| |
cbmeeks
Registered: Oct 2005 Posts: 78 |
Ah. I knew that had to be true. Despite not being able to find anything confirming it. Other than my own coding. lol
Thanks. At least I know to try a different path now. |
| |
Skate
Registered: Jul 2003 Posts: 495 |
@cbmeeks: next time you can simply look it up from aay documentation.
http://unusedino.de/ec64/technical/aay/c64/ |
| |
Digger
Registered: Mar 2005 Posts: 438 |
The infamous: lda ($nn,x) or sta ($nn,x)
Any cool examples of Indirect addressing in demos?
Which demos/effects use that and how?
AFAIR it was somehow useful for Kefrens bars. |
| |
oziphantom
Registered: Oct 2014 Posts: 490 |
@Digger
see LDA (ZP,x) for details |
| |
Frantic
Registered: Mar 2003 Posts: 1648 |
Quote: The infamous: lda ($nn,x) or sta ($nn,x)
Any cool examples of Indirect addressing in demos?
Which demos/effects use that and how?
AFAIR it was somehow useful for Kefrens bars.
Doesn't seem to relate to the initial post of this topic? At most it seems to address it veeery indirectly. ;) |
| |
Monte Carlos
Registered: Jun 2004 Posts: 363 |
Unroll the loop, it's a 4x4 char. You don't need the indirect addressing, here. Just repeat the code section 4 times. |