Hi.
I write programs for LPC Cortex-M0.
I need to use the cos and sqrt functions from math.
Program:
1 | #include <math.h>
|
2 | volatile float DeltaX=50, DeltaY=120, Angle=3.14/4;
|
3 | volatile float Delta;
|
4 | volatile unsigned char DistanceFlag;
|
5 |
|
6 |
|
7 | void Func() {
|
8 |
|
9 | float dx=DeltaX, dy=DeltaY, angle=Angle, distance_delta;
|
10 | dx=dx*cos(angle);
|
11 | dx=dx*angle*3.14;
|
12 | distance_delta=dx*dx+dy*dy;
|
13 | distance_delta=sqrt(distance_delta);
|
14 | if (distance_delta>100)
|
15 | DistanceFlag=1;
|
16 | Delta=distance_delta;
|
17 | }
|
18 | }
|
The size of the program increased on>~10kB. Optimization: -O3 or -Os.
How I can reduse code size?
(For this functions normal size must by 2-3kB).