# `sprinter-cc` — compiler driver One-line entrypoint to the entire toolchain. Takes `.c` files plus options and emits a SprintEXE. ## Synopsis ``` sprinter-cc -o OUT.exe SRC.c [more.c ...] [options] ``` ## Options ### Memory layout | Flag | Description | |---|---| | `--memory MODE` | `tiny` (default), `small`, `big`, `huge`, `manual`. See `memory_modes.md`. | | `--memory-manual SPEC` | For `--memory manual`: comma-separated `KEY=VAL` list, e.g. `CODE=W2,DATA=W2,BANKED=W3`. | | `--stack-size N` | Bytes reserved for the stack. Default ≈ 1278. Larger value reduces the heap. | ### Code organisation | Flag | Description | |---|---| | `--bank N=FILE.c` | Compile FILE.c into bank N (1..15). Repeatable. Functions in banked files need the `__banked` qualifier. | | `--crt0=TYPE` | Override startup file: `default` / `minimal` / `banked` / `small`. Normally chosen automatically by the memory mode. | ### Diagnostics | Flag | Description | |---|---| | `--debug` | Prepends `DEBUG_RT = 1` to crt0 and passes `-DDEBUG_RT` to SDCC. Exposes runtime introspection symbols like `_w2_self_allocated`. | | `-v` | Verbose — echo every sub-command. | | `-h` / `--help` | Built-in help. | ### Passthrough | Flag | Description | |---|---| | `-I PATH` | Extra include path. | | `-Wl FLAG` | Pass FLAG to the linker. | | `--mkexe FLAG` | Pass FLAG to mkexe (e.g. `--mkexe -p --mkexe 0` for zero-padded banks). | | `-L 0xADDR` | Override load address. | | `-E 0xADDR` | Override entry address. | | `-S 0xADDR` | Override initial stack address. Default `0xBFFE`. | ## Examples Smallest possible build: ```sh sprinter-cc -o hello.exe hello.c ``` Larger program (doesn't fit in 14 KB): ```sh sprinter-cc --memory small -o big.exe big.c ``` Multi-bank game: ```sh sprinter-cc --memory huge -o game.exe \ main.c --bank 1=engine.c --bank 2=ai.c --bank 3=audio.c ``` Custom stack size: ```sh sprinter-cc --stack-size 4096 -o app.exe app.c ``` ## Under the hood 1. Picks crt0 based on `--memory` (and `--bank` presence). 2. Assembles crt0 (with optional `DEBUG_RT` / `BANK_W1` prepended). 3. Assembles `heap_top.s` (custom value if `--stack-size`). 4. Compiles every source `.c` to `.rel` via SDCC. 5. Compiles bank sources with `--codeseg/--constseg/--dataseg BANK_n`. 6. Compiles `runtime/bank.s` trampoline (if banks are used). 7. Links everything to `.ihx`, runs `check_banks.py` to enforce 16 KB bank limits. 8. Calls `toolchain/mkexe/mkexe` to wrap the `.ihx` as SprintEXE. Per-build artefacts go in `.sprinter-cc-/` next to the output.