Closed mlozier closed 4 years ago
The SDCC compiler for the Z80 CPU contains lots of additions that aren't in standard C (like inline assembly) so it won't compile on gcc or clang.
To compile to a Z80 binary, you'd have to get SDCC: http://sdcc.sourceforge.net/ But 8bitworkshop sets up a lot of libraries and command-line flags for you, so it's probably easier to use 8bitworkshop :)
Thank you so much for the reply. I get it now. I assume that the same is true for compiling code that involves neslib.h? Which compiler should I use for the 6502? cc65?
Yes, cc65 for 6502 code, but again 8bitworkshop sets up a lot for you so code will probably not compile out-of-the-box.
Hi! The 8bitworkshop IDE is really cool! Question though: I downloaded the hello.c file from the VIC Dual and tried to compile on my Linux box with: gcc hello.c -o hello and got a slew of errors from the compiler. Do I need to add additional flags in order to compile the code? I'll copy / paste the errors below:
hello.c: In function ‘start’: hello.c:9:4: error: expected ‘(’ before ‘LD’ LD SP,#0xE800 ; set up stack pointer ^~ hello.c:9:4: error: unknown type name ‘LD’ hello.c:9:13: error: stray ‘#’ in program LD SP,#0xE800 ; set up stack pointer ^ hello.c:9:14: error: expected identifier or ‘(’ before numeric constant LD SP,#0xE800 ; set up stack pointer ^
~hello.c:9:23: error: unknown type name ‘set’ LD SP,#0xE800 ; set up stack pointer ^~~ hello.c:9:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘stack’ LD SP,#0xE800 ; set up stack pointer ^~~~~ hello.c:10:16: error: unknown type name ‘disable’; did you mean ‘double’? DI ; disable interrupts ^~~ double hello.c:11:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘endasm’ endasm; ^~~~ hello.c: At top level: hello.c:16:12: error: expected declaration specifiers or ‘...’ before numeric constant char at (0xe000) cellram[32][32]; ^~hello.c:17:12: error: expected declaration specifiers or ‘...’ before numeric constant char at (0xe800) tileram[256][8]; ^~hello.c: In function ‘clrscr’: hello.c:31:10: error: ‘cellram’ undeclared (first use in this function) memset(cellram, 0, sizeof(cellram)); ^~~ hello.c:31:10: note: each undeclared identifier is reported only once for each function it appears in hello.c: In function ‘setup_stdio’: hello.c:35:10: error: ‘tileram’ undeclared (first use in this function) memcpy(tileram, font8x8, sizeof(font8x8)); ^~~ hello.c: In function ‘scrollup’: hello.c:43:12: error: ‘cellram’ undeclared (first use in this function) memmove(&cellram[0][1], &cellram[0][0], sizeof(cellram)-1); ^~~ hello.c: In function ‘putchar’: hello.c:64:3: error: ‘cellram’ undeclared (first use in this function) cellram[cursor_x][31-cursor_y] = ch; ^~~