Skip to content

Instantly share code, notes, and snippets.

@Sebb767
Last active March 17, 2016 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sebb767/b98388bb6ceb25627d92 to your computer and use it in GitHub Desktop.
Save Sebb767/b98388bb6ceb25627d92 to your computer and use it in GitHub Desktop.
Compile 32 bit ASM on 64 bit linux (requires nasm, gcc)
#!/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