Created
June 12, 2016 23:22
-
-
Save franciscbalint/9ed35bcb811d21db43d1bf84b3273d67 to your computer and use it in GitHub Desktop.
Complainer ASM
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/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