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 > LDA (ZP,x)
2016-05-16 14:31
oziphantom

Registered: Oct 2014
Posts: 478
LDA (ZP,x)

Has anybody ever used this opcode and if so what for?
 
... 33 posts hidden. Click here to view all posts....
 
2016-05-16 16:28
MagerValp

Registered: Dec 2001
Posts: 1056
It's one of those "seemed like a good idea at the time" opcodes. Everyone would have been happier if we got (ZP),x instead.
2016-05-16 17:10
Peiselulli

Registered: Oct 2006
Posts: 81
(zp) is also missing
2016-05-16 17:19
Oswald

Registered: Apr 2002
Posts: 5021
another opcode would have been more useful, fex sty abs,x stx abs,y. or the mentioned (),x
2016-05-16 17:31
Jammer

Registered: Nov 2002
Posts: 1289
Or txy/tyx ;)
2016-05-16 18:43
tlr

Registered: Sep 2003
Posts: 1716
It's useful for channelized implementations like a music player. If you have your voice structures in zp you can address your data pointers using the regular 0,7,14 index for instance. I've used this method in Breakage.

The fact that the 6502 instruction set is so asymmetric is a large part of making it fun to code for IMO.
2016-05-16 18:46
cadaver

Registered: Feb 2002
Posts: 1153
tlr: That's a cool usage. Though you'll have the downside of having to manipulate the ZP pointer every time you want to access successive bytes (for example note, instrument, duration) from music data, instead of just incrementing Y.
2016-05-16 18:54
Slammer

Registered: Feb 2004
Posts: 416
I really miss add. (adc without carry)
2016-05-16 18:59
lft

Registered: Jul 2007
Posts: 369
I use it exactly like that in my latest playroutine.

Another use is when you'd really want to do (zp), but you need the y register for something else, and you have a known constant in x. Then you can do (zp-constant,x).

Finally, cmp (0,x) is a convenient 6-cycle 2-byte nop (although it clobbers the flags).
2016-05-16 19:15
Bitbreaker

Registered: Oct 2002
Posts: 500
used it a few times as substitute for lda (zp) when x is fix and known lda (<(zp - x_),x) (lda (zp),y is cheaper however to do so)
Now also ponder about lax (zp,x) which could give some x = f(x) results :-D But it could also work as ldx (zp) with the above scenario whenever you can allow to clobber x.
2016-05-16 19:17
lft

Registered: Jul 2007
Posts: 369
Another thing I've had in mind, but never actually implemented, is this: Suppose you're doing something like kefrens bars with open sideborders. You repeat the last line of a row of characters and modify the font on the fly. But in the borders, you repeat sprite data, let's say one sprite on either side. That means you have a single graphics buffer consisting of 46 bytes, but those bytes are distributed somewhat irregularly in RAM. So make a table in zp consisting of 46 pointers to them. Then use (zp,x) in the drawing operations. You can even access neighbouring cells with (zp-2,x) and (zp+2,x).
Previous - 1 | 2 | 3 | 4 | 5 - Next
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
Sentinel/Excess/TREX
Acidchild/Padua
stephan-a
Alakran_64
Clown
Krill/Plush
Leo/Lepsi De
Didi/Laxity
Freddie
Guests online: 142
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 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Musicians
1 Vincenzo  (9.8)
2 Rob Hubbard  (9.7)
3 Stinsen  (9.7)
4 Jeroen Tel  (9.6)
5 Linus  (9.6)

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