The 6502 instructions nobody uses!

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

The 6502 instructions nobody uses!

Post by Dwedit »

In my tests, these instructions were used infrequently:

Code: Select all

1e	ASL $nnnn,X
41	EOR ($nn,X)
59	EOR $nnnn,Y
5E	LSR $nnnn,X
81	STA ($nn,X)
a1	LDA ($nn,X)
b8	CLV
And these instructions were used VERY VERY infrequently:

Code: Select all

21	AND ($nn,X)
56	LSR $nn,X
61	ADC ($nn,X)
E1	SBC ($nn,X)
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

Interesting !
I'm not very sursprited, tough. The only surprise is LSR $nn,X, which I think would be used decently frequently. The whole ($xx,X) adressing mode isn't very usefull, exept if you have a table of pointer in Zero Page, which just doesn't happen often. I only use this in my sound codes.
dvdmth
Posts: 354
Joined: Wed Mar 22, 2006 8:00 am

Post by dvdmth »

How often is SED ($F8) used??

The only time I saw (zp,X) used was in a routine which parsed simultaneously through two data blocks. The code used (zp),Y to dereference one pointer and (zp,X) (with X always set to zero) to dereference the other. Obviously, the latter pointer had to be incremented after every read, while the first didn't need adjustment (until Y overflowed of course).

I sure would love to know whose idea it was to have (zp,X) as an addressing mode...
"Last version was better," says Floyd. "More bugs. Bugs make game fun."
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Forgot that one, that's also in the VERY VERY infrequently used section.

ZP,X is used very frequently on the Atari 2600, which has 128 bytes of IO ports, then 128 bytes of RAM in the zero page. Then it's all mirrored for the 01xx stack page.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

At least one multiplayer game that I have developed for NES uses a lot of zp,X addressing. Much of the game state is stored in a bunch of two-element arrays, one for each player.
Post Reply