Mail Archives: djgpp/2001/05/09/14:12:38
> From: Michiel de Bondt <michielb AT sci DOT kun DOT nl>
> 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.
- Raw text -