Path: utzoo!attcan!uunet!ncrlnk!ncrcae!ece-csc!ncsuvx!gatech!bloom-beacon!spdcc!ima!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.c Subject: Re: Argument Passing in C Keywords: What *really* happens... Message-ID: <28230@think.UUCP> Date: 21 Sep 88 19:15:44 GMT References: <2235@ssc-vax.UUCP> <12187@steinmetz.ge.com> <69210@sun.uucp> Sender: news@think.UUCP Reply-To: barmar@kulla.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 33 In article <69210@sun.uucp> swilson@sun.UUCP (Scott Wilson) writes: >Can someone explain to me what the difference is between a hardware stack >and a software stack? A hardware stack is one that has explicit machine instructions and/or addressing modes for manipulating and using a register (or registers) as a stack pointer. Frequently there is a dedicated register for this purpose, and it is used implicitly by some of these instructions. The example you gave was good. If you can push or pop a value on a stack in one instruction, rather than having to increment the stack pointer in a separate instruction, you have the rudiments of a hardware stack (of course, autoincrementing is also useful for stepping through an array). Other operations sometimes supplied with a hardware stack are special call and return instructions that automatically manipulate the stack. For example, if the return instruction knows that the saved PC is at a particular offset from the stack pointer register and automatically pops it into the PC and unwinds the stack, that is a hardware stack. The Honeywell hardware that Multics runs on doesn't have a hardware stack, but there are conventions that a particular register was always used as the stack pointer. The assembler has a RETURN pseudo-op that is actually a built-in macro that does all the stack manipulation for returning (actually, it transfers to a standard shared routine that does the work). Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar