What is a stack pointer in 8085?

It is a special purpose 16-bit register that stores the address of the “top of stack.
“Stack” is a LIFO “Last In First Out” data structure. You can think of it like a box opened at the top. You can put or take items only from the top. So, the item that you placed last will be the one taken out first, right!
“8085” provides the “stack pointer” which gives the address of the “top of stackSo, whenever you want to store an item it stack, you just store it at the address provided by the stack pointer.
Let's play with 8085 Stack Pointer instructions to get the insight.
(NOTE: Comments are denoted by a '#’ in 8085, just like in bash-scripting)

INITIALIZING STACK POINTER :
  1. LXI SP,16bit
  2.  
  3. #16bit represents the 16 bit address. Say, 5000 in HEX code.
  4.  
  5. LXI SP, 5000H
PUSH & POP OPERATIONS :
  1. LXI SP,5000H
  2. LXI H,3500H
  3.  
  4. PUSH H
  5. #Pushes value of H to stack.
  6.  
  7. POP H
  8. #Retrieves back the value of H.
( Image - Stack Data Structure )
{Source: Tutorials Point via Google Image Search }
Thanks.
Next Post Previous Post
No Comment
Add Comment
comment url