+Dave C Posted September 7, 2021 Share Posted September 7, 2021 Note: I'm assuming this is all old news (I can see threads about the stack on these forums and various stack manipulations in old games)... anyway... Working through some code I've been working I realized I had a bug where I wasn't initializing the stack pointer ...In the case of the code I had written ...somehow in Stella this all turned out to somehow do what I had originally intended... so I didn't notice at first... What I'm wondering about is if the stack is pointing at 00 (i.e., not RAM) are pha/pla going to have the same effect as lda/sta. When I wrote some test code (below) the pla and lda never return the same value. With actual hardware I assume the TIA wouldn't know/care whether an lda/pla is trying to address it...? lda #$ff ldx #$00 txs pha pla lda $00 Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted September 7, 2021 Share Posted September 7, 2021 Use the "CLEAN_START" macro on startup. It does everything to set the machine into a "clean" state in only 8 bytes or so. Many addresses are write-only, so I guess you'd effectively get randomness (whatever is on the data bus) when trying to read them. Look into Stella "developer mode" for assistance in finding these sort of hard-to-find bugs. Quote Link to comment Share on other sites More sharing options...
+Dave C Posted September 8, 2021 Author Share Posted September 8, 2021 Thanks. Reading the Stella programming guide it looked like lda $00 would read CXM0P - which made me wonder if a pla (with SP of $ff) should be expected to return the same value of the lda. Either way I'd rather use CLEAN_START and it will save me a few instructions - thanks! Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted September 8, 2021 Share Posted September 8, 2021 PLA and LDA will always return the same value if they read from the same address. CXM0P uses only two bits, the other six are undefined (but probably 0). 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.