From eb79dc7b43326dde9724d05594f77a39a6b4617e Mon Sep 17 00:00:00 2001 From: Egan Ford Date: Sat, 8 Apr 2017 21:45:39 -0600 Subject: [PATCH] added missing makeheader script --- README.md | 1 + makeheader | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 makeheader diff --git a/README.md b/README.md index d0c0e3e..3994f11 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ | README.md | This File | | c2d.c | Source File | | c2d.h.0 | Source File | +| makeheader | c2d.h build script | | text2page.c | Source File | | Makefile | c2d Makefile | | asm/loader.s | c2d loader source | diff --git a/makeheader b/makeheader new file mode 100755 index 0000000..3c3d029 --- /dev/null +++ b/makeheader @@ -0,0 +1,45 @@ +#!/bin/bash + +header() +{ + FILE=$1 + VAR=$2 + EOL=$3 + BYTES=$(hexdump -v $FILE | sed 's/^.......//' | wc -w | awk '{print $1}'); + + echo "/*" + expand ${FILE}.s + echo "*/" + + printf "unsigned char $VAR[] = {\n\t" + + for i in $(hexdump -v $FILE | sed 's/^.......//'); + do + printf "0x%02X" 0x$i + BYTES=$((BYTES - 1)) + if ((BYTES != 0)) + then + printf "," + fi + EOL=$((EOL - 1)) + if ((EOL == 0)) + then + EOL=8 + printf "\n\t" + fi + done + + printf "\n};\n" +} + +cd asm +make clean +make + +( +header loader loadercode 8 +) > ../c2d.h.1 + +cd .. + +cat c2d.h.[01] > c2d.h