Re: GCC inline assembler question




"Fred Nach" <fred_nach@xxxxxxxxxxx> schrieb im Newsbeitrag news:di0phu$qkl$1@xxxxxxxxxxxxxxxxxxxxxx
Hi all !

I'm wondering how can i use "dummy registers" inside an inline assembly part ?
I mean, considering this code :


    asm("mov r1, %1, asr #15;"
"teq r1, %1, asr #31;"
"eorne %0, %1, %1, asr #31;"
:"=r" (output)
:"r" (input)
:"r1"
);

In this case, r1 is used only locally, and it is also clobbered, hence gcc will store its value (somewhere in the stack, memory, or other free register) before using it...
I would like to know how to let gcc determine the best register to use (for exemple if before that asm instrcution r6 is free... it leads to less store/load instructions).
Hard to explain but how can i specify to gcc that i want to use not specific register ... and let him decide the best to use ?


Thanks in advance for any help !!

Fred.

I've read some tutorial on gcc-asm dealing with this "problem". The suggestion was to "invent" additional output's - being the temporary registers - and assigning them to variables which are not used.


Raymund Hofmann

.



Relevant Pages

  • Re: assembler code in gforth
    ... with the exception of not loading sp into a register. ... needed for that would be a common assembler syntax, ... Yes, if everything goes well, gcc keeps them in registers, and there ...   ...
    (comp.lang.forth)
  • Re: [PATCH] MTD: Fix Orion NAND driver compilation with ARM OABI
    ... Sometimes you need to make an `asm' operand be a specific register, ... but there's no matching constraint letter for that register _by ... Note that we've depended on GCC not copying values with a dereferenced ...
    (Linux-Kernel)
  • Re: gcc return reg on inline asm
    ... gcc ended up using eax as ... It was valid code as far as gcc was concerned ... way I know of to tell GCC that the result is in the flags register, ... way to do it, but as you've probably noticed by now, the only register pair ...
    (comp.lang.asm.x86)
  • Re: assembler code in gforth
    ... with the exception of not loading sp into a register. ... needed for that would be a common assembler syntax, ... Yes, if everything goes well, gcc keeps them in registers, and there ... And he would incur several portability problems: ...
    (comp.lang.forth)
  • Re: [klibc 37/43] x86_64 support for klibc
    ... +#undef NSIG ... I can't remove the workaround just yet, since I have active users of the ... were hard-coded in the patterns (using register variables, ... on older gcc versions. ...
    (Linux-Kernel)