Skip to content

Instantly share code, notes, and snippets.

@franciscbalint
Created June 12, 2016 23:22
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 franciscbalint/9ed35bcb811d21db43d1bf84b3273d67 to your computer and use it in GitHub Desktop.
Save franciscbalint/9ed35bcb811d21db43d1bf84b3273d67 to your computer and use it in GitHub Desktop.
Complainer ASM
#!/bin/bash
# Author Francisc Balint - fib.im
numArg=$#
clear
if [ $numArg -ne 2 ]; then
echo "You entered too many or too little arguments when expected 2"
echo "you supplied only $numArg"
echo "Usage: compile.sh <input.asm> <program_name>"
exit
else
echo "Compiling asm using NASM"
input=$1
output=$2
inter=$2.o
nasm -f macho64 -o $inter $input
# nasm -f macho64 -o hello_world.o hello_world.asm
# nasm -f elf$bits -o $inter $input
ret=$?
if [ $ret != 0 ] ; then
echo "NASM compile failed!"
exit
else
echo "Compiling using ld for final binary"
ld $inter -o $output
# ld hello_world.o -o hello_world
# gcc -m$bits -o $output $inter
ret=$?
if [ $ret != 0 ] ; then
echo "There was a problem with linking!"
exit
else
rm $inter
echo "Compile finished!"
fi
echo "Running..."
echo
./$output
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment