Engeliron Posted September 15, 2017 Share Posted September 15, 2017 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. Quote Link to comment Share on other sites More sharing options...
vidak Posted September 16, 2017 Share Posted September 16, 2017 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 Quote Link to comment Share on other sites More sharing options...
vidak Posted September 16, 2017 Share Posted September 16, 2017 WAIT INDIRECT Y USES THE ZERO PAGE MY BAD Sent from my ASUS_Z012D using Tapatalk Quote Link to comment Share on other sites More sharing options...
vidak Posted September 16, 2017 Share Posted September 16, 2017 Wait you're still wrapping around the entire zero page space. Normally you just go $80, and $81, then LDA ($80), Y Sent from my ASUS_Z012D using Tapatalk Quote Link to comment Share on other sites More sharing options...
alex_79 Posted September 16, 2017 Share Posted September 16, 2017 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": 2 Quote Link to comment Share on other sites More sharing options...
carlsson Posted September 22, 2017 Share Posted September 22, 2017 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. Quote Link to comment Share on other sites More sharing options...
TheHoboInYourRoom Posted September 23, 2017 Share Posted September 23, 2017 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. Quote Link to comment Share on other sites More sharing options...
tokumaru Posted September 23, 2017 Share Posted September 23, 2017 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! 1 Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted October 7, 2017 Share Posted October 7, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.