start with wc

This commit is contained in:
nora 2022-01-02 13:55:09 +01:00
parent 19427394db
commit 9cf4469be6
3 changed files with 46 additions and 37 deletions

View file

@ -1,3 +1,11 @@
assemble () {
FILE="$1"
PROGRAM_NAME="$2"
echo "Assembling $PROGRAM_NAME"
nasm -g -F dwarf -f elf64 "$FILE" -o "./target/$PROGRAM_NAME.o" || return
}
build () {
FILE="$1"
PROGRAM_NAME=$(basename "$FILE" ".asm")
@ -7,8 +15,16 @@ build () {
return
fi
echo "Building $PROGRAM_NAME"
nasm -g -F dwarf -f elf64 "$FILE" -o "./target/$PROGRAM_NAME.o" && ld.lld "./target/$PROGRAM_NAME.o" -o "./target/$PROGRAM_NAME"
if [ "$PROGRAM_NAME" = "common" ]; then
# common does not need to be linked into an executable
return
fi
assemble "$FILE" "$PROGRAM_NAME"
echo "Linking $PROGRAM_NAME"
ld.lld "./target/$PROGRAM_NAME.o" "./target/common.o" -o "./target/$PROGRAM_NAME"
}
@ -21,6 +37,9 @@ if [ ! -d ./target ]; then
mkdir ./target
fi
assemble "src/common.asm" "common"
if [ "$#" -eq 0 ]; then
for FILE in ./src/*.asm ; do
build "$FILE"