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:
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.