Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: asm statements & the stack Message-ID: <8743@utzoo.UUCP> Date: Sat, 10-Oct-87 19:47:26 EDT Article-I.D.: utzoo.8743 Posted: Sat Oct 10 19:47:26 1987 Date-Received: Sat, 10-Oct-87 19:47:26 EDT References: <110@teletron.UUCP>, <7426@e.ms.uky.edu> Organization: U of Toronto Zoology Lines: 21 > The method of keeping the stack pointer pointing at an unused location is > quite common, as I have used many unix compilers which do this... Yes, people trying to work in assembler around C compilers should be aware that this is a standard tactic. There are three reasons for it. First, moving a value to an already-vacant stack-top location is quicker than pushing it onto the stack in many machines. Second, it becomes unnecessary to remove the argument from the stack after calling a one-argument function. And third, on some machines it is easier to remove one or two words from the stack than to remove a more general number, and these efficient removal sequences then apply to a larger fraction of all functions. The first and second reasons also apply to using the stacktop location as an expression-evaluation temporary. This tactic does require careful attention to situations like function calls within function argument lists, but it is a cheap and effective optimization if done right. -- "Mir" means "peace", as in | Henry Spencer @ U of Toronto Zoology "the war is over; we've won". | {allegra,ihnp4,decvax,utai}!utzoo!henry