www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 272177fbf7631dae0ef369a8d285ee26d27c9560
parent 9917f2dfdaf62864c5d13d32090563cfe4b5a6ea
Author: Georges Dupéron <georges.duperon@gmail.com>
Date:   Tue,  3 Jul 2018 17:18:09 +0200

Moved compact ndisasm to a separate file so that it can be called in several places

Diffstat:
Mexample-os/.gitignore | 5+++--
Mexample-os/Makefile | 13++++---------
Autils/compact-ndisasm.sh | 16++++++++++++++++
3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/example-os/.gitignore b/example-os/.gitignore @@ -1,4 +1,5 @@ /os.sh /os.ndisasm.disasm /os.reasm.asm -/os.reasm -\ No newline at end of file +/os.reasm +/os.reasm.disasm +\ No newline at end of file diff --git a/example-os/Makefile b/example-os/Makefile @@ -9,14 +9,7 @@ os.sh: os.asm ../deploy-screenshots Makefile chmod a+x $@ os.ndisasm.disasm: os.sh Makefile - (echo "[BITS 16]"; \ - echo "[ORG 0x7c00]"; \ - ndisasm -o 0x7C00 $< \ - | uniq -s 8 -c \ - | sed -r -e 's/\s*1 //; t; s/\s*([0-9]+) ([^ ]+\s+[^ ]+\s+)/\2times \1 /' \ - | sed -r -e 's/([^ ]+\s+[0-9A-F]{4}\s+jz) 0x/\1 short 0x/') > $@ -# The last sed line just above fixes an issue with ndisasm -# (it fails to annotate the jz with short). + ../utils/compact-ndisasm.sh $< $@ os.reasm.asm: os.ndisasm.disasm Makefile sed -r -e 's/^[^ ]+ +[^ ]+ +//' $< > $@ @@ -26,7 +19,9 @@ os.reasm: os.reasm.asm os.sh Makefile @echo "diff $@ os.sh" @diff $@ os.sh \ && echo "Re-assembled file is identical to os.sh" \ - || (echo "Re-assembled file is different from os.sh"; exit 1) + || (../utils/compact-ndisasm.sh $@ os.reasm.disasm; \ + echo "Re-assembled file is different from os.sh. Use meld os.ndisasm.disasm os.reasm.disasm to see differences."; \ + exit 1) .PHONY: clean Makefile clean: diff --git a/utils/compact-ndisasm.sh b/utils/compact-ndisasm.sh @@ -0,0 +1,16 @@ +in=$1 +out=$2 + +# Add -s 0x1234 to te ndisasm command-line to specify that there is an +# instruction starting at 0x1234. Use this when ndisasm misinterprets +# some instructions due to db. +skip="" +for i in `seq 0 255`; do skip="$skip -s 0x7e$(printf %02x $i)"; done +(echo "[BITS 16]"; \ + echo "[ORG 0x7c00]"; \ + ndisasm -s 0x7c78 $skip -o 0x7C00 "$in" \ + | uniq -s 8 -c \ + | sed -r -e 's/^\s*1 //; t; s/^\s*([0-9]+) ([^ ]+\s+[^ ]+\s+)/\2times \1 /' \ + | sed -r -e 's/([^ ]+\s+[0-9A-F]{4}\s+j[^ ]+ )0x/\1short 0x/') > "$out" +# The last sed line just above fixes an issue with ndisasm +# (it fails to annotate jz and jnc (and possibly other) with short).