EvilZone
Programming and Scripting => Scripting Languages => : DerpyTurtle November 01, 2013, 12:52:55 AM
-
So I am thinking of taking on the task of learning Assembly, was bored one night and decided to write a shell script to compile and build my assembly files. What I am asking of you fine folks is to provide some helpful criticism and give me your input on this script and your ideas on what I could do to make it better. Feel free to use it and modify it as you wish. I have tested it and it does indeed work!
Here is the script
#!/bin/bash
#: Title :asm2exe (Assembly to Executable)
#: Date :(C)2013
#: Author :derpyturtle
#: Version :1.0
#: Description :A small script to compile and build .asm files with ease.
#: Options :
echo " _____ __ __ ___ ________ ________
/\ / ____| \/ |__ \| ____\ \ / / ____|
/ \ | (___ | \ / | ) | |__ \ V /| |__
/ /\ \ \___ \| |\/| | / /| __| > < | __|
/ ____ \ ____) | | | |/ /_| |____ / . \| |____
/_/ \_\_____/|_| |_|____|______/_/ \_\______|" #display ascii art logo
echo #skip a line
echo #skip a line
echo "This is a program to make compiling"
echo " and building your .asm files a breeze!\c" #display message to user
echo #skip a line
echo "Enter the name of the file you would like to compile"
echo "(Please use the full path if it applies):" #prompt user to enter filename
read filename #read input and save it in filename
echo "You want to compile $filename, correct? (y/n)" #prompt user again to be sure
read answer
if test "$answer" = y
then
echo #skip a line
echo "Compilation will begin shortly..." #display message to user
nasm -f elf $filename #begin building process
echo "Ready to begin with step 2!"
echo "Please enter the new file name" #prompt user for .o file
read file2
echo "\n"
echo "Finalizing compilation..."
gcc $file2 -o final
else
echo "Please re-enter the name of the file you would like to use: " #prompt user to re-enter initial file name
read filename #re-check user input
fi
echo "Your file is ready!"
echo "Thank you for using asm2exe"
exit 0
-
I don't really see the advantage. It's ok for having a little bash exercise, but using this script will take much longer than just executing the commands on command line or using a make file.
So why not just create a make file?
-
Honestly I was quite bored and I wanted to do something, but I couldnt think of anything really until this came to mind but its just something I decided to do. Just thought it would be useful in some way. As far as the Make file, I am not too experienced with them, I've used them but never actually made one myself.
-
Stupidest script ever.
Can type the commands in less time than it takes to look at the artwork on your script.
Go home.
-
Couple of aliases in .bashrc would speed up the process more then using the script but useless programs are a quality time killer when you're bored IMO.
-
Hi DerpyTurtle,
Please see below some corrections to your script. Its a good script, but you can definitely learn some tricks from my corrections. Mostly how to use read and echo correctly. ;) (also in bash we always make VARIABLES capitals.
Good Luck!
#!/bin/bash
#: Title :asm2exe (Assembly to Executable)
#: Date :(C)2013
#: Author :derpyturtle
#: Version :1.0
#: Description :A small script to compile and build .asm files with ease.
#: Options :
echo """ _____ __ __ ___ ________ ________
/\ / ____| \/ |__ \| ____\ \ / / ____|
/ \ | (___ | \ / | ) | |__ \ V /| |__
/ /\ \ \___ \| |\/| | / /| __| > < | __|
/ ____ \ ____) | | | |/ /_| |____ / . \| |____
/_/ \_\_____/|_| |_|____|______/_/ \_\______|
"
read -e -p """This is a program to make compiling
and building your .asm files a breeze!
Enter the name of the file you would like to compile
(Please use the full path if it applies):" FILENAME
read -p "You want to compile $FILENAME, correct? (y/n)" ANSWER
if [ $ANSWER = 'y' ] 2> /dev/null
then
echo """
Compilation will begin shortly..."
nasm -f elf $FILENAME
read -p """Ready to begin with step 2!
Please enter the new file name" FILE2
echo """
Finalizing compilation..."
gcc $FILE2 -o final
else
read -p "Please re-enter the name of the file you would like to use: " FILENAME
fi
echo """Your file is ready!
Thank you for using asm2exe"
exit 0
-
Ehh, what about 32/64 bit ELF mode, also why gcc? why not just link it?
-
Hi DerpyTurtle,
Please see below some corrections to your script. Its a good script, but you can definitely learn some tricks from my corrections. Mostly how to use read and echo correctly. ;) (also in bash we always make VARIABLES capitals.
Good Luck!
#!/bin/bash
#: Title :asm2exe (Assembly to Executable)
#: Date :(C)2013
#: Author :derpyturtle
#: Version :1.0
#: Description :A small script to compile and build .asm files with ease.
#: Options :
echo """ _____ __ __ ___ ________ ________
/\ / ____| \/ |__ \| ____\ \ / / ____|
/ \ | (___ | \ / | ) | |__ \ V /| |__
/ /\ \ \___ \| |\/| | / /| __| > < | __|
/ ____ \ ____) | | | |/ /_| |____ / . \| |____
/_/ \_\_____/|_| |_|____|______/_/ \_\______|
"
read -e -p """This is a program to make compiling"
and building your .asm files a breeze!
Enter the name of the file you would like to compile
(Please use the full path if it applies):" FILENAME
read -p "You want to compile $FILENAME, correct? (y/n)" ANSWER
if [ $ANSWER = 'y' ] 2> /dev/null
then
echo """
Compilation will begin shortly..."
nasm -f elf $FILENAME
read -p """Ready to begin with step 2!
Please enter the new file name" FILE2
echo """
Finalizing compilation..."
gcc $FILE2 -o final
else
read -p "Please re-enter the name of the file you would like to use: " FILENAME
fi
echo """Your file is ready!
Thank you for using asm2exe"
exit 0
Thanks! Ill take a look at it!
Ehh, what about 32/64 bit ELF mode, also why gcc? why not just link it?
The book I am using to learn assembly uses gcc. Im still new to this whole process so linking is something I will look into!
-
Thanks! Ill take a look at it!
The book I am using to learn assembly uses gcc. Im still new to this whole process so linking is something I will look into!
Well you should look at it because using gcc and libc functions is kinda cheating in ASM :P
-
This is the book Im using to start out
http://www.amazon.com/Assembly-Language-Step---step-Programming/dp/0471375233/ref=sr_1_3?ie=UTF8&qid=1383542586&sr=8-3&keywords=assembly+language+step+by+step (http://www.amazon.com/Assembly-Language-Step---step-Programming/dp/0471375233/ref=sr_1_3?ie=UTF8&qid=1383542586&sr=8-3&keywords=assembly+language+step+by+step)
Then I plan to move on to this book
http://www.amazon.com/Professional-Assembly-Language-Richard-Blum/dp/0764579010/ref=sr_1_1?ie=UTF8&qid=1383542627&sr=8-1&keywords=professional+assembly+language (http://www.amazon.com/Professional-Assembly-Language-Richard-Blum/dp/0764579010/ref=sr_1_1?ie=UTF8&qid=1383542627&sr=8-1&keywords=professional+assembly+language)
The first says to use nasm and then compile with gcc. So hopefully the other book will cover the topic of linking or maybe this one will later on.