EmbDev.net

Forum: ARM programming with GCC/GNU tools Yagarto & math.h


von artjom7111 q. (Company: Noname) (artjom7111)


Rate this post
useful
not useful
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).

von Krapao (Guest)


Rate this post
useful
not useful
>   }
Error: no matching {

> (For this functions normal size must by 2-3kB).
OK.

On AVR-GCC 4.7.0 (i have no Yagarto installed):
.text (Code) size is 1462 Bytes (with minimal main()); .data size is 12 
Bytes and .bss is 5 Bytes
size of elf file is 18471 Bytes (with debug symbols, not stripped)
size of hex file is 4170 Bytes

> How I can reduse code size?
Analyze the output of the toolchain esp. the *.lss and *.map files.

von artjom7111 q. (Company: Noname) (artjom7111)


Rate this post
useful
not useful
>Error: no matching {
Copy-paste error...

>.text (Code) size is 1462 Bytes (with minimal main()); .data size is 12
>Bytes and .bss is 5 Bytes
Good result.
What options were used?

von Krapao (Guest)


Rate this post
useful
not useful
Attention: AVR-GCC
1
gcc version 4.7.0 20120217 - by SRMeister (GCC) 
2
COLLECT_GCC_OPTIONS='-mmcu=atmega16' '-I' '.' '-v' '-gdwarf-2' '-Os' '-funsigned-char' '-funsigned-bitfields' '-fpack-struct' '-fshort-enums' '-Wall' '-Wstrict-prototypes' '-std=gnu99' '-D' 'F_OSC=3686400' '-MD' '-MP' '-MF' '.dep/main.elf.d' '-o' 'main.elf'

von artjom7111 q. (Company: Noname) (artjom7111)


Rate this post
useful
not useful
I think that the result should be better on ARM.
I have enough single accuracy(float).

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.