Embedded Software Blog

Posts tagged with 'Optimization'

Efficient code - quiz answers

Posted Oct 10, 2011, by Colin Walls

Two weeks ago, I set a quiz. I listed four ways to write some code, which was supposed to divide an unsigned integer by 8. I commented that the priority was for the code to be as fast as possible and asked which of my lines of C was most efficient. I was pleased with the response and acknowledge contributions from Peter Bushell, Dan S, Ken Simone, Krzysztof Wesołowski, Lee Riemenschneider, and Shaun … Read More

Tags: Development Tools, C, Optimization, Programming Languages

Efficient code - a quiz

Posted Sep 26, 2011, by Colin Walls

I was recently reading a set of “golden rules” for embedded programming. I am very skeptical about such proscriptive instructions as, for them to be valid, a great many assumptions must be made and clearly stated. These rules were supposed to promote the production of safe, efficient code. I am OK with “safe” – that simply means that the code does what it is supposed to … Read More

Tags: Development Tools, C, Optimization, Programming Languages

Instrumentation

Posted Aug 22, 2011, by Colin Walls

Embedded software development tools are important to all developers and a topic that I frequently discuss [like here]. The way such tools are described by vendors is interesting. For example, there might be a reference to an “optimizing compiler”. That is rather meaningless, as all compilers are optimizing to at least some degree. For an embedded compiler, the important factors are the quality … Read More

Tags: RTOS, Development Tools, Debugging, Optimization, profiling, Nucleus

Get packing

Posted Aug 8, 2011, by Colin Walls

I have frequently made the observation that a key difference between embedded and desktop system programming is variability: every Windows PC is essentially the same, whereas every embedded system is different. There are a number of implications of this variability tools need to be more sophisticated and flexible; programmers need to be ready to accommodate the specific requirements of their system; … Read More

Tags: Optimization, Development Tools, Programming Languages

Firmly in line

Posted Nov 22, 2010, by Colin Walls

A common compiler optimization is the inclusion of a function’s code at the location(s) from where the function is called, instead of just having calls to the code located elsewhere: inlining. This provides a speed advantage, as the call/return sequence is eliminated, but may increase the memory footprint, if the function is more than a few instructions and is called more than once. I have written … Read More

Tags: Inline, Programming Languages, Optimization, Development Tools, C

Staying in line

Posted Feb 22, 2010, by Colin Walls

The idea of inlining code - placing the actual code of a small function at each call site - is a well known compiler optimization, which I have discussed before. This technique can provide significant performance improvements, due to the elimination of the call/return sequence. Also, stack usage is reduced. There is a possible cost in terms of increased program memory requirement. It is reasonable … Read More

Tags: C, Optimization, EDGE Compiler, Programming Languages, Inline

Small or fast?

Posted Jan 11, 2010, by Colin Walls

Life is often about compromise, but embedded developers really are not good at that. Code generation is a context in which compromise is somewhat inevitable and we call it “optimization”. All modern compilers perform optimization, of course. Some do a better job than others. A lot of the time, the compiler simply guesses which optimization will produce the best result without knowing what the designer … Read More

Tags: C, Optimization, EDGE Compiler, Low Power, Power

++i or i++?

Posted Aug 10, 2009, by Colin Walls

If you are reading this blog, you are probably knowledgeable about embedded software and, therefore, like me, you consider yourself proficient in C. C is still the dominant language for embedded work. I read an article recently which espoused the view that “real men program in C” - I rather liked that. It also suggested that, since relatively few new graduates know C, there is an increasing shortage … Read More

Tags: C++, Optimization, EDGE Compiler