Floating point math on Coldfire V1 - Code size problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Floating point math on Coldfire V1 - Code size problem

Jump to solution
1,217 Views
gustavod
Contributor III

Hello,

 

I'm using some floating point functions on the Coldfire V1 (MCF51JM128 - Codewarrior 6.3).

Basically these functions are Multiply, Divide, Cos, Sin and Acos. The problem is that Codewarrior compiler links the entire floating point library to my project, which increases the code in 22KB. It is too much.

 

I would like to know if its possible to link just the used functions in my project.

 

Thanks in advance,

Best regards,

Gustavo

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
634 Views
CrasyCat
Specialist III

Hello

 

The linker is performing dead striping by default. That means only objects (functions, variables) really used in the application are linked to the final executable file.

 

Are you sure the linker links the whole library to your project?

 

To check the actual code size open the file with extension .xMAP located in the project bin directory.

This is the map file generated by the linker. To check the actual application code size scroll to the bottom of the file and check size of the sections .code and .text.

 

This is the real size of your application. Size displayed in the .mcp window indicates the size of the application in worst case. If all functions were  used. You should not rely on this information.

 

CrasyCat

View solution in original post

0 Kudos
Reply
4 Replies
635 Views
CrasyCat
Specialist III

Hello

 

The linker is performing dead striping by default. That means only objects (functions, variables) really used in the application are linked to the final executable file.

 

Are you sure the linker links the whole library to your project?

 

To check the actual code size open the file with extension .xMAP located in the project bin directory.

This is the map file generated by the linker. To check the actual application code size scroll to the bottom of the file and check size of the sections .code and .text.

 

This is the real size of your application. Size displayed in the .mcp window indicates the size of the application in worst case. If all functions were  used. You should not rely on this information.

 

CrasyCat

0 Kudos
Reply
634 Views
gustavod
Contributor III

Hi CrasyCat,

 

It is true, only really used objects are being linked to the final file. The problem is that floating point mul, div, sin, cos and acos occupy around 20KB of code. (I think that these functions call other functions.)

 

Thanks,

Gustavo

0 Kudos
Reply
634 Views
CrasyCat
Specialist III

Hello

 

Just a side question here.

 

Are you using printf in your application?

Once floating point arithmetic is enabled, size of function printf increases a lot. That might also explain the increase in the application size you are seeing.

 

Try commenting out all call to printf and check size of code after that. Just to make sure this is not the reason for the big increase.

 

CrasyCat

0 Kudos
Reply
634 Views
kef
Specialist I

CrasyCat,

 

#include <math.h>volatile float a,b,c;void main(void) {  EnableInterrupts; /* enable interrupts */  /* include your code here */  a = sin(b)/cos(c)*acos(a);  for(;;) {    __RESET_WATCHDOG(); /* feeds the dog */  } /* loop forever */  /* please make sure that you never leave main */}

 

 Above prontf-less code gives such record in map file:

 

  00000410 00000410 00005988 .text      code

 

That's 22kB.

0 Kudos
Reply