|
|
View previous topic :: View next topic |
Author |
Message |
EdWaugh
Joined: 07 Dec 2004 Posts: 127 Location: Southampton, UK
|
Unused Fragments |
Posted: Tue May 17, 2011 6:18 am |
|
|
Hi all,
I'm sorry if this has been asked before, I did a search but it returns over 1300 matches.
I'm trying to eek the last few bytes of ROM from my device and I was curious about the following in the sta file:
ROM used: 124410 (95%)
130916 (100%) including unused fragments
I guess the fragments are small gaps across blocks in the flash? Is there anyway to optimise this better? 5 % of 131 kB is 6.5 kB!
Cheers
Ed |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Tue May 17, 2011 6:48 am |
|
|
Bit of a 'roundabouts and swings' thing.
Splitting routines into smaller sections, will give the compiler some smaller bits to 'play with', and may allow it to optimise better, _but_ may increase the total size, as calling a routine adds overhead.
Generally, look instead at whether there are things you can do to decrease the total code size. Code 'drinkers', are arithmetic, printf etc.. If (for instance) you are doing a sum completely in fp arithmetic, but part of it is multiplication, and only involves integers, you may be able to save some significant space by forcing the use of integer arithmetic for this part. On printf, look for 'repeated' statements. If you use a printf, to the same target, with the same format specifier in multiple places in the code, make this into a separate routine, and call this routine, rather than having the multiple printf's. Generally I'd not be at all surprised if you couldn't save at least 25%, by moves like this, and this will also reduce the size of the routines involved, allowing more efficient packing at the same time....
Best Wishes |
|
|
EdWaugh
Joined: 07 Dec 2004 Posts: 127 Location: Southampton, UK
|
|
Posted: Tue May 17, 2011 8:14 am |
|
|
Hi Ttelmah,
Thanks for your response. I have had a look at the fp in my code already but I may have another go, I'm curious about the printf stuff tho, surely this is just a single function call that decodes the format string at run time? Otherwise am I able to see all the separate calls in the tree/statistics?
Thanks
Ed |
|
|
EdWaugh
Joined: 07 Dec 2004 Posts: 127 Location: Southampton, UK
|
|
Posted: Tue May 17, 2011 8:48 am |
|
|
Hi again,
I had a look at the use my program is making of anything called pstring or printf:
Code: | 0 52 0 4 @PSTRINGCN_115200_31766_31767
0 434 0 13 @PRINTF_L32D_115200_31766_31767FPFPF
0 134 0 2 @PRINTF_U_115200_31766_31767
0 44 0 3 @PSTRINGC_115200_31766_31767
0 34 0 1 @SPRINTF
0 132 0 2 @PRINTF_U_1019
0 188 0 9 @PRINTF_LU_1019
1 56 0 4 @PSTRINGCN_115200_31793_31794
1 50 0 2 @PSTRINGR_115200_31793_31794
1 52 0 3 @PSTRINGC_115200_31793_31794
0 40 0 2 @PSTRINGR_115200_31766_31767
0 74 0 2 @PRINTF_X_115200_31766_31767
0 282 0 12 @PRINTF_L32D_115200_31766_31767
0 192 0 12 @PRINTF_L32U_115200_31766_31767
0 48 0 4 @PSTRINGCN_1019
0 76 0 2 @PRINTF_X_1019
0 172 0 9 @PRINTF_LU_115200_31766_31767
1 52 0 4 @PSTRINGCN_324
1 44 0 2 @PSTRINGR_324
0 188 0 9 @PRINTF_LU_324
0 280 0 12 @PRINTF_L32D_324
1 162 0 2 @PRINTF_U_115200_31793_31794
1 92 0 2 @PRINTF_X_115200_31793_31794
1 204 0 9 @PRINTF_LU_115200_31793_31794
0 38 0 2 @PSTRINGR_1019
1 276 0 9 @PRINTF_LD_115200_31766_31767
0 290 0 12 @PRINTF_L32D_1019
0 198 0 12 @PRINTF_L32U_1019
0 248 0 9 @PRINTF_LD_1019
0 128 0 2 @PRINTF_U_324
0 430 0 13 @PRINTF_L32D_324FPFPF
0 196 0 12 @PRINTF_L32U_324
0 244 0 9 @PRINTF_LD_324 |
This is a total of 5134 bytes which is quite a lot but my 18F87J11 has 128 kB of ROM so I make this only 3.9 % of the total.
The I looked at the maths functions:
Code: | 0 56 0 4 @DTOF
0 350 0 14 @DIVFF
0 246 0 11 @MULFF
1 80 0 2 @MUL88
0 120 0 6 @DIVS1616
1 92 0 6 @MULS1616
0 770 1 16 @ADDFF
0 92 0 14 @MUL3232
0 234 0 14 @DIVS3232
0 34 0 5 @MUL1616
0 44 0 3 @DIV88 |
Total 2118, 1.6 %
Even if I could halve it that would not make a huge difference for me. Maybe my application is just too big!
Any suggestions are welcome as always.
Ed |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Tue May 17, 2011 9:18 am |
|
|
printf, is not a 'single function call'. It is decoded at _compile_ time, for the specified options, and 90% of the time coded inline. The parts visible in the symbol tree are internal subroutines this then calls. If you search through the .lst file, for the lines coding printf, don't be surprised is there are 70 to 80 bytes setup for every one of the calls....
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|