31 lines
645 B
C
31 lines
645 B
C
// Hello World for TinyCPU (C-style)
|
|
// Prints "Hello from C!" to the GPU display
|
|
// Compile: cbecc ccompile program.c -o roms/boot.bin --arch tinycpu
|
|
|
|
// GPU output port address
|
|
#define GPU_OUT 0xC0
|
|
|
|
// Output a character to the GPU display
|
|
void write_gpu(char c) {
|
|
// Will be translated to: MOV_IMM_A c; STORE_A 0xC0
|
|
}
|
|
|
|
int main() {
|
|
write_gpu('H');
|
|
write_gpu('e');
|
|
write_gpu('l');
|
|
write_gpu('l');
|
|
write_gpu('o');
|
|
write_gpu(' ');
|
|
write_gpu('f');
|
|
write_gpu('r');
|
|
write_gpu('o');
|
|
write_gpu('m');
|
|
write_gpu(' ');
|
|
write_gpu('C');
|
|
write_gpu('!');
|
|
write_gpu('\n');
|
|
|
|
return 0; // HLT
|
|
}
|