avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] [bug #19050] gcrt1.S should call main rather thanjump


From: Anatoly Sokolov
Subject: Re: [avr-libc-dev] [bug #19050] gcrt1.S should call main rather thanjumping to it
Date: Wed, 14 Feb 2007 00:11:48 +0300

Hello.

Let's consider the worst variant:

demo.c
-----
void foo(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int 
a9 )
{
}

int main()
{
  int i;

  foo(0x0201, 0x0202, 0x0203, 0x0204, 0x0205, 0x0206, 0x0207, 0x0208 , 
0x0209);
  return 0;
}
-----

1. In GCC 4.3 main look so:

int main()
{
 100: cd e5        ldi r28, 0x5D ; 93
 102: d8 e0        ldi r29, 0x08 ; 8
 104: de bf        out 0x3e, r29 ; 62
 106: cd bf        out 0x3d, r28 ; 61
  int i;

  foo(0x0201, 0x0202, 0x0203, 0x0204, 0x0205, 0x0206, 0x0207, 0x0208 , 
0x0209);
 108: 0f 2e        mov r0, r31
......
 14a: 92 e0        ldi r25, 0x02 ; 2
 14c: 0e 94 47 00  call 0x8e ; 0x8e <foo>
  return 0;
 150: 80 e0        ldi r24, 0x00 ; 0
 152: 90 e0        ldi r25, 0x00 ; 0
 154: 0c 94 ac 00  jmp 0x158 ; 0x158 <_exit>

00000158 <_exit>:
 158: ff cf        rjmp .-2       ; 0x158 <_exit>

5 instructions in prologue/epilogue, 0 ( 2 for 'i' ) RAM bytes used.

2. main() as normal function:

int main()
{
 100: 8f 92        push r8
 102: 9f 92        push r9
 104: af 92        push r10
 106: bf 92        push r11
 108: cf 92        push r12
 10a: df 92        push r13
 10c: ef 92        push r14
 10e: ff 92        push r15
 110: 0f 93        push r16
 112: 1f 93        push r17
 114: cf 93        push r28
 116: df 93        push r29
 118: cd b7        in r28, 0x3d ; 61
 11a: de b7        in r29, 0x3e ; 62
 11c: 22 97        sbiw r28, 0x02 ; 2
 11e: 0f b6        in r0, 0x3f ; 63
 120: f8 94        cli
 122: de bf        out 0x3e, r29 ; 62
 124: 0f be        out 0x3f, r0 ; 63
 126: cd bf        out 0x3d, r28 ; 61
  int i;

  foo(0x0201, 0x0202, 0x0203, 0x0204, 0x0205, 0x0206, 0x0207, 0x0208 , 
0x0209);
 128: 0f 2e        mov r0, r31
.....
 16c: 0e 94 47 00  call 0x8e ; 0x8e <foo>
  return 0;
 170: 80 e0        ldi r24, 0x00 ; 0
 172: 90 e0        ldi r25, 0x00 ; 0
 174: 22 96        adiw r28, 0x02 ; 2
 176: 0f b6        in r0, 0x3f ; 63
 178: f8 94        cli
 17a: de bf        out 0x3e, r29 ; 62
 17c: 0f be        out 0x3f, r0 ; 63
 17e: cd bf        out 0x3d, r28 ; 61
 180: df 91        pop r29
 182: cf 91        pop r28
 184: 1f 91        pop r17
 186: 0f 91        pop r16
 188: ff 90        pop r15
 18a: ef 90        pop r14
 18c: df 90        pop r13
 18e: cf 90        pop r12
 190: bf 90        pop r11
 192: af 90        pop r10
 194: 9f 90        pop r9
 196: 8f 90        pop r8
 198: 08 95        ret

39 instructions in prologue/epilogue, 12( +2 for 'i') RAM bytes used.

I would prefer to correspond to 'C' standard completely, but we are ready to 
pay such price, for that that function 'main()' to be callable?

Anatoly. 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]