I'm trying to understand the usage and implementation of a Stacks in assembly language (Motorola 68k).
I know that the MC 68k, has 8 address registers, A7 being the special one. Since it's two stack pointers, sharing the name of "System stack pointer".
And we have two states user state and supervisor state. Where:
user state-
certain system resources are blocked and A7 accesses the user stack pointer.
supervisor state-
all system resources are available and A7 accesses the supervisor stack pointer
Now I'm not sure about how to go answering these 2 questions:
Why does the 68000 have two hardware stack pointers?
Write code to
Save the long-word values of registers D1,D3,A2-A6on the runtimestack.
MOVEM D1-D3/A2-A6, -(A7)
Would this be correct?
Here I'm not sure by what is referred to as "runtimestack", and I'm not sure what the difference of (SP) and (A7) really is. Any help would be much appreciated.
I never wrote any 68000 assembler, but from what I can read out of your question this seems to be about user mode vs. supervisor mode. Maybe you should start at the beginning and read the manual?
From the M68000 FAMILY Programmer’s Reference Manual:
1.3.1 Address Register 7 (A7) In the supervisor programming model register, A7 refers to the interrupt stack pointer, A7’(ISP) and the master stack pointer, A7" (MSP). The supervisor stack pointer is the active stack pointer (ISP or MSP). For processors that do not support ISP or MSP, the system stack is the system stack pointer (SSP). The ISP and MSP are general- purpose address registers for the supervisor mode. They can be used as software stack pointers, index registers, or base address registers. The ISP and MSP can be used for word and long-word operations.