diff options
| author | user <user@clank> | 2026-07-16 00:49:58 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-07-16 00:49:58 +0200 |
| commit | ef88f0e530b898ebcb14f9e3dff1d58e83089ada (patch) | |
| tree | 4b4e70fb12a92e5e254a8c937fbda34316141d54 /c/chello.c | |
| parent | shell working: fix syscall ABI (trap clobbers HL) + document (diff) | |
| download | gbos-ef88f0e530b898ebcb14f9e3dff1d58e83089ada.tar.gz gbos-ef88f0e530b898ebcb14f9e3dff1d58e83089ada.tar.xz gbos-ef88f0e530b898ebcb14f9e3dff1d58e83089ada.zip | |
C toolchain: run SDCC-compiled C programs as gbos processes
- c/{gbos.h,crt0.s,libc.s,build.sh}: SDCC sm83 -> ROM-bank blob toolchain.
libc syscall wrappers save/restore BC/DE/HL around rst $30 (trap clobbers
them; SDCC expects them preserved).
- build via SDCC native asxxxx path (sdasgb/sdldgb), crt0 linked first so
_start is the $4000 entry; blob INCBIN'd into a ROM bank.
- chello.c: prints a message + getpid() -> runs as 'chello' shell command.
- Makefile: auto-build c/*.bin, track as a dep of programs.o; gitignore blobs.
- README: document the C toolchain + the SDCC --asm=rgbds codegen bug that
forced the native-toolchain approach.
- verified: '$ chello' -> 'hello from C on gbos!' / 'my pid is 2'.
Diffstat (limited to 'c/chello.c')
| -rw-r--r-- | c/chello.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/c/chello.c b/c/chello.c new file mode 100644 index 0000000..f570b61 --- /dev/null +++ b/c/chello.c @@ -0,0 +1,9 @@ +#include "gbos.h" +void main(void) { + writes("hello from C on gbos!", 21); + nl(); + writes("my pid is ", 10); + /* print pid as a digit */ + { unsigned char c = getpid() + '0'; char d = c; writes(&d, 1); } + nl(); +} |
