1
Getting the Getting the Least Out Least Out
- f
- f Your
Your C C Compiler Compiler
Embedded Embedded Systems Systems Conference Conference San Fransisco 2001 San Fransisco 2001 Class Class #508 #508
Jakob Engblom Jakob Engblom
Strategic Development IAR Systems jakob.engblom@iar.se
- Dept. of Computer Systems
Uppsala University, Sweden jakob@docs.uu.se
2
This Class This Class
- Coding tips and usage tips for C
Coding tips and usage tips for C
- To keep code size down
To keep code size down
- To help the compiler optimize
To help the compiler optimize
- Assumed background:
Assumed background:
- Embedded Systems Hardware
Embedded Systems Hardware
- Embedded Systems Software
Embedded Systems Software
- C Programming
C Programming
- Level: basic
Level: basic
3
The Target Systems The Target Systems
- Microcontrollers:
Microcontrollers:
- CPU Core
CPU Core
- Integrated memory
Integrated memory
- Integrated peripherals
Integrated peripherals
- Integrated services
Integrated services
- “System on a chip”
“System on a chip”
- 8-16 bit most
8-16 bit most common common
CPU Core RAM (small) ROM (big)
UART A/D Timer LCD D
Outside World Outside World
4
Why Care About Size? Why Care About Size?
- Keep memory cost down
Keep memory cost down
- Avoid external memory
Avoid external memory
- Use smaller external memory
Use smaller external memory
- Use a smaller derivative
Use a smaller derivative
- Keep absolute limits
Keep absolute limits
- HW done before the software
HW done before the software
- Application can only
Application can only use on-chip memory use on-chip memory