Fast Math in assembly language

All aspects of programming on the Commander X16.
Ed Minchau
Posts: 508
Joined: Sat Jul 11, 2020 3:30 pm

Fast Math in assembly language

Post by Ed Minchau »



On 5/16/2022 at 5:11 PM, BruceMcF said:




This is exactly the kind of ROM home I would like to see for a Sweet16 VM.



Zsound should probably find a home in ROM, too.

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

Fast Math in assembly language

Post by BruceMcF »



On 5/16/2022 at 9:29 PM, Ed Minchau said:




Zsound should probably find a home in ROM, too.



While I concur, when I was talking about a "home in ROM", even though my open source Sweet16VM is "fat" compared to Woz's masterwork of spaghetti 6502 code ... it's still under 0.75K, so it it's going to find a home in ROM, it has to ride along with something else that is (1) more substantial but (2) under 16K in its own right.

The alternative is to implement enough applets using the Sweet16 VM to justify putting the whole collection in a ROM, but I am working 11 hour shifts at present, so I probably don't have the time for that

Ed Minchau
Posts: 508
Joined: Sat Jul 11, 2020 3:30 pm

Fast Math in assembly language

Post by Ed Minchau »


Version 2 has been uploaded here:


 

I've shuffled some things around and managed to add 14 new subroutines.  Two of them are for saving and restoring the data in zero page addresses F0-FF, so that FASTMATH doesn't stomp on BASIC.  Four of them are for type conversions between 2 or 3 byte integers and the fractional notation used by FASTMATH (which on reflection is really a sort of floating point notation without the logarithms).  There's also a new Clamp function, Determinant, and 4 functions for adding or subtracting 2d or 3d vectors.

I also rewrote the ATN function and modified the lookup table it used significantly, and now there are three arctan(x,y) functions available, with precisions of 8, 9, or 10 bits.

I've got something special coming soon to demonstrate this in action.

User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Fast Math in assembly language

Post by desertfish »


FIFTY functions?   Wowwwww!

Also. Does the library use 65C02 instructions? Or is it usable on 6502 as well?

User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

Fast Math in assembly language

Post by svenvandevelde »



On 6/23/2022 at 11:51 AM, Ed Minchau said:




I've got something special coming soon to demonstrate this in action.



You're a wizard!

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
Ed Minchau
Posts: 508
Joined: Sat Jul 11, 2020 3:30 pm

Fast Math in assembly language

Post by Ed Minchau »



On 6/23/2022 at 11:43 AM, desertfish said:




FIFTY functions?   Wowwwww!



Also. Does the library use 65C02 instructions? Or is it usable on 6502 as well?



65c02 only, because I'm using the BBR/BBS commands.  And although there are 50, quite often there's only small differences, such as a 2d vector version and a 3d vector version. 

Fabio
Posts: 41
Joined: Sat Aug 21, 2021 12:13 pm

Fast Math in assembly language

Post by Fabio »


i have read your work : it's impressive but i have a doubt:what's the use of "fabs" lookup table ? given that it can be calculated as

eor FF

inc A

ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

Fast Math in assembly language

Post by ZeroByte »


Can it do log2 of a 16bit into an 8.8 or 8.16 fixedpoint?

 

Ed Minchau
Posts: 508
Joined: Sat Jul 11, 2020 3:30 pm

Fast Math in assembly language

Post by Ed Minchau »



On 6/23/2022 at 2:28 PM, Fabio said:




i have read your work : it's impressive but i have a doubt:what's the use of "fabs" lookup table ? given that it can be calculated as



eor FF



inc A



 If you've got the value in A, and you've already determined that it's negative (bit 7 = 1), then that works. The FABS table just avoids having to do the compare and branch, saving a few cycles. 

Ed Minchau
Posts: 508
Joined: Sat Jul 11, 2020 3:30 pm

Fast Math in assembly language

Post by Ed Minchau »



On 6/23/2022 at 4:58 PM, ZeroByte said:




Can it do log2 of a 16bit into an 8.8 or 8.16 fixedpoint?



 



No, I avoided logs.  I initially tried using an 8 bit log method for division and the error bars were huge and bimodal.

Post Reply