SpinAsm SOF: Difference between revisions

From PedalPCB Wiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 13: Line 13:
====== Description ======
====== 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.
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"
|+Parameters
|+
!Name
!Name
!Width
!Width
Line 35: Line 37:


====== Coding Example ======
====== Coding Example ======
<syntaxhighlight line="1">
<pre>
Off  EQU  1.0                  ;  
Off  EQU  1.0                  ;  
                                 ;  
                                 ;  
Line 43: Line 45:
sof  1.0,Off                    ; Subtract offset  
sof  1.0,Off                    ; Subtract offset  
sof  1.0,Off                    ; Add offset
sof  1.0,Off                    ; Add offset
</syntaxhighlight>
</pre>

Latest revision as of 13:45, 22 November 2024

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