Argument Passing in C (Stacks)

David Harvey dharvey at wsccs.UUCP
Mon Oct 3 08:27:14 AEST 1988


In article <705.2339B3D8 at stjhmc.fidonet.org>, will.summers at p6.f18.n114.z1.fidonet.org (will summers) writes:

	<body of his message removed>

> In message <69210 at sun.uucp> swilson%thetone at Sun.COM (Scott Wilson) writes:
>  > 
>  > Can someone explain to me what the difference is between a hardware stack
>  > and a software stack?  I worked on a C compiler project once where
>  > one person said the target machine "doesn't even have a hardware stack."
>  > I asked what the difference was between the target machine and, say, a
>  > 68000.
>  > The answer was the 68000 had a stack because it supported addressing modes
>  > like "movl d7, at sp-" whereas the target machine required you to use two
>  > instructions, first a move then an explicit decrement of the stack pointer.

It seems to me that any register based hardware with register indirect
mode and, post-increment and pre-decrement instructions will do the
trick for you.  Using the 68000 as an example:

MOVE.L		#$6000,-(A7)	; to push it on the stack
MOVE.L		(A7)+,D5	; to pop it back off.

This of course creates a normal (goes down in memory as stack grows)
stack, but YOU are responsible for where to put the stack.  Also, it
is highly doubtful that some of the compiler vendors are going to
implement it as a stack (they might if that is all they have).  That
of course means that you will very likely be using Assembler.  My bet
for saying that a machine has a hardware stack is that it has a register
so designated with all the trimmings and trappings as described above.
It is the addressing mode that is most important here however, not a
designated hardware register as a stack pointer per-se.

dharvey at wsccs

I am responsible for Nobody
and Nobody is responsible for me.

The only thing you can know for sure
is that you can't know anything for sure.



More information about the Comp.lang.c mailing list