working Assembler memin workareound!!!

Post any examples or modules that you want to share here
Post Reply
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

working Assembler memin workareound!!!

Post 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.
Attachments
alternative memin.fsm
(1.13 KiB) Downloaded 1369 times
User avatar
TheAudiophileDutchman
Posts: 46
Joined: Tue Jul 13, 2010 1:36 pm
Location: Apeldoorn, The Netherlands

Re: working Assembler memin workareound!!!

Post by TheAudiophileDutchman »

Congrats, as a first impression it seems to work fine here! :D
T A D - since 2005
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: working Assembler memin workareound!!!

Post 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. ;)
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: working Assembler memin workareound!!!

Post 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.
User avatar
nix
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: working Assembler memin workareound!!!

Post 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.
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: working Assembler memin workareound!!!

Post 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;
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: working Assembler memin workareound!!!

Post 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?
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: working Assembler memin workareound!!!

Post 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).
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: working Assembler memin workareound!!!

Post 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
Attachments
alternative memin.fsm
(1.13 KiB) Downloaded 1321 times
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: working Assembler memin workareound!!!

Post 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)?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Post Reply