6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu May 09, 2024 2:06 pm

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Wed Aug 30, 2023 3:43 pm 
Offline
User avatar

Joined: Thu Oct 12, 2017 10:51 pm
Posts: 87
As title.

I already know of:

- Wozniak & Rankin's one from Dr. Dobbs in 1976 (4-byte binary, difficult copyright licensing/issues)
- Microsoft's one in their BASIC (no license)
- Acorn's in their BASIC (no license)
- the Atari MATHPACK clone from Altirra (GPL; 6-byte BCD)
- the C64-compatible routines from the X16 kernal replacement (mostly copied from Microsoft, AFAICT)
- Louis Chorich's Atari floating point library (commercial, 6-byte, presumably BCD but the docs don't say)
- Apple's SANE (source lost)
- Some Random Internet Guy's library (no license, 5-byte BCD, no negative numbers)

Anyone know of more?


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 30, 2023 4:36 pm 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
I wrote some floating point routines earlier this year, I'm not sure if they count as a library though. I think I posted it on Stardot as it was using the BBC BASIC assembler, and had routines to load values from BASIC variables. I only implemented the basics though (addition, subtraction, multiplication). I made a two byte version and a three byte version. The API was load-store register-based, a bit like ARM I guess.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 30, 2023 7:12 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1928
Location: Sacramento, CA, USA
viewtopic.php?p=45404#p45404
... leading to
https://web.archive.org/web/20170923012 ... 80/fpu.txt

https://web.archive.org/web/20210418053 ... calc65.htm

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 30, 2023 7:25 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8177
Location: Midwestern USA
For the 65C816: http://forum.6502.org/viewtopic.php?f=2&t=4133

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 30, 2023 7:27 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8177
Location: Midwestern USA
barrym95838 wrote:

http://65xx.unet.bz/fpu.txt opens for me.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 31, 2023 2:08 pm 
Offline
User avatar

Joined: Thu Oct 12, 2017 10:51 pm
Posts: 87
Here's another one, written this decade: https://hackaday.io/project/181098-home ... r-for-6502 32-bit BCD, no license (but unusually, the author can be contacted without the use of a spirit medium!).


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 31, 2023 2:27 pm 
Offline
User avatar

Joined: Thu Oct 12, 2017 10:51 pm
Posts: 87
https://web.archive.org/web/20200128060 ... calc65.htm: 64-bit BCD, full set of trigonometric functions... no license and 'all rights reserved'.


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 01, 2023 3:36 am 
Offline

Joined: Mon Sep 17, 2018 2:39 am
Posts: 133
Hi!

hjalfi wrote:
As title.

I already know of:

- Wozniak & Rankin's one from Dr. Dobbs in 1976 (4-byte binary, difficult copyright licensing/issues)
- Microsoft's one in their BASIC (no license)
- Acorn's in their BASIC (no license)
- the Atari MATHPACK clone from Altirra (GPL; 6-byte BCD)

The Altirra ROM replacement is not under the GPL, but under the MIT license, much more permissive.

hjalfi wrote:
- the C64-compatible routines from the X16 kernal replacement (mostly copied from Microsoft, AFAICT)
- Louis Chorich's Atari floating point library (commercial, 6-byte, presumably BCD but the docs don't say)
- Apple's SANE (source lost)
The VBCC 6502 compiler uses those, and includes a library with all the split objects.
Quote:
- Some Random Internet Guy's library (no license, 5-byte BCD, no negative numbers)

Anyone know of more?


The Mad Pascal compiler (at https://github.com/tebe6502/Mad-Pascal ) includes:
- 32-bit FLOAT: https://github.com/tebe6502/Mad-Pascal/ ... single.asm
- 16-bit FLOAT: https://github.com/tebe6502/Mad-Pascal/ ... dd_sub.asm and other files.

Have Fun!


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 01, 2023 9:21 am 
Offline
User avatar

Joined: Thu Oct 12, 2017 10:51 pm
Posts: 87
dmsc wrote:
The Altirra ROM replacement is not under the GPL, but under the MIT license, much more permissive.


Oops. I knew that, honest.

dmsc wrote:


That's a nice find. The comment at the top of the first suggests the 32-bit code partially came from David Schmenk's Java VM for the Apple 2 (https://sourceforge.net/projects/vm02/, GPL-2), but the 16-bit stuff looks native.


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 01, 2023 8:15 pm 
Offline

Joined: Mon May 01, 2017 7:13 am
Posts: 82
Here's a standards-compliant implementation. Only compiles on llvm-mos as far as I know.

https://github.com/rweather/berkeley-softfloat-3-6502


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 03, 2023 11:36 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 690
Location: North Tejas
I know you want something with a permissive license.

I am not a patent lawyer and I do not play one on television; if you were to paraphrase code from one processor architecture to a different one, is the result considered to be infringing? If not, that may be a relatively easy way to get there. I have always presumed that to be safe; it is not unlike coding from an algorithm in a book or journal.

Floating point code has been published for the Motorola 8-bit processors. Same for 8080/Z80. Source code for 8087 emulation from the Borland compilers (80x86) is also out there.

Are you picky between BCD versus binary?

A long time ago, I set out to write IEEE 754 compliant floating point for the 6800. I have single precision generally working but have yet to work out how to implement the guard, round and sticky bits. Because the AVR instruction set looked so easy to program, I also built a version for that. Future steps:

* Figure out the guard, round and sticky bits
* Improve the speed
* Implement 6-byte, double and extended precision
* Port to other processors


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 03, 2023 12:09 pm 
Online
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1406
Location: Scotland
johnwbyrd wrote:
Here's a standards-compliant implementation. Only compiles on llvm-mos as far as I know.

https://github.com/rweather/berkeley-softfloat-3-6502


This is interesting as it ought to be possible to port it to cc65 which is probably (at the moment) more accessible to more 6502 users than the llvm-mos branch is.

The idea if implementing floating point in a language that doesn't intrinsically support it [1] isn't new either - in the early 80's BCPL didn't support floating point either, but there were libraries - one I used was the package for the BBC Micros implementation of BCPL which supported various formats and previsions. FP numbers were held in vectors (arrays) and you called functions to do the FP operations.

https://www.computinghistory.org.uk/det ... s-Package/

-Gordon

[1] Yes, C supports floating point but cc65 doesn't, so it would have to be implemented by external means.

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 05, 2023 2:54 pm 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
BillG wrote:
I have single precision generally working but have yet to work out how to implement the guard, round and sticky bits.

I discussed the guard and sticky bits here, including pseudocode to perform correct rounding using them: http://forum.6502.org/viewtopic.php?f=2&t=5352#p64001


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 06, 2023 10:10 pm 
Offline

Joined: Sat Dec 12, 2015 7:48 pm
Posts: 123
Location: Lake Tahoe
I wrote some 32 bit single precision FP routines for VM02. Not much error handling. Search for FLOATING_POINT:

https://github.com/dschmenk/VM02/blob/master/src/ops.s


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 30, 2023 2:29 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 690
Location: North Tejas
Chromatix wrote:
BillG wrote:
I have single precision generally working but have yet to work out how to implement the guard, round and sticky bits.

I discussed the guard and sticky bits here, including pseudocode to perform correct rounding using them: http://forum.6502.org/viewtopic.php?f=2&t=5352#p64001


Thanks for that. Completing floating point implementation will be a huge leap forward for some cross-compilers in progress.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: drogon and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: