www

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

commit d812fc27bd0f55af8324ae4b8175b554767eb444
parent b9236005933bd1761d72c60fd8a68dc52dbb49de
Author: Georges Dupéron <georges.duperon@gmail.com>
Date:   Tue,  3 Jul 2018 15:03:48 +0200

Disassemble the OS (use a compact representation for repetitive parts), re-assemble and check that the result is identical.

Diffstat:
Mexample-os/.gitignore | 7+++++--
Mexample-os/Makefile | 24+++++++++++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/example-os/.gitignore b/example-os/.gitignore @@ -1 +1,4 @@ -/os.sh -\ No newline at end of file +/os.sh +/os.ndisasm.disasm +/os.reasm.asm +/os.reasm +\ No newline at end of file diff --git a/example-os/Makefile b/example-os/Makefile @@ -1,5 +1,5 @@ .PHONY: all -all: os.sh +all: os.sh os.ndisasm.disasm os.reasm.asm os.reasm ../deploy-screenshots: mkdir $@ @@ -8,6 +8,28 @@ os.sh: os.asm ../deploy-screenshots Makefile nasm -o $@ $< chmod a+x $@ +os.ndisasm.disasm: os.sh Makefile + ndisasm $< \ + | 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). + +os.reasm.asm: os.ndisasm.disasm Makefile + sed -r -e 's/^[^ ]+ +[^ ]+ +//' $< > $@ + +os.reasm: os.reasm.asm os.sh Makefile + nasm $< -o $@ + @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) + +.PHONY: clean Makefile +clean: + rm -f os.sh os.ndisasm.disasm os.reasm.asm os.reasm + .PHONY: test test: test-qemu-system-i386 test-qemu-system-arm test-virtualbox test-bochs Makefile