Open In App

GATE | GATE-CS-2015 (Set 2) | Question 65

Like Article
Like
Save
Share
Report

Consider a processor with byte-addressable memory. Assume that all registers, including Program Counter (PC) and Program Status Word (PSW), are of size 2 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 starting 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
A.(016A)16
B.(016C)16
C.(0170)16
D.(0172)16
(A) A
(B) B
(C) C
(D) D


Answer: (D)

Explanation:

The current value of SP is (016E)16

The value of SP after following operations is asked 
in question

 • Store the current value of PC in the stack.
This operation increments SP by 2 bytes as size
of PC is given 2 bytes in question.  
So becomes (016E)16 + 2  = (0170)16

• Store the value of PSW register in the stack.
This operation also increments SP by 2 bytes as size
of PSW is also given 2 bytes.
So becomes (0170)16 + 2  = (0172)16

• Load the starting address of the subroutine in PC. 
The Load operation doesn't change SP.

So new value of SP is  (0172)16 


Quiz of this Question


Last Updated : 10 Nov, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads