Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Indirect addressing driving me crazy
2011-11-13 01:56
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
2011-11-13 03:46
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.
2011-11-13 03:51
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.
2011-11-13 12:23
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/
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Steel/SCS&TRC/G★P
Fungus/Nostalgia
stephan-a
Guests online: 102
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Diskmag Editors
1 Jazzcat  (9.4)
2 Magic  (9.4)
3 hedning  (9.2)
4 Newscopy  (9.1)
5 Elwix  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.036 sec.