interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / helix / rung0 / loadB0.sh

26 lines · 820 bytes Raw Blame History
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.
4set -eu
5[ "$#" -eq 2 ] || { printf 'usage: loadB0.sh INPUT OUTPUT\n' >&2; exit 2; }
6in=$1
7out=$2
8# Strip ';' comments, keep only hex pairs, emit raw bytes via POSIX printf.
9hex=$(sed 's/;.*//' "$in" | tr -d ' \t\r\n')
10case $(( ${#hex} % 2 )) in
11 0) ;;
12 *) printf 'loadB0: odd hex nibble count\n' >&2; exit 6 ;;
13esac
14# Emit bytes in octal via POSIX printf
15printf '%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
25done > "$out"
26chmod +x "$out"