SpinAsm SKP and SpinAsm SOF: Difference between pages

From PedalPCB Wiki
(Difference between pages)
Jump to navigation Jump to search
 
No edit summary
 
Line 1: Line 1:
==SKP==
== SOF ==
{| class="wikitable"
{| class="wikitable"
|+
|+
Line 6: Line 6:
!Instruction coding
!Instruction coding
|-
|-
|SKP
|SOF
|CMASK  N
|C * ACC + D
|CCCCCNNNNNN000000000000000010001
|CCCCCCCCCCCCCCCCDDDDDDDDDDD01101
|}
|}


======Description======
====== Description ======
The SKP instruction allows conditional program execution. The FV­1 features five condition flags that can be used to conditionally skip the next N instructions. The selection of which condition flag(s) must be asserted in order to skip the next N instructions is made by the five bit condition mask “CMASK”. Only if all condition flags that correspond to a logic "1" within CMASK are asserted are the following N instructions skipped. The individual bits within CMASK correspond to the FV­1 condition flags as follows: 
SOF will multiply the current value in ACC with C and will then add the constant D to the result. Please note the absence of an integer entry format for D. This is not by mistake but it should emphasize that D is not intended to become used for integer arithmetic. The reason for this instruction is that the 11 bit constant D would be placed into ACC left justified or in other words 13 bits shifted to the left. D is intended to offset ACC by a constant in the range from –1 to +0.9990234375.
 
====== Parameters ======
{| class="wikitable"
{| class="wikitable"
|+
|+
!CMASK
!Flag
!Description
|-
|b4
|RUN
|The RUN flag is cleared after the program has executed for the first time after it was loaded into the internal program memory. The purpose of the RUN flag is to allow the program to initialize registers and LFOs during the first sample iteration then to skip those initializations from then on.
|-
|b3
|ZRC
|The ZRC flag is asserted if the sign of ACC and PACC is different, a condition that indicates a Zero Crossing.
|-
|b2
|ZRO
|Z is asserted if ACC = 0
|-
|b1
|GEZ
|GEZ is asserted if ACC >= 0
|-
|b0
|NEG
|N is asserted if ACC is negative
|}
{| class="wikitable"
|+Parameters
!Name
!Name
!Width
!Width
!Entry formats, range
!Entry formats, range
|-
|-
|CMASK
|C
|5 Bit
|16 Bit
|Binary
|Real (S1.14)
Hex ($00 ­ $1F)
Hex ($0000 ­ $FFFF)
Symbolic
|-
|D
|11 Bit
|Real(S.10)
Symbolic
Symbolic
|-
|N
|6 Bit
|Decimal (1 – 63)
Label
|}
|}
Maybe the most efficient way to define the condition mask is using it's symbolic representation. In order to simplify the SKP syntax, SPINAsm has a predefined set of symbols which correspond to the name of the individual condition flags. (RUN,ZRC,ZRO,GEZ,NEG). Although most of the condition flags are mutually exclusive, SPINAsm allows you to specify more than one condition flag to become evaluated simply by separating multiple predefined symbols by the "|" character. Accordingly "skp ZRC|N, 6" would skip the following six instructions in case of a zero crossing to a negative value.


======Syntax======
====== Syntax ======
SKP CMASK,N
SOF C,D


======Coding Example======
====== Coding Example ======
<syntaxhighlight line="1">
<syntaxhighlight line="1">
; A bridge rectifier        ;  
Off  EQU  1.0                  ;  
                            ;  
                                ;  
sof  0,0                   ; Clear ACC  
; Halve way rectifier ­­­­­­­­
rdax ADCL,1.0               ; Read from left ADC channel
sof  0,0                       ; Clear ACC  
skp  GEZ,pos                ; Skip next instruction if ACC >= 0
rdax ADCL,1.0                   ; Read from left ADC channel
sof  -1.0,0                ; Make ACC positive
sof  1.0,Off                    ; Subtract offset
pos: wrax DACL,0            ; Result to DACL, clear ACC
sof  1.0,Off                    ; Add offset
rdax ADCL,1.0              ; Read from left ADC channel
skp  N,neg                  ; Skip next instruction if ACC < 0
sof  -1.0,0                ; Make ACC negative
pos: wrax 0,DACR            ; Result to DACR, clear ACC
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 20:54, 6 January 2023

SOF

Mnemonic Operation Instruction coding
SOF C * ACC + D CCCCCCCCCCCCCCCCDDDDDDDDDDD01101
Description

SOF will multiply the current value in ACC with C and will then add the constant D to the result. Please note the absence of an integer entry format for D. This is not by mistake but it should emphasize that D is not intended to become used for integer arithmetic. The reason for this instruction is that the 11 bit constant D would be placed into ACC left justified or in other words 13 bits shifted to the left. D is intended to offset ACC by a constant in the range from –1 to +0.9990234375.

Parameters
Name Width Entry formats, range
C 16 Bit Real (S1.14)

Hex ($0000 ­ $FFFF) Symbolic

D 11 Bit Real(S.10)

Symbolic

Syntax

SOF C,D

Coding Example
Off  EQU  1.0                   ; 
                                ; 
; Halve way rectifier ­­­­­­­­
sof  0,0                        ; Clear ACC 
rdax ADCL,1.0                   ; Read from left ADC channel
sof  1.0,Off                    ; Subtract offset 
sof  1.0,Off                    ; Add offset