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. 
 

 

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?19050>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



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

Reply via email to