📜  门| GATE-CS-2015(套装2)|第 65 题

📅  最后修改于: 2021-09-25 05:12:54             🧑  作者: 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
(四) (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 

这个问题的测验