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 / strand4_ascetic / loadD0.sh

16 lines · 579 bytes Raw Blame History
1#!/bin/sh
2# loadD0.sh -- turn seedD0.d0 (comma-separated hex bytes with '!' comments) into the 404-byte W^X binary.
3set -eu
4[ "$#" -eq 2 ] || { printf 'usage: loadD0.sh INPUT OUTPUT\n' >&2; exit 2; }
5hex=$(sed 's/!.*//' "$1" | tr -d ' \t\r\n,')
6case $(( ${#hex} % 2 )) in
7 0) ;;
8 *) printf 'loadD0: odd hex nibble count\n' >&2; exit 22 ;;
9esac
10printf '%s\n' "$hex" | fold -w 2 | while IFS= read -r b; do
11 case "$b" in
12 [0-9a-fA-F][0-9a-fA-F]) printf "\\$(printf '%03o' "0x$b")" ;;
13 *) printf 'loadD0: bad byte %s\n' "$b" >&2; exit 21 ;;
14 esac
15done > "$2"
16chmod +x "$2"