我正在尝试使用 C 从头开始构建我的第一个 CHIP-8 仿真器。在为指令编写必要的代码时,我遇到了这个操作码:
00EE - RET
Return from a subroutine.
The interpreter sets the program counter to the address at the top of the stack, then subtracts 1 from the stack pointer.
(http://devernay.free.fr/hacks/chip8/C8TECH10.HTM)
我知道子程序基本上是一个函数,但是从子程序“返回”是什么意思?程序计数器、堆栈和堆栈指针分别发生了什么?
(另外一个问题):如果我创建了一个可以容纳 16 个值来表示堆栈的数组,那么“堆栈顶部”是 STACK[0] 还是 STACK[15]?我的堆栈指针应该在哪里?