GithubHelp home page GithubHelp logo

mrdudz / cc65-floatlib Goto Github PK

View Code? Open in Web Editor NEW
34.0 34.0 11.0 62 KB

a naive approach for using kernal floating point numbers on C64, while using IEEE float values at application level

License: zlib License

C 46.31% Assembly 41.85% Makefile 1.82% Pascal 10.02%

cc65-floatlib's People

Contributors

bkeil avatar elderling avatar mrdudz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cc65-floatlib's Issues

Errors building floattest.c

Hi! First I wanted to say, I am so grateful and delighted that you've undertaken this effort! Thank you!
I just started with cc65 a few days ago and discovered there was no floating point then found your project. So I tried it out and I got the errors below. I commented out the lines with those functions and it builds and runs, although I haven't verified them. Is this an error in how I'm using this, or an error with the library? Is there anything I can do to help fix this? Thank you.

Noah@DESKTOP-VL0THH1 /cygdrive/c/Users/Noah/fun/c64/cc65-floatlib
$ make
ca65 float.s -o float.o
cc65 floatc.c -o floatc.s
ca65 floatc.s -o floatc.o
ar65 a runtime.lib float.o floatc.o
cl65 floattest.c runtime.lib -o floattest.prg
floattest.c(162): Warning: Constant is long
gcc -O2 -W -Wall -Wextra -o floattest -lm floattest.c
In file included from floattest.c:10:0:
floattest.c: In function ‘calcsin’:
floattest.c:61:37: warning: implicit declaration of function ‘fsin’; did you mean ‘fmin’? [-Wimplicit-function-declaration]
         csetpoint8(XNUM2+(ftoi(fmul(fsin(deg2rad(itof(i),itof(YNUM))),itof(YNUM2)))/(YNUM/XNUM)));
                                     ^
float.h:149:28: note: in definition of macro ‘ftoi’
 #define ftoi(a)     ((int)(a))
                            ^
floattest.c:61:32: note: in expansion of macro ‘fmul’
         csetpoint8(XNUM2+(ftoi(fmul(fsin(deg2rad(itof(i),itof(YNUM))),itof(YNUM2)))/(YNUM/XNUM)));
                                ^~~~
floattest.c:61:42: warning: implicit declaration of function ‘deg2rad’ [-Wimplicit-function-declaration]
         csetpoint8(XNUM2+(ftoi(fmul(fsin(deg2rad(itof(i),itof(YNUM))),itof(YNUM2)))/(YNUM/XNUM)));
                                          ^
float.h:149:28: note: in definition of macro ‘ftoi’
 #define ftoi(a)     ((int)(a))
                            ^
floattest.c:61:32: note: in expansion of macro ‘fmul’
         csetpoint8(XNUM2+(ftoi(fmul(fsin(deg2rad(itof(i),itof(YNUM))),itof(YNUM2)))/(YNUM/XNUM)));
                                ^~~~
floattest.c: In function ‘calccos’:
floattest.c:70:17: warning: implicit declaration of function ‘fcos’; did you mean ‘acos’? [-Wimplicit-function-declaration]
         fd=fmul(fcos(fs),itof(YNUM2));
                 ^
float.h:121:23: note: in definition of macro ‘fmul’
 #define fmul(a,b)   ((a)*(b))
                       ^
/tmp/ccAMzp5l.o:floattest.c:(.text+0x106): undefined reference to `deg2rad'
/tmp/ccAMzp5l.o:floattest.c:(.text+0x10e): undefined reference to `fsin'
/tmp/ccAMzp5l.o:floattest.c:(.text+0x1a6): undefined reference to `deg2rad'
/tmp/ccAMzp5l.o:floattest.c:(.text+0x1bc): undefined reference to `fcos'
collect2: error: ld returned 1 exit status
make: *** [makefile:19: floattest] Error 1

C128 port?

Would love to see a 128 port of this. Any pointers on how to develop a port?

Issue with the Float Lib

Hello There!

Thank you very much for making this very useful library.
I can build the library and testcode (using latest cc65), though I get the following message:

float.s(169): Warning: Didn't use zeropage addressing for 'sreg'

When running the testcode, the floats do not seem to work properly.
The function f1() crashes the application, and the following code shows a:0:

a=itof(2); printf("a:%x\n",a);

Any help would be most appreciated!!!
Anthony

PET Support

Would PET support be possible? BASIC would have all the same IEEE routines, but they're at different locations.

If it were possible, I have an MTU graphics board and could do a kiiller analog clock for the PET! But I need floating point :-)

Random trivia: Bill and Paul thought the floating point was going to be really hard, and they were talking about it at lunch in their dorm cafeteria. One of their friends scoffed that it'd be easy, he'd done it before!

His name was Monte Davidoff, and Bill and Paul called his bluff and hired him to write the floating point routines for BASIC (8080 originally). I got to chat with him a while back when I was researching the history of the floating point code. Long story short, it mostly comes from what he learned looking at a FOCAL interpreter.

As far as I know, Ric Weiland did the 6502 port.

Division problem

I am trying to get a decimal number into a float. So I did this

Y=fdiv(itof((int)14278),itof((int)10000));

Which should result in 1.4278.
Instead I get 1.42779994.

I know there is some rounding error when dealing with floats but I didn't think it was this bad. Am I doing something wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.