unconditional SKP

Algorithm development and general DSP issues

Moderator: frank

Post Reply
igorp
Posts: 65
Joined: Tue May 19, 2015 6:10 am
Location: RU

unconditional SKP

Post by igorp »

For example, program made calculations and need to go to next part,
I am trying "SKP run|gez|neg|zro|zrc , label" for unconditional jump, but program continued.

Why?

I used "SKP run|gez , label" and it woiked fine for this subrotinue, but i want to understand what was wrong.
frank
Posts: 1241
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Most likely the combination of flags makes no sense to the logic in the instruction decoder. "SKP neg|gez" is illogical to a hardware decoder since we are using the sign bit to decide. "SKP neg|gez" is saying "skip if negative and continue if positive or skip if positive and continue if negative" so which do we do? Do we skip or continue as both states are satisfied? Seems the way I designed it we default to continue.
Frank Thomson
Experimental Noize
igorp
Posts: 65
Joined: Tue May 19, 2015 6:10 am
Location: RU

Post by igorp »

Hm , in classic C "|" mean logical OR , so

"skp run|gez|neg" is interpreted as
"skip if run or skip if gez or skip if neg"

and "SKP neg|gez" mean "skip if negative or positive" , so it must be unconditional skip?
frank
Posts: 1241
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Yes but we are talking assembly here which is far closer to the hardware than C, a simple logical OR in C may map to multiple assembly instructions not just one.

One thing to consider is if you really need to test for both, when I've needed an unconditional SKP I could usually take advantage of knowing in advance that the value in the ACC was going to be positive or negative then use that as the skip flag. Other times the first thing I did at the label point was clear the acc so i just moved that clearing to just before the skp and did a skp zro or skp gez.
Frank Thomson
Experimental Noize
igorp
Posts: 65
Joined: Tue May 19, 2015 6:10 am
Location: RU

Post by igorp »

Oh, i do simple analysis like "wrax temp, 0 : skp zro , label" , but thought skp has more common way to make unconditional jump.

Thank you
ndf
Posts: 12
Joined: Tue Jun 20, 2017 5:43 am

Re: unconditional SKP

Post by ndf »

From my limited testing,

skp 0,target


appears to perform an unconditional skip to target. The value of ACC has no bearing on the outcome, so you can save an instruction - or more importantly: preserve ACC across an unconditional skip.
igorp
Posts: 65
Joined: Tue May 19, 2015 6:10 am
Location: RU

Re: unconditional SKP

Post by igorp »

no flags is testing, but it working?
Great idea, thank you!
smear
Posts: 39
Joined: Fri Jul 01, 2016 9:47 am

Re: unconditional SKP

Post by smear »

I wish this was better documented, I can't believe I went so long without seeing this! It really makes my life easier

I was a bit nervous about using this so i wrote some slightly silly test code to make sure it really does skip, and really does preserve the ACC value. Seems to work perfectly!

Code: Select all

; if skp 0 really skips unconditionally, then should skip regardless of pot value
; if it skips, then input is read to output
; if it doesn't skip, then 0.99 is loaded and we skip to end, with no output
; to confirm that acc is maintained, we multiply input by a rescaled pot1 to control volume


equ   outputmult   reg1

ldax  pot1      ; load pot1, values range 0->1
sof   1,-0.5    ; scale it to -0.5 -> 0.5 to include negative values
skp   0,OUTPUT  ; skip to output section regardless of value
skp   zro,END   ; these are all just to know for sure that this code isn't read
skp   gez,END
skp   neg,END
sof   0,0.99
skp   gez,END
OUTPUT:
sof   0.8,0.6    ; scale from -0.5 -> 0.5 to 0.2 -> 1. this way never totally mute
wrax  outputmult,0
ldax  adcl
mulx  outputmult  ; multiply input by saved pot value
WRAX  dacl,0
END:
potul
Posts: 76
Joined: Tue Sep 26, 2017 12:33 am

Re: unconditional SKP

Post by potul »

great finding! I will use it for sure.
Post Reply