Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!rutgers!apple!voder!kontron!optilink!cramer From: cramer@optilink.UUCP (Clayton Cramer) Newsgroups: comp.lang.c Subject: Re: Argument Passing in C Keywords: What *really* happens... Message-ID: <510@optilink.UUCP> Date: 27 Sep 88 23:41:16 GMT References: <2235@ssc-vax.UUCP> <12187@steinmetz.ge.com> <69210@sun.uucp> Organization: Optilink Corporation, Petaluma, CA Lines: 36 In article <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. > So what?, I thought. So which machines have a hardware stack and which > don't and how do the differences appear to, say, an assembly language > programmer. > > -- > Scott Wilson arpa: swilson@sun.com This may be going further back into prehistory than you intended, but I worked on a machine called the Univac 1219 that had no concept of a "stack pointer". Subroutine calls were implemented with an instruction called "B7IJ", which took the current return address and stuffed it into the word at the beginning of the subroutine you were calling. When your subroutine was complete, you executed a return by doing an indirect jump through the address in the first word of the subroutine. Needless to say, there was no way to do recursion without tremendous effort. An example of a machine with a nearly useless hardware stack is the 6502. The stack pointer is an 8-bit register, and the first eight bits of the hardware stack pointer address are optionally definable by a jumper. As a consequence, the hardware stack is only 256 bytes long. If you want to do anything more complicated than a simple video game, or perhaps a simple process control system, plan on building your own stack manipulation subroutines. And you thought the 8086 family was primitive! -- Clayton E. Cramer ..!ames!pyramid!kontron!optilin!cramer