Precision addition / RDAX scaler

Software questions and issues with the FV-1

Moderator: frank

Post Reply
knutolai
Posts: 86
Joined: Wed Nov 23, 2016 9:43 am
Location: Bergen, Norway

Precision addition / RDAX scaler

Post by knutolai »

The documentation on RDAX is a bit vague.

According to the cheat sheet:
RDAX reg,K1 ACC=ACC+[reg]*K1 K1=16b, -2.0 to +0.9999389
According to the ASM manual regarding k1/c:
C 16bit Real (S1.14) Hex ($8000 -­ $0000 ­ $7FFF) Symbolic
Manual regarding S1.14:
S1.14 Bits 16 Range ­2 to 1.99993896484 Resolution (LSB value) 0.00006103516
The reason I'm asking is I have a case where I need to precisely add two values (for a counter). Normally i would do:

Code: Select all

clr ; acc = 0
or VALUE1 ; acc = value1
rdax reg0, 1 ; value2 contained in reg0, acc = value1 + (value2*1)
wrax reg0, 0 ; store new sum in reg0 for next cycle
Will this work? Can k1 be exactly 1?
knutolai
Posts: 86
Joined: Wed Nov 23, 2016 9:43 am
Location: Bergen, Norway

Re: Precision addition / RDAX scaler

Post by knutolai »

The S1.14 values seem a bit odd. For a 16b range from -2 to (2-LSB) my math says:

4/(2^16) = 0,0000610352 (LSB)

2-LSB = 1,9999389648

Is there a reason for this (very small) difference?
frank
Posts: 1281
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Precision addition / RDAX scaler

Post by frank »

Yes, in RDAX, C can be exactly 1.0 though normally if I am doing a high precision counter I use hex to absolutely control it to the bit as any time we convert from any number base to hex in an assembler you risk a rounding error.

The reason for the very small difference is you wrote down more digits than we did. But again, I would go with hex over decimal and avoid any rounding due to base conversion when LSB accuracy is important.
Frank Thomson
Experimental Noize
knutolai
Posts: 86
Joined: Wed Nov 23, 2016 9:43 am
Location: Bergen, Norway

Re: Precision addition / RDAX scaler

Post by knutolai »

Thank you! Will I be safe from rounding errors when using binary representation too?

Btw note then that the info on the cheat sheet is incorrect regarding Rdax. I'd really appreciate an update of that page if possible as it is a very useful tool to me.

If not a priority I could do an overview and write you a new revision. Let me know
frank
Posts: 1281
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Precision addition / RDAX scaler

Post by frank »

Using binary should also be fine but as I did not write the assembler I am basing it on experience. Has always worked for me but check the assembled code after to make sure. Different writing styles can expose an error or unintended result.

I have not looked at the cheat sheet in years, Keith wrote it and he would maintain it but I should review it and make any corrections/updates now. Probably after the New Year, too much going on to look at right now but if you notice any other errors let me know so I can correct them.
Frank Thomson
Experimental Noize
knutolai
Posts: 86
Joined: Wed Nov 23, 2016 9:43 am
Location: Bergen, Norway

Re: Precision addition / RDAX scaler

Post by knutolai »

On mobile so cumbersome to do a complete check. I think the syntax is correct but most of the constants upper range limits are wrong in the cheat sheet. All the instructions expect EXP and SOF should have upper limits of 2-LSB not 1-LSB (S1.14 and S1.9).
Post Reply