"Hello, World!" with cc65
"Hello, World!" with cc65
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.
"Hello, World!" with cc65
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.
"Hello, World!" with cc65
#include <peekpoke.h>
...
asm ("jsr CLOCK_GET_DATE_TIME");
year = PEEK(0x02);
month = PEEK(0x03);
...
And so on.
"Hello, World!" with cc65
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.
"Hello, World!" with cc65
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;
)
"Hello, World!" with cc65
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...
"Hello, World!" with cc65
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.