diff options
| author | user <user@clank> | 2026-09-24 22:45:04 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-24 22:45:04 +0200 |
| commit | 4cd933009dd6ce87fe710acfca6b1f786d51040c (patch) | |
| tree | 67e50c2ab347ddc2ac3e5b6a5cf5a4cfc44cc8d0 /src/programs.asm | |
| parent | fs: mount the builtins at /bin (diff) | |
| download | gbos-4cd933009dd6ce87fe710acfca6b1f786d51040c.tar.gz gbos-4cd933009dd6ce87fe710acfca6b1f786d51040c.tar.xz gbos-4cd933009dd6ce87fe710acfca6b1f786d51040c.zip | |
usr: touch, tr, rev, cut, uniq
/# ls -l /bin > b
/# cut -d \s -f 1 b | uniq -c
52 -
- touch FILE...: gbfs has no timestamps (an MBC5 cart has no RTC), so touch
does the half that means something here - make an empty file. O_APPEND is
exactly right: it creates, and it does not truncate what is already there.
- tr [-d] SET1 [SET2]: ranges (a-z), -d to delete, and a short SET2 padded
with its last character, like tr(1). ASCII only - a 128-entry map.
- rev, uniq [-c]: one line each, from a file or stdin like the other filters.
Two things the tests caught. A bare "-" is a SET, not a flag, so `tr . -`
has to skip flag-matching only when a letter follows the dash. And uniq
compared an empty "line" against the last run at EOF and flushed a phantom
blank one - a stray "1" in uniq -c output.
tr and cut also take \s \t \n \r escapes, because the shell has no quoting:
`-d ' '` arrives as three tokens, so a space or tab delimiter was simply
untypeable. Shell quoting would be the better fix; this makes the tools
usable today without touching the parser.
Banks 49-53; 10 program slots left in the 1 MB ROM.
Diffstat (limited to '')
| -rw-r--r-- | src/programs.asm | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/programs.asm b/src/programs.asm index a602350..e9e1be9 100644 --- a/src/programs.asm +++ b/src/programs.asm @@ -181,6 +181,21 @@ ProgPoweroff: SECTION "prog_xxd", ROMX[$4000], BANK[48] ProgXxd: INCBIN "build/usr/xxd.bin" +SECTION "prog_touch", ROMX[$4000], BANK[49] +ProgTouch: + INCBIN "build/usr/touch.bin" +SECTION "prog_tr", ROMX[$4000], BANK[50] +ProgTr: + INCBIN "build/usr/tr.bin" +SECTION "prog_rev", ROMX[$4000], BANK[51] +ProgRev: + INCBIN "build/usr/rev.bin" +SECTION "prog_cut", ROMX[$4000], BANK[52] +ProgCut: + INCBIN "build/usr/cut.bin" +SECTION "prog_uniq", ROMX[$4000], BANK[53] +ProgUniq: + INCBIN "build/usr/uniq.bin" ; ----------------------------------------------------------------------------- ; PROG_SH (bank 3) - the shell, now written in C (usr/sh.c): parses >/</| and @@ -317,6 +332,16 @@ ProgramTable:: dw ProgPoweroff db LOW(BANK(ProgXxd)), HIGH(BANK(ProgXxd)) dw ProgXxd + db LOW(BANK(ProgTouch)), HIGH(BANK(ProgTouch)) + dw ProgTouch + db LOW(BANK(ProgTr)), HIGH(BANK(ProgTr)) + dw ProgTr + db LOW(BANK(ProgRev)), HIGH(BANK(ProgRev)) + dw ProgRev + db LOW(BANK(ProgCut)), HIGH(BANK(ProgCut)) + dw ProgCut + db LOW(BANK(ProgUniq)), HIGH(BANK(ProgUniq)) + dw ProgUniq ProgramTableEnd:: ; ----------------------------------------------------------------------------- @@ -418,4 +443,14 @@ NameTable:: db PROG_POWEROFF db "xxd", 0 db PROG_XXD + db "touch", 0 + db PROG_TOUCH + db "tr", 0 + db PROG_TR + db "rev", 0 + db PROG_REV + db "cut", 0 + db PROG_CUT + db "uniq", 0 + db PROG_UNIQ db 0 |
