EmbDev.net

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


Author: artjom7111 qwe (Company: Noname) (artjom7111)
Posted on:

Rate this post
0 useful
not useful
Hi.
I write programs for LPC Cortex-M0.
I need to use the cos and sqrt functions from math.

Program:
#include <math.h>
volatile float DeltaX=50, DeltaY=120, Angle=3.14/4;
volatile float Delta;
volatile unsigned char DistanceFlag;


void Func() {

    float dx=DeltaX, dy=DeltaY, angle=Angle, distance_delta;
    dx=dx*cos(angle);
    dx=dx*angle*3.14;
    distance_delta=dx*dx+dy*dy;
    distance_delta=sqrt(distance_delta);
    if (distance_delta>100)
      DistanceFlag=1;
    Delta=distance_delta;
  }
}
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).

Author: Krapao (Guest)
Posted on:

Rate this post
0 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.

Author: artjom7111 qwe (Company: Noname) (artjom7111)
Posted on:

Rate this post
0 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?

Author: Krapao (Guest)
Posted on:

Rate this post
0 useful
not useful
Attention: AVR-GCC
gcc version 4.7.0 20120217 - by SRMeister (GCC) 
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'

Author: artjom7111 qwe (Company: Noname) (artjom7111)
Posted on:

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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.