| |
cbmeeks
Registered: Oct 2005 Posts: 72 |
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: 634 |
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: 72 |
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: 490 |
@cbmeeks: next time you can simply look it up from aay documentation.
http://unusedino.de/ec64/technical/aay/c64/ |