Created
September 14, 2019 12:17
-
-
Save Frank-Buss/3341ff7a7d83359320e176a50906420b to your computer and use it in GitHub Desktop.
Commander X16 hello world with CC65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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