vdub_bobby Posted January 27, 2005 Share Posted January 27, 2005 I'm trying to wrap my head around indexed indirect addressing. i.e., lda (ZP,X) - can someone tell me what it might be used for? I know what it does, I'm just having a hard time figuring out what situations it might be useful for. Quote Link to comment https://forums.atariage.com/topic/63941-use-for-indexed-indirect-addressing/ Share on other sites More sharing options...
Thomas Jentzsch Posted January 27, 2005 Share Posted January 27, 2005 - can someone tell me what it might be used for? Theoretically it might be useful, but I have never used it (except for wasting time efficiently) . Quote Link to comment https://forums.atariage.com/topic/63941-use-for-indexed-indirect-addressing/#findComment-785560 Share on other sites More sharing options...
vdub_bobby Posted January 27, 2005 Author Share Posted January 27, 2005 - can someone tell me what it might be used for? Theoretically it might be useful, but I have never used it (except for wasting time efficiently) . I guess what I am confused about is this: You use 'lda (ZP,X)' to load one byte from ROM (or RAM, I suppose). But you need two bytes of RAM (ZP+X, ZP+X+1) to get this one byte - so wouldn't it be easier to just store that one byte in RAM in the first place? Plus the fact that if you want to loop you have to do it in increments of 2 (unless your data is arranged super crazy). Say you want to loop like this... ldy #4 ldx #8 Loop lda (ZP1,X) sta ZP2,Y;this is really lda $00NN,Y dey dex dex bpl Loop But that takes 10 bytes for the pointers plus 5 bytes for the ZP storage (unless you are storing to TIA registers or something). Plus all the overhead to setup all the pointers correctly. Hmmm...I can kinda see how it might be useful. But I gotta think that the overhead involved in setting up those pointers plus the fact that it chews up a lot of RAM offsets whatever value it has. Or maybe...I dunno. Quote Link to comment https://forums.atariage.com/topic/63941-use-for-indexed-indirect-addressing/#findComment-785578 Share on other sites More sharing options...
Robert M Posted January 27, 2005 Share Posted January 27, 2005 Its one of the poor design decisions in the 650x family. That addressing mode would have been great for the JMP and JSR instructions to implement a CASE statement like structure. But, the designers put it in only for Loads and Stores etc, and I have never found a use for it that can not be done better another way. Wasted transistors that could have done something more useful. Quote Link to comment https://forums.atariage.com/topic/63941-use-for-indexed-indirect-addressing/#findComment-785587 Share on other sites More sharing options...
vdub_bobby Posted January 27, 2005 Author Share Posted January 27, 2005 Its one of the poor design decisions in the 650x family. That addressing mode would have been great for the JMP and JSR instructions to implement a CASE statement like structure. But, the designers put it in only for Loads and Stores etc, and I have never found a use for it that can not be done better another way. Wasted transistors that could have done something more useful. Searching Google, I found this somewhat amusing explanation/description of indexed indirect: What about Indexed Indirect? This essay has concerned itself almost exclusively with the Indirect Indexed -- or (Indirect), Y -- mode. What about Indexed Indirect -- (Indirect, X)? This is a much less useful mode than the Y register's version. While the Y register indirection lets you implement pointers and arrays in full generality, the X register is useful for pretty much only one application: lookup tables for single byte values. Even coming up with a motivating example for this is difficult, but here goes. Suppose you have multiple, widely disparate sections of memory that you're watching for signals. The following routine takes a resource index in the accumulator and returns the status byte for the corresponding resource. ; This data is sitting on the zero page somewhere resource_status_table: .word resource0_status, resource1_status, .word resource2_status, resource3_status, ; etc. etc. etc. ; This is the actual program code .text getstatus: clc ; Multiply argument by 2 before putting it in X, so that it asl ; produces a value that's properly word-indexed tax lda (resource_status_table, x) rts Why having a routine such as this is better than just having the calling routine access resourceN_status itself as an absolute memory load is left as an exercise for the reader. The last line pretty much sums it up.Source: http://www.stanford.edu/~mcmartin/retro/HL...ndirection.html Quote Link to comment https://forums.atariage.com/topic/63941-use-for-indexed-indirect-addressing/#findComment-785601 Share on other sites More sharing options...
vdub_bobby Posted January 27, 2005 Author Share Posted January 27, 2005 Its one of the poor design decisions in the 650x family. That addressing mode would have been great for the JMP and JSR instructions to implement a CASE statement like structure. But, the designers put it in only for Loads and Stores etc, and I have never found a use for it that can not be done better another way. Wasted transistors that could have done something more useful. Actually, come to think of it - I'm not super sharp when it comes to the stack, but couldn't you do the equivalent of a 'jmp (ZP,X)' with this: lda (ZP,X) pha dex lda (ZP,X) pha rts ? And this could look something like this: ;--this is on the zero page: JumpTable .word Routine1,Routine2,Routine3,Routine4 ... ldx #7 Loop ;--check condition beq ConditionTrue dex dex bpl Loop ... ;--elsewheres ConditionTrue lda (JumpTable,X) pha dex lda (JumpTable,X) pha rts Quote Link to comment https://forums.atariage.com/topic/63941-use-for-indexed-indirect-addressing/#findComment-785608 Share on other sites More sharing options...
vdub_bobby Posted January 27, 2005 Author Share Posted January 27, 2005 And this could look something like this:;--this is on the zero page: JumpTable .word Routine1,Routine2,Routine3,Routine4 ...[snip] Er, that won't work at all; that's completely messed up. That's why this is the newbies forum, right? Quote Link to comment https://forums.atariage.com/topic/63941-use-for-indexed-indirect-addressing/#findComment-785617 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.