Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!linus!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: comp.lang.c Subject: Re: MSC and stack manipulation Message-ID: <2460@mmintl.UUCP> Date: Wed, 7-Oct-87 16:34:45 EDT Article-I.D.: mmintl.2460 Posted: Wed Oct 7 16:34:45 1987 Date-Received: Sun, 11-Oct-87 13:26:01 EDT References: <325@picuxa.UUCP> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT. Lines: 25 Keywords: MSC In article <325@picuxa.UUCP> gp@picuxa.UUCP (Greg Pasquariello X1190) writes: >Here is a question for anyone who cares to throw his stack in the ring. >When MSC 4.0 calls a function, it subtracts the amount of space needed >by local variables from the stack. Why? The 80x86 instructions subtract >two bytes from SP when a push is done anyway. Because the program, in general, may use that local variable any number of times. Thus, when a value is put in it, it is *stored*, not pushed. Also, there may be other locals, and the order in which they are used may be arbitrary. So the routine has to adjust SP to leave space for the local variables. It would be a possible optimization, if most or all of the locals had initialization expressions, to compute and push them for the initial allocation. However, this is not necessarily an optimization. I don't have access to 8086 timing specs at the moment, but on many machines, stores take less time than pushes, so for some number of arguments, the subtract and store methodology is a win. Again; the space left by the subtraction is used later in the program. -- Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108