aboutsummaryrefslogtreecommitdiffstats
path: root/usr/libc.c (unfollow)
Commit message (Collapse)AuthorFilesLines
4 daysrefactor: c/ -> usr/, compiled program blobs out of the source treeuser1-0/+0
Userland sources live in usr/ (fits the Unix theme better than 'c'). SDCC output .bin blobs land in build/usr/ with the other build artifacts instead of littering the source dir; programs.asm INCBINs them from there. Byte-identical ROM.
4 dayskernel: sys_sleep - a cooperative delay off the DIV timer (+ ping pacing)user1-0/+9
There was no time source at all (IRQ vectors just reti; scheduler is purely cooperative). The DIV register (FF04) free-runs at 16384 Hz regardless of interrupts, so sys_sleep accumulates DIV deltas across SchedYields (other procs keep running) until the requested number of 1/64-second units elapse. - SYS_SLEEP(34): B = 1/64s units; libc gsleep(units) / msleep(ms) wrappers. - ping now msleep(800) between echoes, so it paces like real ping instead of blasting all four at once. Verified real-time (capped emulator): replies land ~0.85s apart. In --uncapped runs the delay is GB-time (fast wall-clock), as expected.
6 dayslibc: option parsing (hasflag/optval); wc -l/-w/-c, head -n Nuser1-0/+24
- hasflag(argv,argc,f): single-char flag present (-f or within -abc) - optval(argv,argc,opt): value for -opt (-n 5 or -n5) - wc supports -l/-w/-c (default all); head supports -n N (and bare N)
6 daystools: wc, head, and an argc/argv demo (args) + libc.c helpersuser1-0/+34
- 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.