From 72ff1890ffd37136d5873a493a4feb3bd716629f Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Wed, 2 Jul 2025 16:20:00 +0200 Subject: [PATCH] Added script for compile ASM files for x86 arch --- README.md | 11 ++++++++--- asmc32.sh | 12 ++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100755 asmc32.sh diff --git a/README.md b/README.md index 99b94ce..181e02d 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,12 @@ nasm -f elf32 file.asm -o file.o ld -m elf_i386 file.o -o file ``` +or using script + +```bash +./asmc32.sh file.asm +``` + ### Run ```bash @@ -33,9 +39,8 @@ ld -m elf_i386 file.o -o file ### Full Example ```bash -nasm -f elf32 hello_world.asm -o hello_world.o -ld -m elf_i386 hello_world.o -o hello_world -./hello_world +./asmc32.sh helloworld.asm +./helloworld ``` ## 📚 Intel Syntax diff --git a/asmc32.sh b/asmc32.sh new file mode 100755 index 0000000..fe43f81 --- /dev/null +++ b/asmc32.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +compile() { + local filename="$(basename "$1")" + local basename="${filename%.*}" + + nasm -f elf32 -o "$basename.o" "$filename" + ld -m elf_i386 -o "$basename" "$basename.o" + rm "$basename.o" +} + +compile "$@"