SpinAsm LOG and SpinAsm SOF: Difference between pages

From PedalPCB Wiki
(Difference between pages)
Jump to navigation Jump to search
(Created page with "==LOG== {| class="wikitable" |+ !Mnemonic !Operation !Instruction coding |- |LOG |<nowiki>C * LOG(|ACC|) + D</nowiki> |CCCCCCCCCCCCCCCCDDDDDDDDDDD01011 |} ======Description====== LOG will multiply the Base2 LOG of the current absolute value in ACC with C and add the constant D to the result. It is important to note that the LOG function returns a fixed point number in S4.19 format instead of the standard S.23 format, which in turn means that the most negative Base2 LO...")
 
No edit summary
 
Line 1: Line 1:
==LOG==
== SOF ==
{| class="wikitable"
{| class="wikitable"
|+
|+
Line 6: Line 6:
!Instruction coding
!Instruction coding
|-
|-
|LOG
|SOF
|<nowiki>C * LOG(|ACC|) + D</nowiki>
|C * ACC + D
|CCCCCCCCCCCCCCCCDDDDDDDDDDD01011
|CCCCCCCCCCCCCCCCDDDDDDDDDDD01101
|}
|}


======Description======
====== Description ======
LOG will multiply the Base2 LOG of the current absolute value in ACC with C and add the constant D to the result.  
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.


It is important to note that the LOG function returns a fixed point number in S4.19 format instead of the standard S.23 format, which in turn means that the most negative Base2 LOG value is –16.
====== Parameters ======
 
The LOG instruction can handle absolute linear accumulator values from 0.99999988 to 0.00001526 which translates to a dynamic range of apx. 96dB.
 
D an offset to be added to the logarithmic value in the range of –16 to + 15.999998.
{| class="wikitable"
{| class="wikitable"
|+
|+
Line 28: Line 24:
|16 Bit
|16 Bit
|Real (S1.14)
|Real (S1.14)
Hex ($0000 ­ $FFFF)
Hex ($0000 ­ $FFFF)  
Symbolic  
Symbolic  
|-
|-
|D
|D
|11 Bit
|11 Bit
|Real(S4.6)
|Real(S.10)
Symbolic
Symbolic
|}
|}


======Syntax======
====== Syntax ======
LOG C, D
SOF C,D


======Coding Example======
====== Coding Example ======
<syntaxhighlight line="1">
<syntaxhighlight line="1">
log 1.0,0
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
</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