6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 7:09 am

All times are UTC




Post new topic Reply to topic  [ 125 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Author Message
PostPosted: Mon Dec 17, 2012 10:41 pm 
Offline

Joined: Mon Nov 19, 2012 11:08 pm
Posts: 29
Hi Guys,

I've downloaded a program called 'huey', it works okay but the trig functions are not that accurate and 'huey' does not remove the sine circles so after 2.pi you get gobbledeegook.

I've also been looking at KIMATH by mos technology. Anybody got any more maths for the 6502?

Cheers
Commie


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 17, 2012 11:07 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
Quote:
I've downloaded a program called 'huey'. It works okay but the trig functions are not that accurate and 'huey' does not remove the sine circles so after 2.pi you get gobbledeegook.

I've also been looking at KIMATH by mos technology. Anybody got any more maths for the 6502?

My article and files and their descriptions for large look-up tables for hyper-fast, accurate 16-Bit scaled-integer math are at http://wilsonminesco.com/16bitMathTables/index.html. This is in some cases many hundreds of times as fast as actually calculating the functions, and every last bit will be correct.

Alternately for SIN & COS functions you can take the first four terms of the infinite series and tweak the coefficients slightly (I can give you mine if you're interested) to compensate for the fact that you're only using four, and in 16-bit math, I've never seen them be more than 1 lsb off. It's only accurate like this for a fraction of a circle though-- 45° (π/4 radians) IIRC-- and then you have to handle the other half of the quadrant from the alternate function, and the other quadrants, separately. TAN is best returned as a rational number giving both the SIN and the COS as a fraction, since TAN has this nasty habit of going to ±inf at ±90°. Using the pair you can literally handle the entire range since the COS goes to 0 there.

ARCTAN is a function that interpolates quite nicely from a surprisingly small table. With a 17-point (16-segment) optimized table for 0-45°, I found the maximum error to be under .02°. Using 16-bit scaled-integer math, the resolution is the worst near 0, at about .007°. The accuracy of the output increases much faster than the size of the table. I don't remember exactly, but it was something like that if you double the size of the table, you get four times or eight times the accuracy.

http://www.awce.com/pak1.htm has serial-interfaced floating-point coprocessors which are more convenient but not nearly as fast, and of course floating-point is very inefficient to handle in a processor that doesn't have a FP unit, and it's unnecessary for most applications outside of calculators.

See my links at http://wilsonminesco.com/links.html, particularly the section called "math (including coprocessors), algorithms, OSs, programming languages, programmers' info" which is about 40% of the way down the page. Our own wiki is mentioned there too, with the math index http://6502org.wikidot.com/software-math (although so far that one doesn't have any trig).

_________________
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?


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 18, 2012 10:24 am 
Offline

Joined: Mon Nov 19, 2012 11:08 pm
Posts: 29
Hi Garth,

Just to say thanks

Cheers
Commie


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 01, 2013 11:40 pm 
Offline

Joined: Mon Nov 19, 2012 11:08 pm
Posts: 29
Hi Guys,

My Kim1 is still ticking away on my breadboard, I've been doing some comparisons between Kim basic 9 and AIM65 basic.

I had the grandious idea of dropping my Kim project all together and attempt to build the AIM65 instead. I figured the AIM65 to be a better design due to its debut around 1980, 4 years later than the KIM1. So anyway, I decided to compare the two basics, KB9(KIM1) floating point has exponent range is 10^-99 to 10^+99 whereas AIM basic appears to use 32bit (single)floating point format with exponent range from about 10^-35 to 10^35.
Also, in the case of variables, only the first 2 characters are recognized, if the programmer uses more that 2 the others are simply ignored, this is true for both basics.

Well, all said and done I was going to crash dive into the AIM65 but making a few comparisons reveal there's nothing to be gained over the KIM 1 design.

Cheers


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 02, 2013 5:39 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
Commie wrote:
I had the grandious idea of dropping my Kim project all together and attempt to build the AIM65 instead. I figured the AIM65 to be a better design due to its debut around 1980, 4 years later than the KIM1. So anyway, I decided to compare the two basics, KB9(KIM1) floating point has exponent range is 10^-99 to 10^+99 whereas AIM basic appears to use 32bit (single)floating point format with exponent range from about 10^-35 to 10^35...

Why not build a more contemporary design around the 65C02 or 65C816 and use Lee's EhBasic? It'll be more powerful and not as dependent on ancient logic. Plus it could have more RAM, something which any BASIC implementation can use.

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


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 02, 2013 8:24 am 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
Commie wrote:
I figured the AIM65 to be a better design due to its debut around 1980, 4 years later than the KIM1.
The AIM65 didn't debut in 1980, it's a design from the same time period as the KIM1 - probably only a short time later. It was presumably meant to be a high-end alternative to the KIM1 design. But of course the BASIC could have evolved over a longer time period - I don't even remember ever programming the AIM65 in BASIC, I think we only used Assembly back in school in 1978 (the school had lots of AIM65 computers). Well, that's where I learned 6502 programming for sure.

-Tor


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 02, 2013 8:53 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
According to the Wikipedia AIM-65 article, the original AIM-65 came out in 1976 essentially as an expanded KIM-1, and the AIM-65/40 in 1981.

_________________
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?


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 02, 2013 9:55 am 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
Well, the Wikipedia AIM 65 article isn't entirely trustworthy I think.. it's a bit inaccurate in several ways. It says the AIM 65 used the MOS 6502 chip for example, but I'm sure it used a Rockwell 6502 - that was kind of the point - it's a Rockwell computer, not a MOS computer. As to when it was introduced there are several opinions, no later than 1977 for sure, but I found one source who says he owned an AIM 65 in 1976, and more to the point: Before the Apple II came out (April 1977), because he then immediately bought one and started hacking on the Apple II instead. oldcomputers.net is one of the sources claiming 1977, but the same site has pictures of chips from an engineering sample of the AIM 65 with Rockwell prototype chips. So it must have been designed at the same time as Rockwell began its 65xx chip production.

But it can be surprisingly difficult to pinpoint when these old computers actually appeared on the scene - unless you find an advertisement in an old magazine it's very difficult to find reliable sources. Internet references are almost always circular in this area as far as I can tell.

-Tor


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 02, 2013 11:34 am 
Offline

Joined: Mon Nov 19, 2012 11:08 pm
Posts: 29
BigDumbDinosaur wrote:

Why not build a more contemporary design around the 65C02 or 65C816 and use Lee's EhBasic? It'll be more powerful and not as dependent on ancient logic. Plus it could have more RAM, something which any BASIC implementation can use.



Hi BDD,

I already am using a ATF22V10 for the address decoding which over comes the KIM 1 ram memory expansion problems and in fact my KIM 1 ram memory runs from 0000~6FFF and then again from 2000~9FFF. It runs KB9 basic no problem with R6502P,R6502A,R6502B and R65C02P4.

Cheers Commie


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 02, 2013 8:12 pm 
Offline

Joined: Mon Nov 19, 2012 11:08 pm
Posts: 29
Tor wrote:
The AIM65 didn't debut in 1980, it's a design from the same time period as the KIM1 - probably only a short time later.-Tor


Oops :mrgreen: , Tor I think you are right, but my whole point was to evalute both the KIM1 and the AIM65, and as I've said elsewhere the gem in the stone is in the basics and the KB9 has an extra digit of precision and the max variable count is the same in both so, it wouldn't be worth building the AIM65, not mentioning the keyboard/display problem but had I gone for a build I would go for the TTY option only.

Sigh :roll: we need a 6500 compiler supporting floating point, shame the only one I can locate is Avocet c compiler supporting 32 and 64 bit doubles but costs £800.00.

Cheers
Commie


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 02, 2013 11:31 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
If you have access to the library routines necessary to support floating point, add FP to an existing compiler (like one of the Small-C compiler things) shouldn't be an arduous task. The "hard" part is simply the support library.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 03, 2013 12:53 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
I think I missed something, even though I just now scanned all five pages of the topic again. Were you wanting to get one of the BASICs going because of the floating-point, and a compiler with FP would be a suitable alternative? What is the application that needs floating-point? The more experience I gain, the more I see how few applications really need floating-point, and that properly handled, the more-efficient scaled-integer arithmetic is a better choice there's no floating-point co-processor. Obviously a few applications like calculators will always need floating point because the input range cannot be predicted and it is not practical for the user to keep track of scale factors when doing non-programming calculations on the fly.

_________________
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?


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 03, 2013 12:06 pm 
Offline

Joined: Mon Nov 19, 2012 11:08 pm
Posts: 29
Hi Garth,

I have kb9 up and running which I can use for calculating electrical data, there's no problem there but the problem I see is not a hardware problem, it's software.Coding in assembler is like designing a 4 layer pcb board, after a few hours it totally drains me of energy. Sure I can build a 65816 SBC based on the latest chips but what about the software? what am I going to fill it with?

Just to make a comparison, I'm also using AVR chips coupled with Bascom AVR, the latter supports single and double 64 bit floating point with transcandential math functions and it can be had for less than £100.Whether you use them in your application is up to you they are nice to have on hand.

In my opinion, if the 6502 is going to compete or stay alive then really it needs a supporting powerful compiler.

Yes I know, wdc sell one for $400.00 but I bet you it only supports WDC's 6502 chips, i.e.' it probably wouldn't work with Rockwell parts or any other 6502 for that matter.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 03, 2013 6:11 pm 
Offline

Joined: Thu Mar 03, 2011 5:56 pm
Posts: 284
Let's see...

You have the Kim Basic, AIM 65 Basic, and also EhBasic. There's also forth and cc65 (though I think the latter is cross-compiled). With a little work I think it should be possible to get Pascal running, and it should even be possible to get BBC Basic running.

Note that a 65xx(x) based computer is never going to be a speed demon for general purpose computing, but it seems that there are plenty of options for getting immediate programming enjoyment from a homebrew computer.

One more thing: you mention that one of the Basics has floats with a range of approximately 10^37; this is probably a standard(ish) 32-bit float. The other has a range of 10^99, which means it's likely to be decimal, and not floating-point.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 03, 2013 6:49 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
It's a good guess, but the KB9 I think we're talking about is a 40-bit floating point ("9 digit") Microsoft BASIC: see http://www.pagetable.com/?p=46

(BBC BASIC also uses 40 bits, and it looks like both use one byte for the exponent, so I'm not sure about this 10^99 range. Commie, could you confirm that 1E99 + 1E98 works as expected?)

Cheers
Ed


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 125 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 24 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: