[..]
If I rationalize: on low-end platforms (PIC..) that I often use, RAM
size is a few hundred bytes and program space a few kbytes, so every
byte counts. Even on relatively powerful CPUs (Arm, x86) and when memory
is not an issue, using one more register may force the shift of
something into memory rather than in a register, or/and a little extra
code could abruptly reduce cache efficiency, and in turn slow down
things considerably. I bet I could construct an articial demo where the
suggested change increases execution time/power draw quite perceptibly,
say by 30%.
Francois Grieu
If such finegrained control is needed, wouldn't you be better off
using assembly? Most uC targeted compilers i know of mix the two quite
well.
From what i read portability isn't a great concern, since you're quite
specific on the platform, so that can't be the issue.
Have you ever used assembly on a microcontroller? Many of the
widely-used Atmel uCs, for example, don't have a multiply instruction.
They cannot do calculations on any integers larger than 8 bits
directly. There is no "add immediate" instruction either; you have to
negate the value and use "subtract immediate" instead. Letting the
compiler handle things like 16-bit multiplication certainly makes
things a lot easier.
Programming uCs in assembly is hard, error-prone, and the code will not
be easy to maintain. If anyone says they would rather program uCs in C,
they certainly have a point.