ndf-zz / asfv1

Alternate Assembler for Spin Semi FV-1
MIT License
38 stars 7 forks source link

sof -1, 0.999 #5

Closed johnfwhitmore closed 3 years ago

johnfwhitmore commented 3 years ago

I'm trying to reverse the value coming from a POT in the SPIN FV1 as described in : http://spinsemi.com/knowledge_base/pgm_quick.html#Preparing_pots

The example for reversing the value simply uses 'sop -1, 0.999' But asfv1 doesn't like the '-1' and says that it's out of range. I've tried it on a windows computer running the SPIN IDE and that instruction appears fine there. So for example this code fails to assemble:

equ volume 32

ldax        POT1
;; Need to reverse POT1
sof     -1, 0.999
ndf-zz commented 3 years ago

Hi John,

by default, asfv1 treats all operands the same for consistency. As a result, integer literals are interpreted by the assembler as decimal integer values. The string '-1' represents an integer value outside of range for a sof multiplier because it requires an unsigned 16 bit integer or a real S1_14 value.

Refer: https://github.com/ndf-zz/asfv1#sof-multiplier-offset

To use the real value '-1.0' you should use a string literal that represents a real S1_14 value for the multiplier:

sof -1.0, 0.999

For more information, please refer to the section on operand expressions in the readme, particularly the section on literals:

https://github.com/ndf-zz/asfv1#operand-expressions

This behaviour differs from the Spin assembler, and since Spin code examples contain ambiguous literal values throughout, there is a compatibility option:

-s : Interpret integer literals 1 and 2 as 1.0 and 2.0 respectively. This option should be used with SpinASM assembly.

For example:

$ asfv1 -s spin_tut.asm spin_tut.bin

I hope that helps,

Nathan

On Sat, 20 Mar 2021, John Whitmore wrote:

I'm trying to reverse the value coming from a POT in the SPIN FV1 as described in : http://spinsemi.com/knowledge_base/pgm_quick.html#Preparing_pots

The example for reversing the value simply uses 'sop -1, 0.999' But asfv1 doesn't like the '-1' and says that it's out of range. I've tried it on a windows computer running the SPIN IDE and that instruction appears fine there. So for example this code fails to assemble:

equ volume 32

ldax POT1 ;; Need to reverse POT1 sof -1, 0.999

johnfwhitmore commented 3 years ago

Thank you, and sorry Nathan. I'd gone back and forth through the SPIN documentation on the instruction but should have looked at the documentation specific to your assembler. Thanks for taking the time to point out my error.

John

ndf-zz commented 3 years ago

No worries at all! Thanks for making contact.