SynthMaker

undocumented assembler instructions

Archive · 2009 7 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

MyCo ·

Hi!

I've found some supported assembler instructions that are not documented (in the wiki "list of opcodes"). They might be usefull:

shufps - very useful when you work with packed mono, because you can exchange the channels or spread them to do 4 similar calculations at once pslld - can be used to do power of 2 multiplications on integers pand - AND for integers, but works on float, too... haven't found any difference to andps yet, but S|M uses it internal quiet often

MyCo ·

Here is an example for using shufps. The idea is to have a stereo signal packed this way: 1: left 2: right 3: left 4: right

now the code does nothing else than process only channel 3 and 4 and let the channels 1 & 2 untouched. So you have on the first 2 channels the original signal and on the other 2 channels, you have a processed signal. In the demonstration the processing is just: out = in*2 ... since there are two of the modules in series the output is out = in*4

bootsy ·

Cool, so we can save the unpack/pack overhead when the processing sometimes differs on the channels ... P.S.: Where can we find the codes for the parameters?

trogluddite ·

I'll try and explain my understanding of the shufps opcodes, but I' not sure I'm up to it... 😕

The first parameter is always an xmm register, the second is an xmm register or a memory location and behave like normal...

shufps xmm1, xmm2, X

Will take values from xmm1 and xmm2 abd leave the result in xmm1 like you would expect.

The packed mono data keeps four float numbers in each register, so for the above example

xmm2[3] xmm2[2] xmm2[1] xmm2[0] (call this the dource) xmm1[3] xmm1[2] xmm1[1] xmm1[0] (call this the destination)

With shufps you can take any pair of numbers from the 'source' and any pair from the 'destination' and leave that output in the destination.

To understand the value X you need to know a bit of binary. The last operand (X) is always an eight bit binary number (0-255 in decimal), but it is made up of four two-digit binary numbers (each representing 0-3 in decimal).

Bits 2/1 says which of the four numbers from the destination will end up as number [0] in the ourput Bits 4.3 says which of the four numbers from the destination will end up as number [1] in the output Bits 6/5 says which of the four numbers from the source will end up as number [2] in the output Bits 8/7 says which of the four numbers from the source will end up as number [3] in the output

So iff X=228...

228 Decimal = 11 10 01 00 Binary. The four 2bit numbers encoded in here are 3,2,1,0 in decimal.

bits 2/1 of X have value 0 so the output in xmm1[0] will come from xmm1[0] nits 4/3 of X have a value 1 so the output in xmm1[1] will be from xmm1[1] bits 5/6 of X have a value 2 so the output in xmm1[2] will be from xmm2[2] bits 7/8 of X have a value 3 so the output in xmm1[3] will be from xmm2[3]

so we've left streams [1] and [0] of xmm1 intact but exchanged [3] and [2] for the values in xmm2

So for shufps xmm1,xmm2,39 the last operand is 00 10 01 11 Binary. Then the output becomes ... xmm1[0]=xmm1[3] xmm1[1]=xmm1[1] xmm1[2]=xmm2[2] xmm1[3]=xmm2[0]

Hope that's clear - it bent my brain for quite a while. Let me know if it's useful (or even correct!)- if so, I'll get it up on the Wiki.

The Luddite

infuzion ·

trogluddite wrote: Hope that's clear - it bent my brain for quite a while. Let me know if it's useful (or even correct!)- if so, I'll get it up on the Wiki.

That is a good explanation. And thank you very much for working on the WiKi, I'm kinda burned out on it & only put entries anymore for my own personal reference (though everyone can see it).

I think the best shufps tutorial is this one: http://www.songho.ca/misc/sse/sse.html The pictures really do help, & makes general SSE math easier to understand. Perhaps you can email him to mirror, or just make an "inspired" version.

stw ·

infuzion wrote: I think the best shufps tutorial is this one: http://www.songho.ca/misc/sse/sse.html The pictures really do help, & makes general SSE math easier to understand. Perhaps you can email him to mirror, or just make an "inspired" version.

That's really a good one. A picture is worth more than a thousand words! 🙂 Thanks for the link.

infuzion ·

stw wrote: infuzion wrote: I think the best shufps tutorial is this one: http://www.songho.ca/misc/sse/sse.html The pictures really do help...

That's really a good one. A picture is worth more than a thousand words!

You're welcome! Took me a while to wrap my mind around: 1) XMM memory slots go from right to left, so slot 0 is the right most, & 3 is on the left 2) the flag reordering bit layout is source source destination destination Also thank Trig, since if he didn't post, I like would not either. 😉

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.