I have a doubt on stack implementation in 8051 and I don't even know if I'm asking it in right way so please pardon me. I've been reading stack implementation in 8051 and many textbooks and references it's mentioned that when we push the data then first SP is incremented and then the value is stored. So I've understood it like the following using an example :
push A // if by default SP is pointing at address x then the value of A is stored in x+1 location ?
Is it correct ?
EDIT:
And if I want to access the value 'A' after pushing it by register or pointer then do I have to access from 'x+1' location ?
Best Answer
You are right.
There are two kind of stack type. full stack and empty stack.
And 8051 uses the former, full stack. For example, when the 8051 is initialized, SP will be initialized to 07h. If you immediately push a value onto the stack, the value will be stored in internal RAM address 08h.