This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mips va_arg question


Hi all
I have question regarding usage of va_arg functions
when type is double. I think that code will be correct
only in case that sp is multiple of 8. 
Passing of double to function with variable number of
arguments is over stack, and va_arg inside of function
with variable number of arguments suppose that sp
could be divided by 8.
Here is small sample:
  test(1, 2, 3, 4.56,5,6);  
  asm("addiu $29, $29, -4"); // SP isn't multiple of 8
  test(1, 2, 3, 4.56,5,6);  

Here is code for test:
void test(int arg1, int arg2, ...)
{
   int n, n5, n6;
   double d;
   va_list ap;

   va_start(ap, arg2);
   
   n = va_arg(ap, int);    
   d = va_arg(ap, double); 
   n5 = va_arg(ap, int);   
   n6 = va_arg(ap, int);  
   va_end(ap);    
}

Here is ams sorce for d = va_arg(ap, double):
000042cc:  lw           v0,40(s8)          
000042d0:  nop                             
000042d4:  addiu        v1,v0,7            
000042d8:  li              v0,-8              
000042dc:  and          v0,v1,v0           
000042e0:  sw           v0,40(s8)          
000042e4:  lw            v0,40(s8)          
000042e8:  nop                             
000042ec:  addiu        v0,v0,7            
000042f0:  sw             v0,40(s8)          
000042f4:  lw              v1,40(s8)          
000042f8:  li               v0,-8              
000042fc:  and           v0,v1,v0           
00004300:  sw           v0,40(s8)          
00004304:  lw            v1,40(s8)          
00004308:  lw            v0,40(s8)          
0000430c:  nop                             
00004310:  addiu        v0,v0,8            
00004314:  sw            v0,40(s8)          
00004318:  lw             v0,0(v1)           
0000431c:  lw             v1,4(v1)           
00004320:  nop                             
00004324:  sw           v1,36(s8)          
00004328:  sw           v0,32(s8)         

I use gcc 3.4.1 for mips-elf, code is compiled with
-mlong-calls -msoft-float -mips1 -c -G0. Please could
You help me?

Best regards Mile



		
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]