avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Question about code size


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Question about code size
Date: Sun, 18 Mar 2007 08:42:25 +0100 (MET)

"Dave Hylands" <address@hidden> wrote:

> 3.4.4 avr-gcc -Os -mshort-calls -mmcu=atmega168
> 
> 00000000 <getNch>:
>    0:   cf 93           push    r28
>    2:   88 23           and     r24, r24
>    4:   21 f0           breq    .+8             ; 0xe <getNch+0xe>
>    6:   c8 2f           mov     r28, r24
>    8:   00 d0           rcall   .+0             ; 0xa <getNch+0xa>
>    a:   c1 50           subi    r28, 0x01       ; 1
>    c:   e9 f7           brne    .-6             ; 0x8 <getNch+0x8>
>    e:   cf 91           pop     r28
>   10:   08 95           ret

In preparation for a bug report, I tried to reproduce that.  With GCC
3.4.6, I get:

        .type   getNch, @function
getNch:
/* prologue: frame size=0 */
        push r17
        push r28
/* prologue end (size=2) */
        mov r17,r24
        ldi r28,lo8(0)
        cp r28,r24
        brsh .L7
..L5:
        rcall getch
        subi r28,lo8(-(1))
        cp r28,r17
        brlo .L5
..L7:
/* epilogue: frame size=0 */
        pop r28
        pop r17
        ret
/* epilogue end (size=3) */
/* function getNch size 13 (8) */

i.e. essentially the same as with GCC 4.x.

So back to 3.4.4:

..global getNch
        .type   getNch, @function
getNch:
/* prologue: frame size=0 */
        push r28
/* prologue end (size=1) */
        tst r24
        breq .L7
        mov r28,r24
..L5:
        rcall getch
        subi r28,lo8(-(-1))
        brne .L5
..L7:
/* epilogue: frame size=0 */
        pop r28
        ret
/* epilogue end (size=2) */
/* function getNch size 10 (7) */

OK, checked 3.4.5 finally:

..global getNch
        .type   getNch, @function
getNch:
/* prologue: frame size=0 */
        push r17
        push r28
/* prologue end (size=2) */
        mov r17,r24
        ldi r28,lo8(0)
        cp r28,r24
        brsh .L7
..L5:
        rcall getch
        subi r28,lo8(-(1))
        cp r28,r17
        brlo .L5
..L7:
/* epilogue: frame size=0 */
        pop r28
        pop r17
        ret
/* epilogue end (size=3) */
/* function getNch size 13 (8) */

So the problem appeared before 3.4.5.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

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