[sdiy] Update - OT - Linear interpolation in C

Olivier Gillet ol.gillet at gmail.com
Wed Feb 2 15:19:59 CET 2011


> I thought some of you might be interested to see how I solved the fixed-point maths / linear interpolation problem I asked about the other day. Basically I followed the advice I got here, and put an assembly routine in to do the interp, which is then called from the C.
>
> It goes in its own source file ("assembly.s") and looks like this:
>
> ; Declare the functions as global so they're visible to C code
> .global _Lerp

The advantage of using inline assembly directly in the C code is that
you can get rid of the overhead of a function call - so there'll
probably less shuffling of data between registers which are useless
and only due to the fact that you must explicitly allocate registers
in assembly. I'm saying that without having seen the generated
assembly code, but my gut feeling with tiny embedded platforms is
"flatten things as early as possible in the compile/link/run" chain,
and having small chunks of assembly linked rather than inlined is one
phase too late to me.

Olivier



More information about the Synth-diy mailing list