Jump to content
IGNORED

Indirect,y question


Engeliron

Recommended Posts

Using the Easy 6502 to figure out indirect,y I stumbled across something that I can't figure out.

As an example I'll set address $FF with a value of #$FF. The address $00 with a value of #$FF. Finally set the 'y' reg with a value of #$01.

When I do a LDA ($FF),y should the lookup bytes be $00 then $FF? Then this gives us a final address of $FFFF plus the 'y' reg of #$01 which would be address $0000?

Can you have wrap around with the 2 byte value? What should the answer be?

Also, why does indirect,x normally take 1 more cycle than indirect,y?

Any information would be greatly appreciated.

Link to comment
Share on other sites

From my understanding I think you might have the concept correct.

 

This forum post from 6502.org seems to confirm what you're saying:

 

http://forum.6502.org/viewtopic.php?f=2&t=2195

 

However I'm not sure about wrapping around the entire memory space.

 

You're wrapping around the entire memory space twice: first in the memory addresses storing the pointer, and then when you increment by y in the actual operation.

 

I'm a newbie, so I'm not sure about this, but I wouldn't try and wrap around the entire memory space

 

Hopefully this is correct?

 

Sent from my ASUS_Z012D using Tapatalk

Link to comment
Share on other sites

As an example I'll set address $FF with a value of #$FF. The address $00 with a value of #$FF. Finally set the 'y' reg with a value of #$01.

When I do a LDA ($FF),y should the lookup bytes be $00 then $FF? Then this gives us a final address of $FFFF plus the 'y' reg of #$01 which would be address $0000?

I think your description is correct: the pointer is in zero page and wraps around to $00 after $FF, while the destination address can cross a page (after the Y index is added) and since in the example the address (without the index) was in the last page ($FF), the resulting address after the index is added is in page 0.

 

Anyway, in the case of the 2600, you can't use address $FF as the operand of an (indirect),y instruction, because address $00 (which would be the high byte of the pointer) is mapped to a TIA register.

 

Also, why does indirect,x normally take 1 more cycle than indirect,y?

Because the cpu performs an extra "dummy" memory access to zero page in the case of (indirect,x), thus taking one more cycle to execute the instruction.

For example when executing a "LDA ($80,X)", with X=2, the cpu reads memory $80 first (the data is discarded), then adds the X index and reads the pointer from $82 and $83, and finally reads the value from the destination address.

 

See chapter 6 of the "MCS6500 microcomputer family programming manual":

  • Like 2
Link to comment
Share on other sites

Wow! Is the (indirect,X) addressing mode used on the Atari 2600? That tends to be one of the greatest mysteries in 6502 programming, when and for what cause use that addressing mode. The mode (indirect),Y though is used almost all the time, at least on other platforms.

I'm given to understand that it is used, but somewhat rarely.

Link to comment
Share on other sites

Is the (indirect,X) addressing mode used on the Atari 2600? That tends to be one of the greatest mysteries in 6502 programming, when and for what cause use that addressing mode.

(indirect,X) is useful when accessing collections of streams of data, such as the individual sound channels of a song. OK, that's not the best example of usefulness on the 2600, which only has 2 sound channels, but still. Anyway, there must be other good uses for arrays of pointers!

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

The basic reason that Peddle's MOS engineers included (indirect,x) and (indirect),y addressing modes for 6502 was to make their new processor more attractive to potential buyers - what it lacked when compared to the 6800's number of registers, it could make up for via "virtual" registers. Up to 128 of them in zero page. Is (indirect,x) useful? Not by much, when you consider that bankswitching schemes and such have made available memory space virtually unlimited.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...