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: 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
2011-11-13 03:46
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.
2011-11-13 03:51
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.
2011-11-13 12:23
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/
2024-08-20 14:36
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.
2024-08-20 15:25
oziphantom

Registered: Oct 2014
Posts: 490
@Digger
see LDA (ZP,x) for details
2024-08-22 12:12
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. ;)
2024-08-24 22:22
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.
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
Mr. SID
Knight Rider/TREX 🦖
tlr
The Syndrom/TIA/Pret..
Airwolf/F4CG
TMA/Abyss-Connection
Bob/Censor Design
E$G/HF ⭐ 7
Bieno/Commodore Plus
pcollins/Quantum
Mojzesh/TGR🇬🇧
TheEnemy/TREX/THD
Rub_0201
Guests online: 86
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.6)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Sprite Bukkake 2  (9.6)
9 Uncensored  (9.6)
10 Comaland 100%  (9.6)
Top onefile Demos
1 Layers  (9.7)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 Morph  (9.5)
7 Dawnfall V1.1  (9.5)
8 Libertongo  (9.5)
9 Katzen-Video.mp4  (9.5)
10 Onscreen 5k  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Performers  (9.3)
4 Fairlight  (9.3)
5 Triad  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 Veto  (9.6)
4 The Sarge  (9.6)
5 Facet  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.039 sec.