From b8a173787a0b9b8c0dc064c12c99475a41dfe383 Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Fri, 28 Jan 2022 18:42:46 -0500 Subject: Add some scripts to help assemble generated output and run it Until we have a better way of outputting the data, we're just using return codes for now. The `test.sh` script creates the compiler, compiles the selected file into ASM, then assembles and links the generated output, after which it runs it and shows the exit status. --- assemble.sh | 14 ++++++++++++++ compile.sh | 1 - test.sh | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 assemble.sh create mode 100755 test.sh diff --git a/assemble.sh b/assemble.sh new file mode 100755 index 0000000..90f945f --- /dev/null +++ b/assemble.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# NOTE: Only for macOS (intel) + +if [ -z "$1" ] +then + echo "Usage: $0 " + exit 1 +fi + +set -xe + +nasm -f macho64 -o $1.o $1 +ld -lSystem $1.o diff --git a/compile.sh b/compile.sh index faeaf52..9568907 100755 --- a/compile.sh +++ b/compile.sh @@ -7,4 +7,3 @@ SRCS=cup/*.c set -xe $CC $CFLAGS $SRCS -o cupcc -./cupcc $@ diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..14f0145 --- /dev/null +++ b/test.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +if [ -z "$1" ] +then + echo "Usage: $0 " + exit 1 +fi + +set -xe + +./compile.sh +./cupcc $@ +./assemble.sh output.nasm + +set +e + +./a.out +echo "Exit status: $?" \ No newline at end of file -- cgit v1.2.3