Guest User

Untitled

a guest
Feb 6th, 2014
225
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. numArg=$#
  4. clear
  5. if [ $numArg != 3] ; then
  6.     echo "You entered too many or too little arguments when expected 3"
  7.     echo "you supplied only $numArg"
  8.     echo "Usage: asmlearn.sh <input.asm> <program_name> <bits>"
  9.     exit
  10. else
  11.     echo "Compiling asm using NASM"
  12.     input=$1
  13.     output=$2
  14.     inter=$2.o
  15.     bits=$3
  16.     nasm -f elf$bits -o $inter $input
  17.     ret=$?
  18.     if [ $ret != 0 ] ; then
  19.         echo "NASM compile failed!"
  20.         exit
  21.     else
  22.         echo "Compiling using GCC for final binary"
  23.         gcc -m$bits -o $output $inter
  24.         ret=$?
  25.         if [ $ret != 0 ] ; then
  26.             echo "There was a problem with linking!"
  27.             exit
  28.         else
  29.             rm $inter
  30.             echo "Compile finished!"
  31.         fi
  32.     fi
  33. fi
RAW Paste Data