[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Question about code size
From: |
Dave Hylands |
Subject: |
[avr-gcc-list] Question about code size |
Date: |
Thu, 15 Mar 2007 20:50:05 -0800 |
Hi,
I've tried building a bootloader I have using 4.1 and 4.2 and the code
size is about 50% larger than what I get from 3.4.4 (or 3.4.5). Now, I
got the sources for these toolchains from different sources, so its
conceivable that one has a patch that other one doesn't, but the
difference seems rather extreme.
I've put all of my file over here:
http://www.davehylands.com/Misc/bootloader/
The b34.sh and b42.sh are the scripts I used to build the two
An excerpt of a typical function is:
void nothing_response(void)
{
if (getch() == ' ')
{
putch(0x14);
putch(0x10);
}
}
Under 3.4.4, using -Os -mshort-calls (on boot.c)
00003c72 <nothing_response>:
3c72: f7 df rcall .-18 ; 0x3c62 <getch>
3c74: 80 32 cpi r24, 0x20 ; 32
3c76: 21 f4 brne .+8 ; 0x3c80
<nothing_response+0xe>
3c78: 84 e1 ldi r24, 0x14 ; 20
3c7a: da df rcall .-76 ; 0x3c30 <putch>
3c7c: 80 e1 ldi r24, 0x10 ; 16
3c7e: d8 df rcall .-80 ; 0x3c30 <putch>
3c80: 08 95 ret
Under 4.2.0, using the same options, I get:
00003ca2 <nothing_response>:
3ca2: 80 91 c0 00 lds r24, 0x00C0
3ca6: 87 ff sbrs r24, 7
3ca8: fc cf rjmp .-8 ; 0x3ca2
<nothing_response>
3caa: 80 91 c6 00 lds r24, 0x00C6
3cae: 80 32 cpi r24, 0x20 ; 32
3cb0: 71 f4 brne .+28 ; 0x3cce
<nothing_response+0x2c>
3cb2: 80 91 c0 00 lds r24, 0x00C0
3cb6: 85 ff sbrs r24, 5
3cb8: fc cf rjmp .-8 ; 0x3cb2
<nothing_response+0x10>
3cba: 84 e1 ldi r24, 0x14 ; 20
3cbc: 80 93 c6 00 sts 0x00C6, r24
3cc0: 80 91 c0 00 lds r24, 0x00C0
3cc4: 85 ff sbrs r24, 5
3cc6: fc cf rjmp .-8 ; 0x3cc0
<nothing_response+0x1e>
3cc8: 80 e1 ldi r24, 0x10 ; 16
3cca: 80 93 c6 00 sts 0x00C6, r24
3cce: 08 95 ret
Is there a different set of options I can use with 4.x to get smaller code size?
It seems to be inlining the putch function which is called many times,
and the inlined version is quite a bit bigger than calling the
function.
--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/