Date: Wed, 09 May 2001 19:14:55 +0300 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: Michiel de Bondt Message-Id: <1659-Wed09May2001191455+0300-eliz@is.elta.co.il> X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9 CC: djgpp AT delorie DOT com In-reply-to: <3AF93C8E.84E782F@sci.kun.nl> (message from Michiel de Bondt on Wed, 09 May 2001 14:48:14 +0200) Subject: Re: how to use inline push and pop References: <3AF93C8E DOT 84E782F AT sci DOT kun DOT nl> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: Michiel de Bondt > Newsgroups: comp.os.msdos.djgpp > Date: Wed, 09 May 2001 14:48:14 +0200 > > I wish to do the following: I wish to use my macro's push, pop, call > and ret in my program, use recursion and speed it up. Maybe, I get > the same effect if I use sub-functions, but this is only possible in > plain C, not in C++. Sorry, I don't follow: why do you say that recursion and calling subroutines is not possible in C++? > I wish to use these macros on any > platform. Further, I wish to use macros like pusha and popa, but > only if the preprocessor defines the symbol INTEL. It might be an > idea to call _printf in inline asm, but on a Sparc, the i-regs are > used instead of the stack. So this does not give a solution. So I > keep hoping that gcc has the same features on other platforms. > Another option is to use inline functions, but I do not know whether > these functions may be recursive. Maybe, I should try. I only call > labels in my function with my call macro, not functions. I really think that you should try doing all this in C or C++. Simply write recursive code and then time it and see if it's indeed so slow that you must go to assembly. You might be surprised how fast can recursive code be, contrary to popular belief. In contrast, in my experience, stack manipulation has significant overhead, no matter if done in assembly or C. If I'm right, you will not see any significant speedup. In addition, inline assembly is inherently platform-dependent, so you actually shoot yourself in your foot if portability is of importance. > A pushall is much faster than separate pushes or using backup locals, I > think. But most functions don't need to push all the registers, only a small number of them. Is pushall faster than pushing, say, two registers? > Isn't it really possible to use the stack in a save way. The fact that it isn't easy is a sign that doing so is not a good idea, at least not in most cases. Otherwise, someone would have already done that.