[Coco] Assembly language question: The stack
Salvador Garcia
salvadorgarciav at yahoo.com
Wed Oct 24 21:34:17 EDT 2018
Hi all,
I am studying assembly language for the 6809 and have a question about the stack.
>From what I have been reading, I deduced the following:
When I push a byte the stack pointer decrements and then the byte is stored at that location
When I pull a byte, the byte is recovered from the current pointer location and then the pointer is incremented.
I'll pause here in case any of the above needs correction.
This means that the stack pointer points to the top of the stack where the last pushed byte is located. If I initialize the stack pointer to, say $4000, for example and I do the first push, what happens to location $4000. If I am correct in how the stack works, the first byte of the stack is always wasted because the push causes the pointer to decrement before the value is stored.
Am I correct about this?
Also, I assume it is the developer's responsibility to manage the stack, that is, there is no way to know if the stack gets too big or if I do too many pulls and end up pulling from an empty stack. Is that right?
Thanks all, especially to those who are on CoCoTalk answering questions about Steve Bjork's assembly course :-)
Salvador
More information about the Coco
mailing list