Last active
March 17, 2016 10:41
-
-
Save Sebb767/b98388bb6ceb25627d92 to your computer and use it in GitHub Desktop.
Compile 32 bit ASM on 64 bit linux (requires nasm, gcc)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# (c) Sebb767, 2016 | |
# | |
# Compile an 32-bit asm executable under linux x64. Requires gcc and nasm. Usage: | |
# ./compile.sh # compile *.asm in directory | |
# ./compile.sh file # compile $file | |
# | |
# This file is licensed under the WTFPL. | |
set -e | |
compile () | |
{ | |
asm="$1" | |
base="${asm%.*}" | |
echo "Started compiling $asm ... " | |
nasm -f elf32 "$asm" | |
gcc -m32 "$base.o" -o "$base" | |
chmod +x "$base" | |
echo "Compiled $asm to $base." | |
} | |
if [ ! -z "$1" ]; then | |
compile "$1" | |
else | |
for asm in *.asm; do | |
compile "$asm" | |
done | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment