Register calling conventions

Don Fisher (dfisher@as.arizona.edu)
Tue, 08 Jul 1997 17:39:13 -0700


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
not
been able to determine what the register calling conventions etc. are.
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.

thanks
don

unsigned int csum_partial(const unsigned char * buff, int len, unsigned
int sum) {
/*
* Experiments with ethernet and slip connections show that
buff
* is aligned on either a 2-byte or 4-byte boundary. We get
at
* least a 2x speedup on 486 and Pentium if it is 4-byte
aligned.
* Fortunately, it is easy to convert 2-byte alignment to
4-byte
* alignment for the unrolled loop.
*/
__asm__("
testl $2, %%esi # Check alignment.
jz 2f # Jump if alignment is ok.
subl $2, %%ecx # Alignment uses up two bytes.
jae 1f # Jump if we had at least two
bytes.
addl $2, %%ecx # ecx was < 2. Deal with it.
jmp 4f
1: movw (%%esi), %%bx
addl $2, %%esi
addw %%bx, %%ax
adcl $0, %%eax
2:

-- 
*******************************************************************
*    Don Fisher				  dfisher@as.arizona.edu  *
*    MMT Observatory			  VOICE: (520)621-7647	  *
*    University of Arizona    		  FAX:   (520)670-5740	  *            
*    Tucson, AZ  85721                				  *              
*******************************************************************