HardwareHeaven.com
Looking for the skin chooser?
 
 
  • Home

  • Reviews

  • Articles

  • News

  • Tools

  • GamingHeaven

  • Forums

  • Network

 

Go Back   HardwareHeaven.com > Forums > Hardware and Related Topics > kX Project Audio Driver Support Forum > Effects and the DSP


Reply
 
Thread Tools
Old Jun 1, 2009, 11:21 AM   #1
HardwareHeaven Newbie
 
Join Date: Apr 2009
Posts: 10
Rep Power: 0
vax71 is on a distinguished road

??? 'Skip' instruction : how does this work ?

Hello

According to as10k1 manual (and other documents) the skip instruction can test many mix of the 5 lsb of any register. For example (AFAIU) a test value of 11101 00010 (binary, 10 lsb) should trigger a skip when the 5 lsb of the tested register are 00010 = 0x02 (bits 0,2,3,4 unset and bit 1 set). This would be a short (space saving) way of testing small integer value from 0 to 31.

But i cannot get it work.
I miss something! Any advice ? Thks.

Xavier
vax71 is offline   Reply With Quote


Old Jun 1, 2009, 08:10 PM   #2
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,507
Rep Power: 61
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Re: 'Skip' instruction : how does this work ?

It is not any register, it is the Condition Code Register that is checked...

i.e.
You are testing the flags that were set by the previous instruction.
Russ is offline   Reply With Quote
Old Jun 1, 2009, 10:11 PM Threadstarter Thread Starter   #3
HardwareHeaven Newbie
 
Join Date: Apr 2009
Posts: 10
Rep Power: 0
vax71 is on a distinguished road

Re : 'Skip' instruction : how does this work ?

Are you sure ?
AFAIK the 'skip R,A,X,Y' instruction does :
1) move A to R
2) test A according to X
3) skip (or not) Y instructions
The A operand can be any register (any operand can be any register). One can use this for 'if/then/else' structure : the 1st skip save the CCR, and the 2nd one test the saved value.
If I'm wrong then either all documents are wrong either I'm an idiot, and I'm not, for sure

Well *cough* maybe I am, as I can not figure out how works step 2)
vax71 is offline   Reply With Quote
Old Jun 2, 2009, 12:50 AM   #4
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,606
Rep Power: 66
Max M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to all

Ответ: 'Skip' instruction : how does this work ?

i'm not 100% sure as well, but i agree with Russ.
I suppose the "skip" tests the CCR to X, while the A register is just copied to R.
(e.g. to test "any" register you still need two skip instructions, first one to copy A to CCR so that the second one can actually test it).
Though i'd better base on real execution tests.

>If I'm wrong then either all documents are wrong either I'm an idiot,

Could you give some quotes please?
__________________
Max M. is offline   Reply With Quote
Old Jun 2, 2009, 12:57 AM   #5
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,507
Rep Power: 61
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Re: 'Skip' instruction : how does this work ?

Yeah, I do not know... It only seems to work if the 'A' operand is 'CCR'.

I realize that the as10k1 manual says differently (and the guide written for kX basically just repeats the same info), but that is the only way it seems to work. Even saved CCR's do not seem to work...

Also the docs describing the FX8010 architecture do not talk about the 'R' or 'A' operands of the skip instruction (but it does say that tests of the Condition Code Register are used to determine whether or not to skip), but does say that the 'X' (ccr mask) and 'Y' (skip count) operands can be regular GPR's.

BTW: IIRC there is more info about the skip instruction in one of the patents, but I do not remember which patent, and a lot of the links appear to be dead.

Last edited by Russ; Jun 2, 2009 at 01:22 AM.
Russ is offline   Reply With Quote
Old Jun 2, 2009, 01:40 AM   #6
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,606
Rep Power: 66
Max M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to all

Ответ: 'Skip' instruction : how does this work ?

The "skip" execution is described in details in Processor with instruction set for audio effects
But its "language" seems to be intentionally "blurred" (as most patents do) and may contain misdirections (like swapped X/Y or shuffled test masks) so i would not rely on that too much.
The as10k1 manual mentions "any register" only in context of "an always skip" (which could be a reasonable simplification, especially considering the times it was written).
__________________

Last edited by Max M.; Jun 2, 2009 at 02:45 AM. Reason: just some corrections for my charming english :)
Max M. is offline   Reply With Quote
Old Jun 2, 2009, 02:02 AM   #7
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,507
Rep Power: 61
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Re: 'Skip' instruction : how does this work ?

Yeah, that is the patent I was thinking of
Can also be found here: Processor with instruction set for audio effects - Patent # 5930158 - PatentGenius
Russ is offline   Reply With Quote
Old Jun 2, 2009, 03:24 AM   #8
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,606
Rep Power: 66
Max M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to all

Ответ: 'Skip' instruction : how does this work ?

btw., i'm just curious what could be an application of testing lower 5 bits of a GPR?
(well, personally, i always prefer to go a "math" way rather then with an explicit branch (even in higher level languages) - i'm mentioning it just because there's a chance that even more optimal (comparing to "one skip") solution can exist).
(in other words: "instead of coding separate blocks 'A' and 'B' and switching them by 'skip' it could be possible to make a block 'C' which can do 'A+B' job while controled by some value 'X' produced by some non-linear maths of the 'wrap, limit, andxor, tstneg etc.' stuff" - to see what i mean check out http://www.hardwareheaven.com/effects-...ossfading.html )
__________________
Max M. is offline   Reply With Quote
Old Jun 2, 2009, 09:02 AM Threadstarter Thread Starter   #9
HardwareHeaven Newbie
 
Join Date: Apr 2009
Posts: 10
Rep Power: 0
vax71 is on a distinguished road

Re : 'Skip' instruction : how does this work ?

The 2-instruction code :
Code:
macints 0,reg,-1i,value
skip 0,CCR,8,somewhere
might be turn to a single instruction:
Code:
const test_mask = value + ~value << 5
skip 0,reg,test_mask,somewhere
This would work for 5 bits values only.
'test_mask' is computed according to both documents : as10k1 manual and the patent.

This might be useful in case of piecewise functions, where the tested register contains a stage number from 0 to 31. I can think of an ADSR-like envelop generator, or a complex saw/tri/sqr wave generator.
Code:
interp res, V1, pos, V2
skip 0,stage,stage0_mask, 3i
interp res, V2, pos, V3
skip 0,stage,stage1_mask, 1i
interp res, V3, pos, V4
macs output, 0, res, volume
The usual code for that needs 2 more macs instructions.
But maybe one can do that with less than 5 instructions without any skip

If the docs are correct, more complex tests might be done.
For example, reg <>15 (01111) might be tested with:
Code:
test_mask = 1 << 30 // select OR function -- not sure
            + 15 << 5 + ~15
Thank you for your answers. If I can make it work I'd be back
vax71 is offline   Reply With Quote
Old Jun 3, 2009, 12:40 AM   #10
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,507
Rep Power: 61
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Re: 'Skip' instruction : how does this work ?

I do not think you are calculating the masks correctly.

The way I take it is that you just mask off the bits you want to check, where the bits look like this:
..9.......................5....4.................. .0..
[!S] [!Z] [!M] [!B] [!N] [S] [Z] [M] [B] [N]

For each 10 bits (the upper 5 bits are for testing the inverses of the lower 5 bits (i.e. for testing that a flag is not set)). The 2nd (bits 10..19) and 3rd (bits 20..29) groups of 10 are for additional (optional) tests. (with the remaining 2 bits being used to select one of the 4 forms).

So if you want to test for [!Z] (not zero) your mask has a 1 at bit position 8. (1 << 8 = 256 (or if you prefer: (1 << 3) << 5 = 256):
skip r, ccr, 0x100, count;

Or if you want to test for [M][!S] (non-saturated negative), you would mask bits 2 and 9. ((1 << 9) + (1 << 2) = 516)
skip r, ccr, 0x204, count;

Or a more complex example, where maybe you want to test [M][!S] OR [!M][!Z][!S] (non-saturated negative OR non-saturated positive), you could masks bits 7,8, and 9 for the second part and shift them into bit positions 10..19, and add with the mask for the first part (same as previous). ( ((1 << 7) + (1 << 8) + (1 << 9) ) << 10) + 516 = 918020
skip r, ccr, 0xe0204, count;

Also, with all the different options (flag combinations and mask forms) it seems there are multiple ways that you could test for the same flags (i.e. with the above [!Z][!S] (as well as some other masks) should give same result).

In any case, that is how I think the masks work (something like that), but I would have to do a bit of testing to be sure (but I have never really needed anything beyond the basic stuff, so...).

Last edited by Russ; Jun 3, 2009 at 12:45 AM.
Russ is offline   Reply With Quote
Old Jun 3, 2009, 10:38 AM   #11
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,606
Rep Power: 66
Max M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to all

Ответ: 'Skip' instruction : how does this work ?


(using small font as being quite off-topic)

Quote:
where the tested register contains a stage number from 0 to 31
Yes, if initial task is set as "break the algo into independent execution paths and switch/case each path on integer encoded stage mark" then it's not too much you can do about that.
However in most cases such explicit switching is not really necessary (especially "integer stage encoding").

Quote:
I can think of an ADSR-like envelop generator, or a complex saw/tri/sqr wave generator.
I see. Well, the ADSR stuff could be a good example, as beside explicit "skip" instructions, the "split/skip" flow for it also will need additional instructions to encode the stages into integers (while the stages are already sit inside control signals and the envelope itself) as well as more extra code to properly sew and scale each stage together.

To illustrate that the other way around could be much more optimal i've sketched a less or more complete ADSR module that uses no skips. Take a look (i made the module to be somewhat compatible with http://www.hardwareheaven.com/effects-...ystem-1-a.html so that it can be evaluated easier):
adsr.da.txt
(note that i did not optimize its register usage for better readability (for example all five temp registers maybe merged into one, etc.)).

..................................................

Well, either way, the "split/skip" flow is more straightforward to code - so it's nothing wrong with it in general. And, after all, considering the overall count of instructions for a typical module, two more or less instructions of 20 (for example) may be not so important.
But if you're looking for really optimal code, the first thing to consider is "can i do that without explicit branches?".
__________________

Last edited by Max M.; Jun 3, 2009 at 11:09 AM. Reason: updated adsr.da.txt with better comments
Max M. is offline   Reply With Quote
Old Jun 3, 2009, 12:17 PM Threadstarter Thread Starter   #12
HardwareHeaven Newbie
 
Join Date: Apr 2009
Posts: 10
Rep Power: 0
vax71 is on a distinguished road

Re : 'Skip' instruction : how does this work ?

Russ:
Quote:
I do not think you are calculating the masks correctly.
Your explanation conforms to what I understand from the patent document. So I still can not see my mistake.
Code:
const test_mask = value + ~value << 5
AFAIU with 'value' I test the set bits and with '~value' I test the unset bits.
I have to check my code once again...

Max:
Quote:
(using small font as being quite off-topic)
'Quite', but very instructive
A question: do you get 'linear' response ?
My 'interp res, V1, pos, V2' is linear from V1 to V2, but i understand that your 'interp a,1,ak,a' in something like 1-exp(-a.t). Maybe it's not very important, but I imagine the attack is smoother.

Many thanks!

Last edited by vax71; Jun 3, 2009 at 02:39 PM.
vax71 is offline   Reply With Quote
Old Jun 3, 2009, 01:18 PM   #13
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,507
Rep Power: 61
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Re: 'Skip' instruction : how does this work ?

OK, I see, I misunderstood something in your code .
Russ is offline   Reply With Quote
Old Jun 3, 2009, 02:56 PM   #14
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,606
Rep Power: 66
Max M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to all

Ответ: 'Skip' instruction : how does this work ?

yes, all three curves are exponential (or logarithmic, depending on point of view) - something like that.
But they can be changed to linear too. For example attack becomes linear when its interp replaced with just "a + ak" (this needs corresponding modification of the ak coefficient computation of course). Same for release (assuming inverse direction). The decay will need some deeper changes (as it won't longer "stop" at sustain level) - but yep, these are details i guess.
A lot of little modifications are possible, here and there, as always, each having its unique applications.
(different curves for different synths. personally i think that some kind of semi-logarithmic curve for attack is probably more universal, while decay and release are better to be fully exponential/logarithmic).
With a posted module i just tried to somewhat mimic the kxm400 behaviour roughly - though it's not identical of course.
__________________

Last edited by Max M.; Jun 6, 2009 at 10:57 AM. Reason: link make up
Max M. is offline   Reply With Quote
Old Jun 3, 2009, 04:19 PM Threadstarter Thread Starter   #15
HardwareHeaven Newbie
 
Join Date: Apr 2009
Posts: 10
Rep Power: 0
vax71 is on a distinguished road

Re : 'Skip' instruction : how does this work ?

The non linear attack looks like attack+hold, and the decay looks like delay+break. And the non-linear release is probably more natural. I'll give it a try
..........

'looks like you're right : 'skip' is useless
I will no more focus on it. I can now see the Hidden Power of Limits

Anyway I still want to know why I can not make 'skip' work...
vax71 is offline   Reply With Quote
Old Jun 3, 2009, 11:10 PM   #16
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,507
Rep Power: 61
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Re: 'Skip' instruction : how does this work ?

Maybe it is just something that was never implemented... Patents tend to try to be all inclusive in order to cover all the bases, etc.
Russ is offline   Reply With Quote
Old Jun 4, 2009, 03:06 PM   #17
HardwareHeaven Lover
 
Join Date: Jan 2008
Location: germany, sb0090
Posts: 242
Rep Power: 26
stylus02 will become famous soon enoughstylus02 will become famous soon enough

Re: 'Skip' instruction : how does this work ?

hey guys, interesting topic. max you have done an adsr generator with only 16 registers, nice my first (and only) adsr for kx- modular took 33 registers
and a lot of skips (horrible spaghetti code).

stylus
__________________
http://kxm.dyndns.org

Last edited by stylus02; Jun 4, 2009 at 03:18 PM.
stylus02 is offline   Reply With Quote
Old Jun 5, 2009, 11:14 AM   #18
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,606
Rep Power: 66
Max M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to allMax M. is a name known to all

Ответ: 'Skip' instruction : how does this work ?

hehe, i guess whatever "horrible" code is always better then nothing ;)
__________________
Max M. is offline   Reply With Quote
Reply

Bookmarks

Thread Tools