Page 1 of 1

unconditional SKP

Posted: Mon Mar 12, 2018 2:04 pm
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.

Posted: Tue Mar 13, 2018 8:50 am
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.

Posted: Tue Mar 13, 2018 2:43 pm
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?

Posted: Tue Mar 13, 2018 5:16 pm
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.

Posted: Wed Mar 14, 2018 11:09 am
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

Re: unconditional SKP

Posted: Mon Sep 03, 2018 4:09 am
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.

Re: unconditional SKP

Posted: Thu Oct 18, 2018 1:46 am
by igorp
no flags is testing, but it working?
Great idea, thank you!

Re: unconditional SKP

Posted: Sat Apr 04, 2020 11:16 am
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:

Re: unconditional SKP

Posted: Mon Apr 06, 2020 4:19 am
by potul
great finding! I will use it for sure.