-
Notifications
You must be signed in to change notification settings - Fork 1
/
P5_andi+xor_T3.asm
260 lines (209 loc) · 4.63 KB
/
P5_andi+xor_T3.asm
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# 10 Insn include:
# j Jal jr addu subu ori lw sw beq lui
# andi xor
### initial the sp & var
ori $k0, $0, 0x01
ori $k1, $0, 0x04
ori $sp, $0, 0x20
sw $sp, 0($0)
move $s6, $0
move $s7, $0
#### No.1 Instr-sequence
andi $a0, $k1, 0x0f0f
ori $a1, $a0, 0x0080 # I.E_RS -- Cal.M
ori $a2, $a0, 0x1111 # I.E_RS -- Cal.W
xor $a3, $a0, $k0
## after every hazard, save the result for checking
sw $a1, 0($sp)
addu $sp, $sp, $k1
sw $a2, 0($sp) # Store.M_Rt -- Cal.W
addu $sp, $k1, $sp # R.E_Rt -- Cal.W
sw $a3, 0($sp)
move $t1, $k1
addu $sp, $t1, $sp # R.E_Rt -- Cal.M
#### No.2 Instr-sequence
lw $t0, 0x20($0)
ori $t1, $t0, 0x4444 # I.E_RS -- Load.M & I.E_RS -- Load.W
sw $t1, 0($sp)
addu $sp, $sp, $k1
#### No.3 Instr-sequence
jal f1 # I.E_RS -- Jal.W
addu $s7, $s7, $k0
sw $t1, 0($sp)
addu $sp, $sp, $k1
#### No.4 Instr-sequence
addu $t1, $t1, $t0
addu $t2, $t1, $t0 # R.E_RS -- Cal.M
addu $t3, $t1, $t0 # R.E_RS -- Cal.W
sw $t2, 0($sp)
addu $sp, $sp, $k1
sw $t3, 0($sp)
addu $sp, $sp, $k1
#### No.5 Instr-sequence
ori $t1, $0, 0x4
sw $a0, 0($t1) # Store.E_RS -- Cal.M
sw $a1, 4($t1) # Store.E_RS -- Cal.W
#### No.10 Instr-sequence
ori $t2, $0, 0x8
lw $t1, 0($t2) # Load.E_RS -- Cal.M
lw $t3, 0($t2) # Load.E_RS -- Cal.W
sw $t1, 0($sp)
addu $sp, $sp, $k1
sw $t3, 0($sp)
addu $sp, $sp, $k1
#### No.12 Instr-sequence
lw $t0, -12($sp)
beq $t0, $t1, _lbl_1 # Br.D_RS -- Load.E & Br.D_RS -- Load.M & Br.D_RS -- Load.W
addu $s7, $s7, $k0
addu $s6, $s6, $k0
#### No.13 Instr-sequence
_lbl_1:
lw $t0, -4($sp)
beq $t1, $t0, _lbl_2 # Br.D_RT -- Load.E & Br.D_RT -- Load.M & Br.D_RT -- Load.W
addu $s7, $s7, $k0
addu $s6, $s6, $k0
#### No.14 Instr-sequence
_lbl_2:
addu $t0, $a0, $0
addu $t1, $a1, $0
beq $t1, $t0, _lbl_3 # Br.D_RS -- Cal.E && Br.D_RS -- Cal.M && Br.D_RT -- Cal.W
addu $s7, $s7, $k0
addu $s6, $s6, $k0
#### No.16 Instr-sequence
_lbl_3:
addu $t0, $a2, $0
addu $t1, $a2, $0
beq $t0, $t1, _lbl_5 # Br.D_RT -- Cal.E && Br.D_RT -- Cal.M && Br.D_RS -- Cal.W
addu $s7, $s7, $k0
addu $s6, $s6, $k0
#### No.17 Instr-sequence
_lbl_5:
lw $t0, -4($sp)
addu $t1, $t0, $t0 # R.E_RS -- Load.M & R.E_RS -- Load.W & R.E_RT -- Load.M & R.E_RT -- Load.W
sw $t1, 0($sp)
addu $sp, $sp, $k1
#### No.24 Instr-sequence
lw $t0, 0($0)
lw $t1, 0($t0) # Load.E_RS -- Load.M & Load.E_RS -- Load.W
sw $t1, 0($sp)
addu $sp, $sp, $k1
#### No.25 Instr-sequence
sw $sp, 0($0) # prepare for next hazard
addu $sp, $sp, $k1
lw $t0, 0($0)
sw $t0, 0($t0) # Store.E_RS -- Load.M & Store.E_RS -- Load.W & STORE.M_RT -- Load.W
#### No.27 Instr-sequence
jal f2
addu $s7, $s7, $k0
#### No.27 Instr-sequence
move $t1, $ra
ori $t0, $0, 24
addu $t1, $t1, $t0
move $t9, $0 # nop
jal f3
addu $s7, $s7, $k0
#### No.27 Instr-sequence
ori $t0, $0, 212
addu $t1, $ra, $t0
jal f4
addu $s7, $s7, $k0
#### No.28 Instr-sequence
ori $t0, $0, 80
addu $t1, $ra, $t0
jal f5
addu $s7, $s7, $k0
#### No.29 Instr-sequence
jal f6
addu $s7, $s7, $k0
#### No.30 Instr-sequence
jal f7
addu $s7, $s7, $k0
#### No.30 Instr-sequence
jal f8
addu $s7, $s7, $k0
#### No.30 Instr-sequence
jal f10
addu $s7, $s7, $k0
### store delay slot counter ###
sw $s7, 0($sp)
addu $sp, $sp, $k1
sw $s6, 0($sp)
addu $sp, $sp, $k1
_loop:
j _loop
move $t9, $0 # nop
move $t9, $0 # nop
### Function List ###
f1:
ori $t1, $31, 0x56 # I.E_RS -- Jal.W
jr $31
addu $s7, $s7, $k0
move $t9, $0 # nop
f2:
lw $t1, -0x3100($ra) # Load.E_Rs -- Jal.W
sw $t1, 0($sp)
addu $sp, $sp, $k1
jr $31
addu $s7, $s7, $k0
move $t9, $0 # nop
f3:
move $t9, $0 # nop
beq $t1, $ra, _f3_lbl # Br.D_RS -- Jal.W
addu $s7, $s7, $k0
addu $s6, $s6, $k0
_f3_lbl:
jr $ra
addu $s7, $s7, $k0
move $t9, $0 # nop
f4:
beq $t1, $ra, _f4_lbl # Br.D_RS -- Jal.M
addu $s7, $s7, $k0
addu $s6, $s6, $k0
_f4_lbl:
jr $ra
addu $s7, $s7, $k0
move $t9, $0 # nop
f5:
beq $ra, $t1, _f5_lbl # Br.D_RT -- Jal.M
addu $s7, $s7, $k0
addu $s6, $s6, $k0
_f5_lbl:
jr $ra
addu $s7, $s7, $k0
f6:
addu $t0, $ra, $ra # R.E_RS -- Jal.W & R.E_RT -- Jal.W
sw $t0, 0($sp)
addu $sp, $sp, $k1
jr $ra
addu $s7, $s7, $k0
f7:
sw $sp, -0x3160($ra) # Store.E_Rs -- Jal.W
jr $ra
addu $s7, $s7, $k0
f8:
sw $ra, 0($sp)
addu $sp, $sp, $k1
subu $ra, $ra, $k1
jal f9
addu $s7, $s7, $k0
lw $ra, -8($sp) # jr.D_Rs -- Load.E & jr.D_Rs -- Load.M & jr.D_Rs -- Load.W
jr $ra # jr.D_RS -- Jal.M
addu $s7, $s7, $k0
f9:
sw $ra, 0($sp)
addu $sp, $sp, $k1
ori $t0, $0, 8
addu $ra, $ra, $t0
move $t9, $0 # nop
move $t9, $0 # nop
subu $ra, $ra, $t0 # jr.D_Rs -- Cal.E & jr.D_Rs -- Cal.M
jr $ra
addu $s7, $s7, $k0
f10:
ori $t0, $0, 0x3000
subu $ra, $ra, $t0
sw $ra, 0($sp)
addu $sp, $sp, $k1
ori $ra, $ra, 0x3000
jr $ra # jr.D_RS -- Jal.M
addu $s7, $s7, $k0