News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

[SM] About the stack

Started by monktroid, May 03, 2017, 03:35:05 PM

Previous topic - Next topic

monktroid

Hiya,

I've got some questions about the stack.

1) In Geiger, is there a way to view the values in stack while debugging?

2) say I have a bunch of words in the stack

--TOP--------
#$F000
--------------
#$BAAA
-------------
#$FOBA
--BOTTOM--

say I run the following:

SEP #$20
LDA #$12
PHA
REP #$20


am I right in thinking the stack is gonna get scrambled? is the result as follows:

--TOP--------
#$12F0
--------------
#$00BA
--------------
#$AAFO
--------------
#$BA??
--BOTTOM--
(where ? is literally garbage)

What I'm asking is - basically - is pushing to the stack in 8-bit mode an absolute NO NO?

Quote58

#1
Well one of the really cool things about assembly is that the stack is literally just a regular data structure located in work ram (as opposed to higher languages that have both the standard data structure, as well as an often inaccessible stack behind the scenes that manages call and return pointers, local variables, etc. in stack frames. In snes assembly the stack that manages call and return pointers can be accessed in ram, and even has special operations that let you know where you are in the stack). It's fully accessible and you can see it by going into geigers, using the open hex button, choosing wram, and going to $7E1F5B. It's also totally fine to push to the stack in 8bit, so long as you retrieve it in 8bit as well.

Conveniently enough, a youtube channel I like posted a video explaining how the stack is used in the super Nintendo like yesterday,
https://www.youtube.com/watch?v=IWQ74f2ot7E

monktroid

thanks Quote, that's an awesome response!