0

In 8085 whatever address the stack pointer holds, we always start storing bytes from one less than this address . Eg. If SP holds 2008H. We will store 16-bit data at 2007 and 2006H. Why don't we store at 2008H itself? Aren't we wasting a memory location . Is there any specific reason behind this design ?

Urooj
  • 73
  • 1
  • 4
  • Am guessing here at 8085 micro-architecture...perhaps the stack pointer decrement can be accomplished during instruction-decode micro-cycle, before the first stack write cycle. Some versions of 8080-style instruction sets have various instruction cycle times. – glen_geek May 12 '20 at 16:31

2 Answers2

0

Eg. If SP holds 2008H. We will store 16-bit data at 2007 and 2006H. Why don't we store at 2008H itself?

The next step is we decrement SP to 2006h.

So what would happen if the next time we want to push data, we stored the new data at 2006h?

We'd clobber the data we stored there previously.

The Photon
  • 126,425
  • 3
  • 159
  • 304
0

The Stack Pointer in an 8085 contains the address of the last valid data that was pushed onto the Stack. When new data is pushed, this data should not be overwritten (obviously) and the Stack Pointer is decreased by 1 (or two when writing 16-bit data) before writing new data.

There will not be any wasted memory locations if the Stack Pointer is initialized to a value 1 higher than the top of the Stack.

StarCat
  • 1,124
  • 1
  • 7
  • 13