[sdiy] Some Audio DSP prototypes

sleepy_dog at gmx.de sleepy_dog at gmx.de
Wed Apr 20 21:18:06 CEST 2022


Ingo Debus via Synth-diy:
> On my day job, I had written programs for the 8051 (only 256 bytes of
> RAM! Certainly not more powerful than a PIC) in C for many years. In
> fact, C can be easier on RAM than assembly language, since in assembly
> there’s no such thing as local variables.
> And regarding program memory usage: in the beginning I tried to
> outsmart the compiler (counting a loop counter down rather than up),
> hoping the compiler would use the DJNZ instruction. DJNZ (decrement
> and jump if not zero) is a powerful 8051 instruction for creating
> loops. Then I looked at the code the compiler had created: no DJNZ in
> there. Looking closer I found that the compiler’s solution was shorter
> and faster than the one I had in mind.
>
> Look at Arduino: tons of programs for the low-end 8 bit AVR, all
> written in C++. I really don’t get it why the PIC guys stick to
> assembly language.

I never was an asm guru, but somewhat adequate in the late 1990s when I
could not afford the paid version of MSVC when getting into gamedev, so
I used the "for students" compiler which did not optimize. So I rolled
my most frequently called functions in asm, which worked nicely back then.
Indeed after compiilers got ever better at optimizing, I stopped that
almost entirely.
Only for some vector instruction stuff like NEON on ARM, or SSE2 on
Intel, I did a little bit of assembly a couple years ago, as I couldn't
get the C++ intrinsics to work as fast as promised, and the asm versions
did (with lots of help of people who know that stuff in their sleep, I
do this too infrequently to get the best results, esp. in time)
I imagine it could be possible that I could get a bit more out of a
slower MCU where I need as much as possible e.g. in an interrupt, and
that's done in a few tailored asm instructions. I haven't tested that
idea, since I didn't have the scenario that something was just barely
not fast enough to work with a chosen MCU. Although in my job of the few
past years it's not about mass production. I guess if it's important to
use the cheapest possible MCU, not just some ballpark adequate one, it
could be different.




More information about the Synth-diy mailing list