Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Data type efficiency on ARM using IAR EWARM

Status
Not open for further replies.

joeman

Newbie level 3
Joined
Oct 6, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
France
Activity points
1,299
Hi All
I'm an ARM newbie, currently developing firmware project based on a ARM STM32L from ST (ARM Cortex M3).
I'm using IAR EWARM IDE and was wondering how to optimize my code.

Is it more efficient to use 32 bits data or 16 or 8 ?

For instance in a small loop for(i=0; i<10; i++), what is the more efficient way to declare i ?
As a 32 bits, 16 bits or 8 bits ?

Thanks in advance for any answer !
J
 

Hi,

As ARM is a native 32 core (int is 32 bits), it is better to declare 32 bits data.
the compiler will put a 8 bits data in a 32 bits box avoiding to use align directives.
If you want to use less memory use the THUMB mode, is like a native 16 bit core.
this mode was previosly used on ARM7TDMI.
Hope, i am not wrong because i worked 4 years on ARM systems but it was 2001.
joseMiguel
 
  • Like
Reactions: joeman

    joeman

    Points: 2
    Helpful Answer Positive Rating
Thanks for your answer.

You mean if I use 8 bits data, the compiler will add code for aligning data to 32 bits ?
If so, that would not be efficient at all !
 

First of all read compiler's guide provided at the "help" menu (for AVR it's there I think this will be the same for ARM). Maybe there you 'll get your explanation.
Furthermore the 32bit allignement may not be bad. You need more RAM that's for sure, but the execution speed gets improved. ARM is a 32-bit architecture so optimal code is for 32-bit data.

**broken link removed**
**broken link removed**


Hope this helps.
 
  • Like
Reactions: joeman

    joeman

    Points: 2
    Helpful Answer Positive Rating
Hi,
in an old ARM system architecture,
- ARM C compiler generally aligns data items on appropriate boundaries.
* Bytes are stored at byte address,
* Half-words are stored at even-byte addresses,
* Words are stored on four-byte boundaries.

where several items of different types are declared at the same time, the compiler will introduce padding where necessary to achieve this alignement.
joseMiguel
 
  • Like
Reactions: alexxx

    alexxx

    Points: 2
    Helpful Answer Positive Rating
Thanks to all of you !
Will use u32 data type when possible !
J
 

joeman said:
Will use u32 data type when possible !

I assume it is always possible, except when you need 64-bit data!;-)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top