add itoa and build "system"

This commit is contained in:
nora 2022-01-02 13:41:04 +01:00
parent 73c1ca8415
commit 19427394db
3 changed files with 153 additions and 0 deletions

30
build.sh Normal file
View file

@ -0,0 +1,30 @@
build () {
FILE="$1"
PROGRAM_NAME=$(basename "$FILE" ".asm")
if [ ! -f "$FILE" ]; then
echo "$PROGRAM_NAME not found"
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 [ "$1" = "--clean" ]; then
rm -r target
exit
fi
if [ ! -d ./target ]; then
mkdir ./target
fi
if [ "$#" -eq 0 ]; then
for FILE in ./src/*.asm ; do
build "$FILE"
done
else
build "src/$1.asm"
fi