aboutsummaryrefslogtreecommitdiffstats
path: root/c/build.sh
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-16 07:30:34 +0200
committeruser <user@clank>2026-07-16 07:30:34 +0200
commit8682553498d32d3c18dea41c598ab40de18404a3 (patch)
tree74096aa1fcefce24f80583ee10f25e5831a3b589 /c/build.sh
parentlibc + CLI tools: a small C userland (diff)
downloadgbos-8682553498d32d3c18dea41c598ab40de18404a3.tar.gz
gbos-8682553498d32d3c18dea41c598ab40de18404a3.tar.xz
gbos-8682553498d32d3c18dea41c598ab40de18404a3.zip
tools: wc, head, and an argc/argv demo (args) + libc.c helpers
- c/libc.c: shared C helpers linked into every program - putu (print decimal), atou (parse decimal), argv_parse (tokenize getargs() into argc/argv). - wc: count lines/words/chars of stdin. head [n]: first n lines (drains rest to EOF). args: argc/argv demo. - pid now uses libc putu; build.sh links libc.c; Makefile CBLOBS + libc dep. - README: document the new tools + argv_parse. - verified: 'args one two three' -> argc=3/argv[..]; wc '2 3 16'; head 2.
Diffstat (limited to '')
-rwxr-xr-xc/build.sh3
1 files changed, 2 insertions, 1 deletions
diff --git a/c/build.sh b/c/build.sh
index 6a2deab..8034d87 100755
--- a/c/build.sh
+++ b/c/build.sh
@@ -8,12 +8,13 @@ LIBDIR=/usr/share/sdcc/lib/sm83
mkdir -p "$B"
sdasgb -o "$B/crt0.rel" c/crt0.s
sdasgb -o "$B/libc.rel" c/libc.s
+sdcc -msm83 -c -Ic c/libc.c -o "$B/libc_c.rel"
sdcc -msm83 -c -Ic "$SRC" -o "$B/prog.rel"
# link: crt0 first (=> _start at 0x4000), then libc, program, and sm83 lib
sdldgb -n -m -w -j -i "$B/prog.ihx" \
-b _CODE=0x4000 -b _DATA=0xa000 \
-k "$LIBDIR" -l sm83 \
- "$B/crt0.rel" "$B/libc.rel" "$B/prog.rel"
+ "$B/crt0.rel" "$B/libc.rel" "$B/libc_c.rel" "$B/prog.rel"
makebin -Z -p "$B/prog.ihx" "$B/prog.bin"
dd if="$B/prog.bin" of="$OUT" bs=1024 skip=16 count=16 2>/dev/null
echo "wrote $OUT ($(wc -c < "$OUT") bytes); entry:"