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 ?


1 Answer 1


You are right.

There are two kind of stack type. full stack and empty stack.

Full stack: A full stack is where the stack pointer points to the last data item written. A push will increment the stack pointer and store the value.

Empty stack: Empty stack is where the stack pointer points to the first free slot. A push will store the value, and increment the stack pointer.

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.