1
votes

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)hex and it grows upward. The stack pointer (SP) points to the top element of the stack. The current value of SP is (016E)hex. The CALL instruction is of two words, the first word is the op-code and second word is the starting address of the subroutine (one word = 2 Bytes). The CALL instruction is implemented as follows:

  1. Store the current value of PC in the Stack
  2. Store the value of PSW register in the stack
  3. Load the starting address of the subroutine in PC

The content of PC just before the fetch of a CALL instruction is (5FA0)hex. After execution of the CALL instruction, the value of the stack pointer is

A. 016A

B. 016C

C. 0170

D. 0172

This question was asked in GATE 2015 Computer science.

I marked D as answer please help me to verify my answer, because I am not sure whether I have done it right or not.

Thanks in Advance.

1
Walk us through how you arrived at D so we can help you understand where you went wrong (or if you are correct)Gillespie
I did the same thing as @StenSoft has mentioned in his answer.Vikrant Singh

1 Answers

2
votes

CALL stores two words in the stack so it changes SP by 4. Stack grows up on this architecture so its value is increased as more data are stored. So finally you can compute the result:

0x16e + 4 = 0x172