-1

If in 8085, SP=0000H, which registers in which memory locations will be stored if PUSH B instruction is executed?

Will it be that register B content will be stored at FFFF and C at FFFE?

js306
  • 11
  • 2

2 Answers2

1

(Edited)

Ahhh, I see the question now.

This is not normally a situation that would arise in real-world code, of course. Code is generally loaded starting from low memory in this architecture, with data and stack above, so the program would be overwritten before you could provoke this situation.

There is no indication in the official Intel data sheets, or in any other documentation I've found, that an interrupt is triggered on stack pointer underflow.

So I would indeed expect that the instruction increments/decrements the SP register without any attempt to check for overflow, so memory addressing will indeed go from 0000 to FFFF. Since the behavior is unspecified, there's no reason for the manufacturer to waste gates testing for this case and handling it in any other way.

However, the official answer may be that this is Unspecified Behavior. To nail that down, you would have to find a statement from Intel, who originally designed this architecture. I've done a bit of searching (as noted above) but I simply don't see anything absolute.

Since I can't see any reason this would arise under normal circumstances, or any use for provoking it... I'm tempted to reduce all of the above to the Zen summation of "Mu."

keshlam
  • 7,931
  • 2
  • 19
  • 33
  • Keshlam it would be good if you could tell the answer. 'Websearching 8085 instruction set' I have already tried. – js306 Mar 16 '14 at 15:04
  • I did provide the answer in addtion to mentioning the search, based on information from [the first hit](ftp://ftp.unilins.edu.br/dib/2006_EE_140%20-%20MICROPROCESSADORES/8085/instruction_set_8085.pdf) on that search. (First item on page 3, or search the PDF for "PUSH".) – keshlam Mar 16 '14 at 16:44
  • yes it says that when push instruction will be encountered, contents of SP reg will be decremented and the contents of higher order reg will be pushed into that loc, then again SP will be decremented and contents of lower order reg will be put into this loc. Now my ques is, since SP is already 0000, how do i decrement it? Do I make it FFFF(the last mem loc)? – js306 Mar 16 '14 at 17:04
  • thanks....yes I know this situation would not arise...but since I have got this question as part of an.assignment my instructor gave me and I too read quite a lot but could not find anything definite...Thanks! – js306 Mar 16 '14 at 19:51
0

So in order to answer this question, we need to really understand how the PUSH instruction actually works in 8085. Consider the following situation:

Register B has contents 0xAA
Register C has contents 0xBB
SP = 0x0000

Now, Let us assume the instruction encountered is PUSH. The PUSH instruction first decreases the stack pointer SP

B -> 0xAA
C -> 0xBB
SP -> 0xFFFF

and then stores the higher order register, decrements again and then stores the lower order registers as well.

B -> 0xAA
C -> 0xBB
0xFFFF -> 0xAA
0xFFFE -> 0xBB
SP -> 0xFFFE