13,303 views

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}$

### 4 Comments

I think it will be 5FA4

as memory is Byte Addressable, and we increment PC as the size of instruction (which is 2 words = 4B)

Hence, 5FA0 + 4 = 5FA4
I think

Question contain 2 pc.

One is of instruction(whose current pc value= (5AF0)base16 ) and

other is of stack(whose current pc value =.(016E)base16).

They are asking value  of stack pc.

@Overflow04 i.e stack pointer.

## 2 Answers

Best answer

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$

### 4 Comments

Yes preety u can do , memory is byte addressable so for one byte stack pointer will move one place
For addition doubts,

0000 0001 0110 1110
0000 0000 0000 0010
-----------------------------
0000 0001 0111 0000, which is $(0170)_{16}$

Now, when we add 0010 to this again, only the block will undergo changes, especially the last two bits, giving us:

0000 0001 0111 0010, which is $(0172)_{16}$
why isn’t starting address of the subroutine added onto the stack ?

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

### 2 Comments

you saw right sentence but implemented in totally opposit way. generally stack is growing downward that's why we decrement the address of top. but here stack is expanding upward. so we have to add bytes for new top. not minus
in question they have mentioned ..stack is starting from (0100) ..and current value is (016E) so it's incrementing while pushing the elements!
Answer:

33 votes
4 answers
1
26 votes
5 answers
2
11,601 views
46 votes
4 answers
3
22 votes
5 answers
4
10,412 views