Added script for compile ASM files for x86 arch

This commit is contained in:
Fabio Scotto di Santolo
2025-07-02 16:20:00 +02:00
parent 7b989eb032
commit 72ff1890ff
2 changed files with 20 additions and 3 deletions

View File

@@ -24,6 +24,12 @@ nasm -f elf32 file.asm -o file.o
ld -m elf_i386 file.o -o file ld -m elf_i386 file.o -o file
``` ```
or using script
```bash
./asmc32.sh file.asm
```
### Run ### Run
```bash ```bash
@@ -33,9 +39,8 @@ ld -m elf_i386 file.o -o file
### Full Example ### Full Example
```bash ```bash
nasm -f elf32 hello_world.asm -o hello_world.o ./asmc32.sh helloworld.asm
ld -m elf_i386 hello_world.o -o hello_world ./helloworld
./hello_world
``` ```
## 📚 Intel Syntax ## 📚 Intel Syntax

12
asmc32.sh Executable file
View File

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