Skip to content

Instantly share code, notes, and snippets.

@Frank-Buss
Created September 14, 2019 12:17
Show Gist options
  • Save Frank-Buss/3341ff7a7d83359320e176a50906420b to your computer and use it in GitHub Desktop.
Save Frank-Buss/3341ff7a7d83359320e176a50906420b to your computer and use it in GitHub Desktop.
Commander X16 hello world with CC65
// save as demo.c and compile like this:
// cl65 -t c64 -O -o demo.prg demo.c
#include <stdint.h>
#include <cbm.h>
#define BSOUT(c) \
__AX__ = c; \
asm("jsr BSOUT");
void print(const char* string)
{
while (*string) {
BSOUT(*string);
string++;
}
}
int main(void)
{
// bad hack: redefine CC65 stack to $0xa800-0xafff, should be a proper x16 custom target
*((uint16_t*) 0x02) = 0xb000;
// switch back to uppercase character set
BSOUT(0x8e);
// print something
print("hello world");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment