forked from whaleygeek/MyLittleComputer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_suite
executable file
·158 lines (117 loc) · 1.71 KB
/
test_suite
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#! /bin/bash
rm actual_results.txt
echo ---- assemble/disassemble test.lmc
cat <<END > test.lmc
INP
STA 18
INP
STA 19
LDA 18
ADD 19
STA 20
LDA 18
SUB 19
STA 21
LDA 20
OUT
LDA 21
OUT
BRA 14
BRZ 15
BRP 16
IO
IO 00
IO 01
IO 02
IO 03
IO 04
IO 05
HLT
HLT 00
HLT 01
HLT 02
HLT 03
DAT 01
DAT 02
DAT 03
DAT 04
END
python assembler.py test.lmc test.out
python disassembler.py test.out test.dis
cat test.dis >> actual_results.txt
echo ---- assemble/disassemble multiply.lmc
cat <<END > multiply.lmc
INP
STA FIRST
INP
STA SECOND
STA COUNT
MULT LDA COUNT
BRZ MULTEND
SUB ONE
STA COUNT
LDA FIRST
ADD TOTAL
STA TOTAL
BRA MULT
MULTEND LDA TOTAL
OUT
HLT
ONE DAT 001
COUNT DAT
TOTAL DAT
FIRST DAT
SECOND DAT
END
python assembler.py multiply.lmc multiply.out
python disassembler.py multiply.out multiply.dis
cat multiply.dis >> actual_results.txt
echo ---- simulate multiply.lmc
python simulator.py multiply.out <<END > multiply.run
5
3
END
cat multiply.run >> actual_results.txt
echo ---- interactive session to add two numbers
python interactive.py <<END > interactive.run
INP
10
STA 010
INP
20
STA 011
LDA 010
ADD 011
STA 012
LDA 012
OUT
HLT
END
cat interactive.run >> actual_results.txt
echo ---- new USB, MUL and DIV instruction mnemonics
python interactive.py <<END > interactive2.run
INP
2
STA 022
INP
3
STA 023
USB
LDA 022
LDA 023
MUL
OUT
HLT
END
cat interactive2.run >> actual_results.txt
echo ---- Test compiler
cat > math.e <<END
(((2+3)-1)*3)/2;
END
python compiler.py < math.e > math.lmc
python assembler.py math.lmc math.dec
python disassembler.py math.dec math.dis
python simulator.py math.dec > math.run
cat math.run >> actual_results.txt
echo ---- Comparing Results
diff expected_results.txt actual_results.txt