128 bit Floating Point 65C816 implementation
128 bit Floating Point 65C816 implementation
Hello everyone.
i'm developing a floating point unit for 65C816 compliant with IEEE754 quadruple precision.
At this time these functions are full implemented:
- fpadd, fpsub, fpmult, fpdiv (basic operations)
- fprexp (extract exponent), fscale (scale by a power of two), scale10 (scale by a power of ten), fsquare
- fpack (store in memory in ieee format), funpack (get from memory)
- Roundup functions: ftrunc, fceil, floor, fround, fmod
- str2int, str2fp (convert string to binary)
- fp2str: convert a float to string (compliant with sprintf() function)
- int2dec, uint2dec: convert a 128 bit integer to string
- fsqrt, fcbrt: square root and cube root
- flog, flog10, flog2 (logarithm functions)
- flogp1, flog10p1, flog2p1: computes lognn(1+x) whenn x is very close to 1.0
- fexp, fexp2, fexp10: exponential functions
- fexpm1: computes exp(x)-1 with greater accuracy when x is close to 0.0
- fpown: computes x raised at n (n integer)
- frootn: computes the n-th root
- fpowxy: computes x raised to y (both float)
For future i plan to implement circular functions and hyperbolics functions.
Source code is available HERE: http://65xx.unet.bz/fpu.txt
- Marco
i'm developing a floating point unit for 65C816 compliant with IEEE754 quadruple precision.
At this time these functions are full implemented:
- fpadd, fpsub, fpmult, fpdiv (basic operations)
- fprexp (extract exponent), fscale (scale by a power of two), scale10 (scale by a power of ten), fsquare
- fpack (store in memory in ieee format), funpack (get from memory)
- Roundup functions: ftrunc, fceil, floor, fround, fmod
- str2int, str2fp (convert string to binary)
- fp2str: convert a float to string (compliant with sprintf() function)
- int2dec, uint2dec: convert a 128 bit integer to string
- fsqrt, fcbrt: square root and cube root
- flog, flog10, flog2 (logarithm functions)
- flogp1, flog10p1, flog2p1: computes lognn(1+x) whenn x is very close to 1.0
- fexp, fexp2, fexp10: exponential functions
- fexpm1: computes exp(x)-1 with greater accuracy when x is close to 0.0
- fpown: computes x raised at n (n integer)
- frootn: computes the n-th root
- fpowxy: computes x raised to y (both float)
For future i plan to implement circular functions and hyperbolics functions.
Source code is available HERE: http://65xx.unet.bz/fpu.txt
- Marco
http://65xx.unet.bz/ - Hardware & Software 65XX family
Re: 128 bit Floating Point 65C816 implementation
Oh, this is wonderful. I'm going to try it out RIGHT NOW.
...and thank you.
...and thank you.
Re: 128 bit Floating Point 65C816 implementation
Hello everyone,
i updated the fpu implementation with a new version: http://65xx.unet.bz/fpu.txt
Some minor bugs was fixed (one in str2fp function, one in fexp function) and some improvements was done.
Added a function int2str compliant with format of sprintf() function (hex. formatting, a flag to Group thousand in decimal format).
The function that extract integral part and fractionary part was renamed from fmod to fpfrac.
Added two "remainders" functions: fpmod & fprem (work as the same functions in C).
Finally, added circular & hyperbolics functions:
fsin, fcos, ftan, fcotan (max. absolute value of argument: 2^56)
fasin, facos, fatan, fatanyx (this last function compute fatan(y/x) but return value in interval [0, 2pi] useful for computes phase angle)
fsinh, fcosh, ftanh
fasinh, facosh, fatanh
For implementation details and algorithms look at source code.
Greetings,
Marco
i updated the fpu implementation with a new version: http://65xx.unet.bz/fpu.txt
Some minor bugs was fixed (one in str2fp function, one in fexp function) and some improvements was done.
Added a function int2str compliant with format of sprintf() function (hex. formatting, a flag to Group thousand in decimal format).
The function that extract integral part and fractionary part was renamed from fmod to fpfrac.
Added two "remainders" functions: fpmod & fprem (work as the same functions in C).
Finally, added circular & hyperbolics functions:
fsin, fcos, ftan, fcotan (max. absolute value of argument: 2^56)
fasin, facos, fatan, fatanyx (this last function compute fatan(y/x) but return value in interval [0, 2pi] useful for computes phase angle)
fsinh, fcosh, ftanh
fasinh, facosh, fatanh
For implementation details and algorithms look at source code.
Greetings,
Marco
http://65xx.unet.bz/ - Hardware & Software 65XX family
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 128 bit Floating Point 65C816 implementation
For those who haven't had a peek at Granati's source code, it runs to 9838 lines, which is a substantial piece of work (the entire firmware in my POC is about 11,300 lines). I hope to look more closely into it in the near future, after I recover from my next (
) eye surgery.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: 128 bit Floating Point 65C816 implementation
BigDumbDinosaur wrote:
For those who haven't had a peek at Granati's source code, it runs to 9838 lines, which is a substantial piece of work (the entire firmware in my POC is about 11,300 lines). I hope to look more closely into it in the near future, after I recover from my next (
) eye surgery.
Many lines on fpu.asm are just comments, assembled code is about 16k (many bytes used for store float constants).
The main goal is build a "virtual numeric co-processor" with some internal pseudo-registers stack-oriented, interfaced by 'cop' instruction.
http://65xx.unet.bz/ - Hardware & Software 65XX family
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: 128 bit Floating Point 65C816 implementation
It's great to have this available online. Thanks Marco. I added it to the math and other software section of my links page.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 128 bit Floating Point 65C816 implementation
granati wrote:
BigDumbDinosaur wrote:
For those who haven't had a peek at Granati's source code, it runs to 9838 lines, which is a substantial piece of work (the entire firmware in my POC is about 11,300 lines). I hope to look more closely into it in the near future, after I recover from my next (
) eye surgery.
Quote:
Many lines on fpu.asm are just comments, assembled code is about 16k (many bytes used for store float constants).
The constants tables should help a lot in what are computationally-intensive operations. This is a classic tradeoff between memory consumption and compute-bound performance. Given the much greater addressing capabilities of the 65C816 over the 65C02, memory consumption of this sort should not be a problem.
Quote:
The main goal is build a "virtual numeric co-processor" with some internal pseudo-registers stack-oriented, interfaced by 'cop' instruction.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: 128 bit Floating Point 65C816 implementation
Glanced over the code. Thank you for writing it. Looks good.
Is anyone aware whether 32 and 64 bit versions of this code exist?
Is anyone aware whether 32 and 64 bit versions of this code exist?
Re: 128 bit Floating Point 65C816 implementation
32,64,128 bit
why not, ieee754-16 (half single)
https://en.wikipedia.org/wiki/Half-prec ... int_format
why not, ieee754-16 (half single)
https://en.wikipedia.org/wiki/Half-prec ... int_format
Re: 128 bit Floating Point 65C816 implementation
(Welcome, tebe6502!)
Re: 128 bit Floating Point 65C816 implementation
The link seems to be dead now. Did anyone save a copy?
Re: 128 bit Floating Point 65C816 implementation
Sorry for dead link, soon i put again online. Happened when i changed hosting (i restored an old version of the web site).
Marco
p.s.: the source code is available in the downloadable archive in my site
Marco
p.s.: the source code is available in the downloadable archive in my site
http://65xx.unet.bz/ - Hardware & Software 65XX family
Re: 128 bit Floating Point 65C816 implementation
Great to know you're still active!
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: 128 bit Floating Point 65C816 implementation
granati wrote:
p.s.: the source code is available in the downloadable archive in my site
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?