Page 1 of 1

Is ASM faster or better than DSP?

PostPosted: Wed Jun 10, 2015 8:36 am
by Spogg
Hi all

Simple question (I hope!). I see that quite a few people create DSP code blocks then convert the compiled code to ASM.
Why? Is it faster, more accurate or what?
When I've done this myself I can't detect any improvement.

Cheers

Spogg

Re: Is ASM faster or better than DSP?

PostPosted: Wed Jun 10, 2015 10:08 am
by adamszabo
ASM is the closest code to give instructions to the CPU. The DSP code will anyway be converted into ASM no matter what, but sometimes its not as "smart", and compiles the code with unnecessary instructions. If you learn to write your code from scratch in assembly you can really optimize it well and it will be faster than the DSP code.

Re: Is ASM faster or better than DSP?

PostPosted: Wed Jun 10, 2015 10:18 am
by Tronic
Hi Spogg,
the improvement is how you optimize the assembler code.

this is the result of original compiled abs function:
Code: Select all
streamin in;
streamout out;

float smIntVarTemp=0.0;
float smIntVarZero=0;

movaps xmm0,in;
movaps smIntVarTemp,xmm0;
cmpps xmm0,smIntVarZero,6;
andps xmm0,smIntVarTemp;
addps xmm0,xmm0;
subps xmm0,smIntVarTemp;
movaps out,xmm0;


thi is the optimized version:
Code: Select all
streamin in;
streamout out;

int absMask=2147483647;

movaps xmm0,in;
andps xmm0,absMask;
movaps out,xmm0;

Re: Is ASM faster or better than DSP?

PostPosted: Wed Jun 10, 2015 11:08 am
by Spogg
Ahhh! Thanks for that guys, now I get it. :)
Thanks for the answers.
Spogg

Re: Is ASM faster or better than DSP?

PostPosted: Thu Jun 11, 2015 8:29 pm
by Nubeat7
just in case if someone asks himself where tronic got the original abs code from, just use the "S" output on the DSP module, this is the ASM code version from your DSP code as text, which you can now copy - paste into the ASM moduleand optimize it there..

if you are interested in optimizing your DSP codes and ASM codes you should have a look to KG's great articles on flowstone guru:

http://flowstone.guru/blog/optimizing-d ... component/
http://flowstone.guru/blog/optimizing-c ... assembler/
http://flowstone.guru/blog/advanced-dsp ... tion-tips/

Re: Is ASM faster or better than DSP?

PostPosted: Fri Jun 12, 2015 10:03 am
by Spogg
Many thanks for that Nubeat7. Some great info there.
Cheers
Spogg