-
Notifications
You must be signed in to change notification settings - Fork 1
/
ASMFastDevelopment.sh
71 lines (65 loc) · 2.42 KB
/
ASMFastDevelopment.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
flag=$1
projectFolder=$2
currentFolder=${PWD}
function newProject {
mkdir "$currentFolder/$projectFolder/"
echo "; $projectFolder.asm" >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo "; x86 architecture" >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo "; Intel specification" >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo "section .data" >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo " " >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo "" >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo "section .text" >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo " global _start" >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo "" >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo "_start:" >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo " " >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo " " >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
echo " " >> "$currentFolder/src/projects/$projectFolder/$projectFolder.asm"
}
function compile {
cd "$currentFolder/src/projects/$projectFolder/"
nasm -f elf32 $projectFolder'.asm' -o $projectFolder'.o'
ld -m elf_i386 $projectFolder'.o' -o $projectFolder
cd $currentFolder
}
function printHelp {
echo
echo 'Usage: bash ASMFastDevelopment.sh [<options>] [<folder name>]'
echo
echo ' -h, --help Show helps'
echo ' -n, --new Create new project with folder name given'
echo ' -c, --compile Compile .asm file inside folder'
echo ' Disclaimer: This script works in current folder, do not try to compile outside this folder'
echo
echo 'Example:'
echo ' > bash CompileASM.sh -c HelloWorld'
echo
}
function printFinish {
echo 'Compilation done with 0 errors'
echo 'Check '$projectFolder' folder'
echo
}
while true; do
case "$flag" in
-h|--help)
printHelp
break
;;
-n|--new)
newProject
break
;;
-c|--compile)
compile
printFinish
break
;;
*)
printHelp
break
;;
esac
done