info-c digest v2n226

Mike Schultz mikes at oakhill.UUCP
Fri Nov 11 00:53:21 AEST 1988


In article <1075 at dukeac.UUCP> sbigham at dukeac.UUCP (Scott Bigham) writes:
>In article <8810242200.AA05011 at lti.com> reg at lti.com (Rick Genter x18) writes:
>>The difference [between hardware and software stacks]
>>is that a machine with a hardware stack can dereference
>>the top of the stack and modify the stack pointer as an atomic operation
>>(usually via an addressing mode).  A machine with "only" software stacks
>>must use multiple machine instructions to perform this operation...
>
>What of the 68000?  By your argument, it has a hardware stack, since I can
>push something onto the stack with MOVE.L #FFFF,-(SP).  But suppose I
>allocate a chunk of memory and set another address register (say A3) to the
>top of it.  Then I can say MOVE.L #FFFF,-(A3) et al; essentially, I've just
>produced my own stack out of thin air.  I would call this a software stack,
>since it wasn't there when I turned the machine on.  But then why isn't the
>SP-based stack a software stack?  (Remember, SP is just A7)

That is correct, but remember that there are instructions that know about A7
being the Stack Pointer.  Instructions like JSR, BSR, RTS, RTE.  Also the 
processor uses A7 to push state information on the stack during exceptions. 
Plus there are really two A7's,  one which is active when the supervisor bit
is set, and another when it isn't.

So, it is true that you can implement a software stack on the 68000, but 
enough of the hardware knows about A7 being used as a stack pointer to
qualify it as a hardware stack.

Mike Schultz
Motorola Inc, Austin Texas
....!uunet!cs.utexas.edu!oakhill!mikes



More information about the Comp.lang.c mailing list