edited by
16,801 views
57 votes
57 votes

Consider a processor with byte-addressable memory. Assume that all registers, including program counter (PC) and Program Status Word (PSW), are size of two bytes. A stack in the main memory is implemented from memory location $(0100)_{16}$ and it grows upward. The stack pointer (SP) points to the top element of the stack. The current value of SP is $(016E)_{16}$. The CALL instruction is of two words, the first word is the op-code and the second word is the starting address of the subroutine (one word = 2 bytes). The CALL instruction is implemented as follows:

  • Store the current value of PC in the stack
  • Store the value of PSW register in the stack
  • Load the statring address of the subroutine in PC

The content of PC just before the fetch of a CALL instruction is $(5FA0)_{16}$. After execution of the CALL instruction, the value of the stack pointer is:

  1. $(016A)_{16}$
  2. $(016C)_{16}$
  3. $(0170)_{16}$
  4. $(0172)_{16}$
edited by

3 Answers

Best answer
85 votes
85 votes

First we have to consider here memory is byte-addressable 

The CALL instruction is implemented as follows:

  • Store the current value of PC in the stack

    PC is $2$ bytes it means when we store pc in stack it will increase by $2$  
    So current value of SP is $(016E)_{16} +2$
     
  • Store the value of PSW register in the stack
    PSW is $2$ byte it means when we store psw in stack it will increase by $2$  
    So current value of SP is $(016E)_{16}+2+2 =(0172)_{16}$

Correct Answer: $D$

edited by
0 votes
0 votes

Stack in main memory grows upwards. This statement tells that the stack pointer decrements on adding new elements to stack. For more details plz refer to hamacher 2nd chapter. So i think it will work as : 

  • Store the current value of PC in the stack 

    pc is 2 byte it means when we store pc in stack it will deccrease by 2   
    so current value of SP is (016E)16 -2 

     
  • Store the value of PSW register in the stack 
    psw is 2 byte it means when we store psw in stack it will decrease by 2   
    so current value of SP is (016E)16 -2-2 =(016A)16 
     
Answer:

Related questions

26 votes
26 votes
5 answers
3
go_editor asked Feb 12, 2015
14,097 views
Consider the following routing table at an IP router:$$\begin{array}{|l|l|l|} \hline \textbf {Network No} & \textbf {Net Mask} & \textbf{Next Hop} \\\hline \text {128.96...