Page 1 of 7

working Assembler memin workareound!!!

Posted: Wed May 21, 2014 3:57 pm
by KG_is_back
This module is able to extract the pointer (address of first value) of a memory input. Now you can write your own custom wavetable and wave readers in assembler.

It is just a prototype to show the basic idea - I can't guarantee stability.

How I came up with it? Well I connected wave read primitive to analyzer and noticed that the analyzer shows the inner assembly code of the primitive. I noticed which value is the pointer of the memory connected to it. Extracting it automatically was then relatively easy.

Re: working Assembler memin workareound!!!

Posted: Wed May 21, 2014 10:04 pm
by TheAudiophileDutchman
Congrats, as a first impression it seems to work fine here! :D

Re: working Assembler memin workareound!!!

Posted: Wed May 21, 2014 10:20 pm
by martinvicanek
A real millennium hack! :mrgreen: :ugeek:
I wonder if something similar is possible for a mem[] array declared within code/ASM to pass it to another code/ASM block (as opposed to a wavetable). That would come in handy for stream FFT, no need to serialize the input/output, less delay. ;)

Re: working Assembler memin workareound!!!

Posted: Wed May 21, 2014 10:44 pm
by KG_is_back
martinvicanek wrote:A real millennium hack! I wonder if something similar is possible for a mem[] array declared within code/ASM to pass it to another code/ASM block (as opposed to a wavetable). That would come in handy for stream FFT, no need to serialize the input/output, less delay.


Yes, it should... If you connect anything to analyser primitive, you can see that variables are actually stored as doubleword at [ebp+N] (where N is a number). Maybe you can use multiplexer to switch one code to analyzer (opposed to mono stream) and readout the address.
However in this case it might be more wise to create a memory that is used by both assembly blocks. Trog proposed similar approach some time ago. He created a frame in Ruby code and passed the pointer to assembler which effectively created float array to mem (It works basically the same way as this one). I successfully used his module in many applications to pass arrays between assembler blocks.

Re: working Assembler memin workareound!!!

Posted: Thu May 22, 2014 3:24 am
by nix
It's a little bit OT,
but is there any way to create left and right float array,
to stereo mem?
You can do it by rendering, but this takes too much time.

Re: working Assembler memin workareound!!!

Posted: Thu May 22, 2014 10:12 am
by KG_is_back
nix wrote:It's a little bit OT,but is there any way to create left and right float array,to stereo mem?You can do it by rendering, but this takes too much time.

Stereo mem is a mem that has odd samples left channel and even samples right channel. Rendering is the only way.
you can render using Analyzer, which is quite fast though.

This ASM code should do it in single sample:

Code: Select all

streamin pointerL;
streamin pointerR;
streamin pointerSTEREO;
streamin Length;

int c=-1;

stage0;
push ebx;
cvtps2dq xmm0,Length;
paddd xmm0,c;
movaps c,xmm0;

loop1:
mov ebx,c[0];
shl ebx,2;
mov eax,pointerR;
add eax,ebx;
fld [eax];
mov eax,pointerL[0];
add eax,ebx;
fld [eax];
shl ebx,1;
mov eax,pointerSTEREO[0];
fstp [eax];
add eax,4;
fstp [eax];

mov eax,c[0];
add eax,-1;
mov c[0],eax;
cmp eax,0;
jnl loop1;

pop ebx;

Re: working Assembler memin workareound!!!

Posted: Thu May 22, 2014 2:22 pm
by KG_is_back
This should work with wave-array too (the code looks very similar) but I don't understand how the waves are written in the array (and how the wave-array read primitive works) can someone look into it please?

Re: working Assembler memin workareound!!!

Posted: Thu May 22, 2014 6:16 pm
by tester
KG_is_back wrote:This module is able to extract the pointer (address of first value) of a memory input. Now you can write your own custom wavetable and wave readers in assembler.

It is just a prototype to show the basic idea - I can't guarantee stability.

How I came up with it? Well I connected wave read primitive to analyzer and noticed that the analyzer shows the inner assembly code of the primitive. I noticed which value is the pointer of the memory connected to it. Extracting it automatically was then relatively easy.


Can't open. Immediately crashes my FS on initalization phase (no matter whether I dbclick on schematic or drag'n'drop onto open FS).

Re: working Assembler memin workareound!!!

Posted: Thu May 22, 2014 9:04 pm
by KG_is_back
tester wrote:Can't open. Immediately crashes my FS on initalization phase (no matter whether I dbclick on schematic or drag'n'drop onto open FS).


this one should open. You need to connect the assembler blocks to analyzers. The problem might be, that analyzers are initialized too early and zero address is passed to them. I will take a little tweaking green stuff to prevent that

Re: working Assembler memin workareound!!!

Posted: Thu May 22, 2014 11:06 pm
by tester
Hmm... Right at the moment when connecting to the analyzer - FS crashes. Maybe it has to do with system (XP here) or hardware architecture (C2D)?