Mail Archives: djgpp/2001/05/09/09:48:16
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
- Raw text -