> -----Original Message-----
> From: 
> [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]
> org] On Behalf Of Anatoly Sokolov
> Sent: Tuesday, February 13, 2007 9:52 AM
> To: Anatoly Sokolov; Joerg Wunsch; [EMAIL PROTECTED]; 
> [email protected]
> Subject: [avr-libc-dev] [bug #19050] gcrt1.S should call main 
> rather thanjumping to it
> 
> 
> Follow-up Comment #1, bug #19050 (project avr-libc):
> 
> Call main() as a normal function have some drawback:
> 
> 1. Loss of two bytes of RAM for storing 'main' return address 
> in stack.
> 
> 2. Increase code size, if 'main' function has local variables.
> 
> Now stack frames for 'main' function is setup by a following code:
> REG_Y (frame pointer)  = RAM_END - frame_size
> SP = REG_Y
> 
> Size = 4 instruction.
> 
> If 'main' will be usual function, that in prologue will be a 
> following code:
> 
> PUSH REG_Y
> REG_Y = SP
> REG_Y = REG_Y - frame_size
> SP = REG_Y
> 
> Size - 7/8 instruction and loss of two bytes more of RAM. And 7/8 more
> instructions in an epilogue of function.
> 
> 3. If in 'main' function 'call-saved' registers (r2..r17) 
> will be used, then
> they will be saved in a stack. 

Hi Anatoly,

You make some very good points. Unfortunately, main() is already converted
over to a normal function in gcc 4.x. Do you propose that we convert it
back?

Can someone remember what was the reasoning behind making main() a normal
function? Is the reason still valid?

Thanks
Eric Weddington



_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to