Re: Register calling conventions

Gabriel Paubert (
Wed, 9 Jul 1997 10:45:31 +0200 (METDST)

On Tue, 8 Jul 1997, Don Fisher wrote:

> Hi,
> I hope this is an ok question to ask. I have been wanting to write
> some assy code. I have looked at examples like the one below and have

It would be better on linux-gcc.

> not
> been able to determine what the register calling conventions etc. are.

Have a look at the assembly-language HOWTO, but beware it's somewhat
confusing when using FPU (and MMX since these are the same registers).
AFAIK, gcc calls all subroutines with an empty FP stack.

> Which
> regs are saved, and how are arguments passed? I looked through the gcc
> info and couldn't find anything. Does it have anything to do with
> : "=a"(sum)
> : "0"(sum), "c"(len), "S"(buff)
> : "bx", "cx", "dx", "si");
> statements. I also was curious what effect __volatile__ has after
> the __asm__ directive.

Simply type info gcc and go to C Extensions then Extended Asm . Basically
all the code you see here is not an assembly language subroutine, but
inline assembly with constraints for register allocation inside a
subroutine (but constraints for Intel are the most complex of all given
the oddities of the architecture, i.e., that every register is special wrt
some instructions).

In this case gcc takes care of all the register saves and restores, frame
pointer setup if necessary and so on... You only have to write the
truly speed critical part of the loop in assembly :-)