omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / helix / rung0 / loadB0.sh
| 1 | #!/bin/sh |
| 2 | # loadB0.sh -- turn seedB0.b0 (byte-pair hex with ';' comments) into the first 396-byte binary. |
| 3 | # Strand B's one outside step (POSIX sh + printf only). Independent of Strand A's load0.sh. |
| 4 | set -eu |
| 5 | [ "$#" -eq 2 ] || { printf 'usage: loadB0.sh INPUT OUTPUT\n' >&2; exit 2; } |
| 6 | in=$1 |
| 7 | out=$2 |
| 8 | # Strip ';' comments, keep only hex pairs, emit raw bytes via POSIX printf. |
| 9 | hex=$(sed 's/;.*//' "$in" | tr -d ' \t\r\n') |
| 10 | case $(( ${#hex} % 2 )) in |
| 11 | 0) ;; |
| 12 | *) printf 'loadB0: odd hex nibble count\n' >&2; exit 6 ;; |
| 13 | esac |
| 14 | # Emit bytes in octal via POSIX printf |
| 15 | printf '%s\n' "$hex" | fold -w 2 | while IFS= read -r b; do |
| 16 | case "$b" in |
| 17 | [0-9a-fA-F][0-9a-fA-F]) |
| 18 | printf "\\$(printf '%03o' "0x$b")" |
| 19 | ;; |
| 20 | *) |
| 21 | printf 'loadB0: bad byte %s\n' "$b" >&2 |
| 22 | exit 5 |
| 23 | ;; |
| 24 | esac |
| 25 | done > "$out" |
| 26 | chmod +x "$out" |