-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathasmit.sh
executable file
·133 lines (133 loc) · 3.92 KB
/
asmit.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# !/bin/bash
# this is a script for use dosbox to run TASM/MASM tools
# set value
tool="$(dirname "$0")"
test="${tool}/work"
boxconf="$tool/dosbox/dosbox-0.74.conf"
mode='C'
print=0
# check whether installed dosbox
if type dosbox
then
echo !Msg: dosbox installed
else
echo !Msg: You need install dosbox first
echo !Msg: *Maybe You can use:sudo apt install dosbox
exit
fi
# check the file path
if [ -z "$1" ]
then
echo "./asmit.sh <file> [-d <toolsdir> -m <mode> -w <workdir>]"
echo "./asmit.sh -h for help"
exit
# display the help
elif [ "$1" = "-h" ]
then
echo './asmit.sh <file> [-d <toolsdir> -m <mode> -w <workdir>]'
echo '<file> file to be used '
echo '<mode> choose mode the way display default is 1'
echo " 0 copy the files open dosbox add path"
echo " 1 tasm run output in dosbox"
echo " 2 tasm run pause exit"
echo " 3 tasm run and td"
echo " 4 open turbo debugger at test folder"
echo " 5 masm run output in dosbox"
echo " 6 masm run pause exit"
echo " 7 masm and debug"
echo " 8 open masm debug at test folder"
echo " A tasm run output in shell"
echo " B masm run ouput in shell"
echo " C simplipfy output open turbo debugger at test folder"
echo " D simplipfy output open masm debug at test folder"
echo '<tooldir> the tools folder with subdir masm,tasm'
echo '<workdir> the folder of asm.bat'
# make sure the file readable and is a ASM file
elif [ -r "$1" ]
then
file=$1
# get the options
echo
shift
while getopts :m:d: opt
do
case "$opt" in
m) mode=$OPTARG;;
d) tool=$OPTARG
if [ -d "${tool}" ]
then
echo Your directory concludes
ls "${tool}"
else
echo invalid ${tool} not a readable directory
exit
fi;;
w) test=$OPTARG
if [ -d "${test}" ];
then
echo Your directory concludes
ls ${test}
else
echo invalid ${test} not a readable directory
exit
fi;;
*) echo "unknown option: $opt";;
esac
done
if [ "${mode}" = A ] || [ "${mode}" = B ];then
print=1
elif [ "${mode}" = C ] || [ "${mode}" = D ];then
print=2
fi
if [ "$print" = 0 ];then
boxconf="$tool/dosbox/bigbox.conf"
fi
# output infomation
echo !Msg: ASMtoolsfrom:$(pwd)
echo !Msg: ASMfilefrom:$file
echo !Msg: Mode:$mode Time:$(date)
# check the file
if [ $mode != 4 ] && [ $mode != 8 ]
then
if [ ${file##*.} != ASM ] && [ ${file##*.} != asm ];then
echo "the ${file##*.} file may not a assembly source code file"
echo ---
if ! read -t 10 -p "press Y to use it as an asmfile: " selection || [ ${selection} != Y ]
then
echo "No \"Y\" catched back to shell"
exit
fi
fi
# copy file to test
ls "${test}" || mkdir "${test}" && rm "${test}/T.*"
echo removed
cp "$file" "${test}/T.ASM"
# echo deleted temp files
fi
# do the operation
cd "${test}"
dosbox -conf "${boxconf}" -noautoexec\
-c "mount c \"$tool\"" -c "mount d \"$test\""\
-c "d:"\
-c "asm/m ${mode}"
echo ASMfilefrom:${file}
if [ "$print" = 1 ];then
echo "!Msg:[ASM and link] info:"
cat T.TXT
if [ -r T.OUT ];then
echo "!Msg: [YOUR program] OUTPUT:"
cat T.OUT
echo
fi
elif [ "$print" = 2 ];then
tail -n +4 T.TXT
if [ -r T.OUT ];then
echo "!Msg: [YOUR program] OUTPUT:"
cat T.OUT
echo
fi
fi
else
echo invalid path $1
fi
exit