Mail Archives: djgpp/1997/12/03/19:57:58
At 03:39 12/3/1997 +1000, Leath Muller wrote:
>> > You MUST !!
>
>> Not necessarily. In many cases you can use GCC's extended asm features to
>> inform it that a certain register has been clobbered. I can't think of a
>> simple realistic example, so here's an imaginary one. The `frob' instruction
>> does something useful and puts undefined stuff into the given register.
>> asm("frob %ebx" : /* no outputs */ : /* no inputs */ : "%ebx");
>
>Correct me if I am wrong, but if you have a piece of assembly in its own
>subroutine:
>
> void whatever()
> {
> asm {
> }
> }
>
>then you don't have to push/pop any registers other than the stack/stack
>frame ones (like ebp if you use it) as the subroutine has its own stack
>frame anyway...
Not quite. You will have to (save/restore) or (tell the compiler that you
clobbered) registers which it expects to be preserved across function calls.
Last I checked, this was %ebx, %esi, %edi and %ebp. IMHO, you should inform
the compiler about clobbering every register that you change, and it will
then take appropriate action if necessary.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -