From: Michiel de Bondt Newsgroups: comp.os.msdos.djgpp Subject: Re: how to use inline push and pop Date: Wed, 09 May 2001 14:48:14 +0200 Organization: University of Nijmegen Lines: 64 Message-ID: <3AF93C8E.84E782F@sci.kun.nl> References: NNTP-Posting-Host: fanth.sci.kun.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: wnnews.sci.kun.nl 989412495 20827 131.174.132.54 (9 May 2001 12:48:15 GMT) X-Complaints-To: usenet AT sci DOT kun DOT nl NNTP-Posting-Date: Wed, 9 May 2001 12:48:15 +0000 (UTC) X-Mailer: Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Eli Zaretskii wrote: > On Mon, 7 May 2001, Michiel de Bondt wrote: > > > I made some macro's to push and pop registers, but it did not work when > > I optimized the code. > > It might be a good idea to explain why did you need that in the first > place. 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++. 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. > If you write full-blown assembly code that calls other > functions, simply make an assembly module instead of doing it in > inline assembly. Going inline is only justified for short code > sequences, and manipulating the stack (with pushall, on top of that) > has overhead which can easily nullify any advantages. A pushall is much faster than separate pushes or using backup locals, I think. But I have to admit that on a SPARC, it seems a better idea to copy my six reg vars to other regs, since there are so many regs. But some are needed for storing memory offsets and computing memory addresses: I cannot remember that I computed addresses during my loads. I only remembered that bits seperated reg, mem, imm (-8192 to 8191), large imm. Maybe, I will add some macros for the SPARC later. I believe I can use only registers on a SPARC, so no base pointer and all registers except %i6 used (the stack pointer). Other processors are unknown to me, except the MC 68000, but that seems obsolete for computers, I think. I have heard that it is used for washing machines etcetera. Isn't it really possible to use the stack in a save way. I have seen things that are called insn's, but I do not know how these work. Further, my push/pop macros work in almost all cases, which makes it seem easy to modify gcc to make it work always. Remember that C was intended to be a machine independent assembler. Or is the call instruction not machine independent: does it shift the register window on a SPARC? I do not remember. Best regards, Michiel