"Hello, World!" with cc65

Chat about anything CX16 related that doesn't fit elsewhere
rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

"Hello, World!" with cc65

Post by rje »


I was thinking about writing a "localtime()" function or something...  No reason I can't write it myself and submit a Merge Request.  The X16 will probably have a decent ABI, so it's worth at least seeing how easy/difficult it is.

 

Greg King
Posts: 162
Joined: Wed Jul 08, 2020 1:14 pm

"Hello, World!" with cc65

Post by Greg King »



38 minutes ago, Ender said:




Actually, that seems like a pretty doable feature for the emulator, to set the date and time when you start it to emulate a RTC.



I assume that people are waiting for "the powers that be" to choose which RTC chip will be mounted in the X16.

Greg King
Posts: 162
Joined: Wed Jul 08, 2020 1:14 pm

"Hello, World!" with cc65

Post by Greg King »


#include <peekpoke.h>
...
asm ("jsr CLOCK_GET_DATE_TIME");
year = PEEK(0x02);
month = PEEK(0x03);
...


And so on.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

"Hello, World!" with cc65

Post by rje »



13 hours ago, Greg King said:




 




#include <peekpoke.h>
...
asm ("jsr CLOCK_GET_DATE_TIME");
year = PEEK(0x02);
month = PEEK(0x03);
...



 



And so on.



Good point... I totally spaced on inline assembly.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

"Hello, World!" with cc65

Post by rje »


Has anyone implemented floating point routines in C, since CC65 doesn't support floats?

I've thought about supporting Commodore-style 5-byte floats, e.g.

typedef struct {
   int exponent: 8;
   int sign:     1;
   int ma4:      7;
   int ma3:      8;
   int ma2:      8;
   int ma1:      8;
} Float5;

(or even:
int exponent :8;
long mantissa;
)

 

Polluks
Posts: 2
Joined: Fri Apr 09, 2021 10:08 am

"Hello, World!" with cc65

Post by Polluks »



On 11/17/2020 at 7:29 AM, rje said:




Has anyone implemented floating point routines in C, since CC65 doesn't support floats?



Least we have a roadmap...

voidstar
Posts: 494
Joined: Thu Apr 15, 2021 8:05 am

"Hello, World!" with cc65

Post by voidstar »


 

No (float) solution yet for CC65, but for reference...

 

Assembly examples of implementing some floating-point support (from 1976 and the 6502):

www.6502.org/source/floats/wozfp1.txt

 

In the discussion below, we pondered invoking the built in BASIC to perform floating point functions using the available ROM software.  You'd have to contrive setting up variables in BASIC (POKE) and call the right routine, then extract the answer back out.   Possible, but not very efficient (and very coupled to that ROM).   But also in the discussion, someone ended up adding support for the "float" type in C in something called vbcc.

calling ROM BASIC functions from cc65 - Commodore 64 (C64) Forum (lemon64.com)

 

A person made a build of my C code that was compiled for the Commodore PET (6502 CPU), and the C and resulting binary is here:  (a modified C compiler to include support for the "float" type)

voidstar78/SolarSystemCalculator: Solar System Calculator (github.com)

 

 

 

Note, if you just need a MOD operator (that still requires float support to determine that remainder).... You might just try using a table lookup instead of the actual math.     When determing some screen-coordinate stuff in a game I made, I ended up using a MOD_4_TABLE and DIV_4_TABLE, avoiding having to actually do the floating point operations.

 

 

Post Reply