📜  门| GATE-CS-2015(Set 2)|第65章

📅  最后修改于: 2021-06-29 23:21:08             🧑  作者: Mango

考虑具有字节可寻址存储器的处理器。假定所有寄存器,包括程序计数器(PC)和程序状态字(PSW),均为2字节大小。从存储器位置(0100)16实现主存储器中的堆栈,并且该堆栈向上增长。堆栈指针(SP)指向堆栈的顶部元素。 SP的当前值为(016E) 16 。 CALL指令有两个字,第一个字是操作码,第二个字是子例程的起始地址(一个字= 2字节)。 CALL指令的实现如下:

• 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. 

紧接CALL指令提取之前,PC的内容为(5FA0) 16 。执行CALL指令后,堆栈指针的值为
(A) (016A) 16
(B) (016C) 16
(C) (0170) 16
(D) (0172) 16答案: (D)
解释:

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 

这个问题的测验