Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!wasatch!utah-gr!uplherc!sp7040!obie!wsccs!dharvey From: dharvey@wsccs.UUCP (David Harvey) Newsgroups: comp.lang.c Subject: Re: Argument Passing in C (Stacks) Summary: How about using the normal registers? Message-ID: <699@wsccs.UUCP> Date: 2 Oct 88 22:27:14 GMT References: <705.2339B3D8@stjhmc.fidonet.org> Lines: 39 In article <705.2339B3D8@stjhmc.fidonet.org>, will.summers@p6.f18.n114.z1.fidonet.org (will summers) writes: > In message <69210@sun.uucp> swilson%thetone@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,@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@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.