Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

How to not become crazy in dsp and asm ;)

DSP related issues, mathematics, processing and techniques

How to not become crazy in dsp and asm ;)

Postby Tepeix » Tue Mar 08, 2022 2:02 pm

Almost every time i write a code in dsp or asm i have i first bad impression that nothing works !)
Then i place a DS or Asio out in my shematics and it begin to works !)
Very fast now to realize that !) Almost a reflex.

Now in asm i find a serious way to become crazy for a longer time !)
Crying that something is not right ! Copying and erasing every complex part of the code.
To have just the simplest movaps out,xmm0; not working !
Restarting the application...
Then i realize that the first thing to check is that all variable or input output have the exact same name.

I was using streamout done; But i completely forget that and the compilator say nothing when we use an undeclared variable like movaps out,xmm0 in this case... ...

Did you have other's thing that become a reflex to checks first when the code is not working ?
Last edited by Tepeix on Tue Mar 08, 2022 4:00 pm, edited 1 time in total.
Tepeix
 
Posts: 350
Joined: Sat Oct 16, 2021 3:11 pm

Re: How to not become crazy in asm ;)

Postby Spogg » Tue Mar 08, 2022 2:25 pm

After about 7 years I can finally write small bits of DSP that actually work first time! Sometimes! :lol:

One thing I find useful for DSP is

Code: Select all
streamout test;
test = counter;

The test output allows me to check any part of the code to see what’s going wrong.

In my view so much can be wrong and what’s right is tiny in comparison. That means it’s hard to offer advice, but I can say that experience is the key. I got quicker at finding my mistakes over time.
User avatar
Spogg
 
Posts: 3318
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: How to not become crazy in dsp and asm ;)

Postby Tepeix » Tue Mar 08, 2022 4:36 pm

Very good advice !)
If i have done that always using test to debug i will not have problem with other's syntax !

Now i get another despair.)

Trying to use cmp eax,4095; or any number.

if i assign a negative value to eax it will do like -1 is greater to 4095 !
So i try add eax,1; before cmp eax,4095. Not working..
inc [eax]; crash it !
eax come from xmm0. So i try to paddd xmm0,inc. Not working... ,)

Now i could transform xmm0 in a float with cvtdq2ps, use addps to add a float of 1.
Transform now in a int with cvtps2dq. So now eax must be 0 like xmm0.

But even like this cmp eax refuse to works...

So i suppose that we could not use a int value that was negative when using eax ???

Here's the code if some want to see.
Attachments
cmp eax with negative.fsm
(52.17 KiB) Downloaded 453 times
Tepeix
 
Posts: 350
Joined: Sat Oct 16, 2021 3:11 pm

Re: How to not become crazy in dsp and asm ;)

Postby Spogg » Wed Mar 09, 2022 9:53 am

I’m not into ASM so I hope someone else can chip in…
User avatar
Spogg
 
Posts: 3318
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: How to not become crazy in dsp and asm ;)

Postby martinvicanek » Wed Mar 09, 2022 1:23 pm

@Tepeix, towards the end of your ASM code there is an instruction
addps xmm0,inc;
addps adds floats, but inc is an integer (and so is xmm0). You have to use paddd instead of addps.

General comment regarding the topic: Yes, ASM has an extraordinary potential to drive you mad. :mrgreen: Perhaps the worst errors are undeclared or doubly declared variables. Sometimes the code will execute as expected without problems, sometimes it will produce garbage, and sometimes it will crash Flowstone. Fortunately, these issues are highlighted in FS alpha codebox and thus easily avoided. I have made it a habit to check the more complex ASM codes in FS alpha.
User avatar
martinvicanek
 
Posts: 1315
Joined: Sat Jun 22, 2013 8:28 pm

Re: How to not become crazy in dsp and asm ;)

Postby Tepeix » Wed Mar 09, 2022 8:19 pm

Thanks !)
Correcting this line, now it works to compare negative integer.)
That incident make me falsely believe that compare with a negative eax was not possible !

That's a surprising bug. The paradox is that if the bug occurs the line that make it happen is supposed to be skip.

In my version 3.6. It's not possible to paddd xmm0,xmm1;
So i'm tempted to use addps if it works to not use a variable.
But now i know it could make some things not works..
Tepeix
 
Posts: 350
Joined: Sat Oct 16, 2021 3:11 pm

Re: How to not become crazy in dsp and asm ;)

Postby martinvicanek » Wed Mar 09, 2022 9:36 pm

Tepeix wrote:In my version 3.6. It's not possible to paddd xmm0,xmm1.

You can add eax,1; in 3.0.6 :)
User avatar
martinvicanek
 
Posts: 1315
Joined: Sat Jun 22, 2013 8:28 pm

Re: How to not become crazy in dsp and asm ;)

Postby Tepeix » Thu Mar 10, 2022 11:37 am

Yes, but it's another case where i need to add in SSE 4 different integer.
But finally i check those code and find i use later another way.)

The idea was to calculate 1 index and 1 or 3 delay in the same variable.
And, that's not so much practical ,) But could have some use if some want the same delay for a stereo signal.

In first attempts i addps index and delay as integer. But finally it's possible to paddd with the index variable..

By the way, i never could do this without yours delays ! Thanks !!!)

So the idea is to write once, 2 channels and the same + 1 sample.
Then to read the array twice to get 2 stereo interpolated delay.

Well some "non-sense optimization" but i learn a lot trying this !)
Attachments
spDelay2.fsm
(78.1 KiB) Downloaded 436 times
Tepeix
 
Posts: 350
Joined: Sat Oct 16, 2021 3:11 pm


Return to DSP

Who is online

Users browsing this forum: No registered users and 23 guests