cpu-registerscpu-architectureprocessorstack-memorystack-machine

Does the processor use more than one stack to separate the call stack from the expression/register stack?


I was reading some basic articles about memory manipulation by the processor, and I was confused as to how the processor handles what comes next.

The concept of the call stack is clear, but I was wondering if the expression stack/register stack (used to make the calculations) is the same stack, or even if the stack for the local variables of a subroutine (a function) in a program is the same call stack.

If anyone could explain to me how the processor operates regarding its stack(s), that'd help me a lot.


Solution

  • All the processors I've worked on have just used a single stack for these.

    If you think about what the processor is doing, you only need a single stack. During calculations you can use the same stack as the calling stack, as when the calculation is complete the stack will be 'clean' again. Same for local variables, just before you go out of the scope of the local variables your stack will be clean allowing the call to return correctly.