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 "$@"