-
Notifications
You must be signed in to change notification settings - Fork 0
/
instructions.yml
298 lines (279 loc) · 5.83 KB
/
instructions.yml
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# Esse arquivo contém a lista das instruções MIPS.
#
# A subcrate `indy-macros` consome essa lista e gera *automaticamente*
# a implementação do decoder das instruções.
#
# O rationale desse método é que é menos repetitivo desse jeito. Anteriormente,
# eu precisaria implementar cada nova instrução em uns 4 lugares. Usando isso, eu
# descrevo ela aqui e só preciso implementar a nova variante do enum no cpu.rs.
#
# Também, foi uma desculpa para eu finalmente aprender a usar procedural macros. Ah,
# e também uma justificativa minha para eu procrastinar outras disciplinas :p
#
# Campos:
# - opcode: o valor de `opcode` da instrução. Para as R, é 0 por default.
# - funct: o valor de `funct` da instrução.
# - sign_ext: `true` se o valor imediato deve ser interpretado como um signed. Opcional
# e defaulta para `true`.
# - one_operand: `true` se a instrução só leva em consideração apenas um operando. Opcional
# e defaulta para `false`.
# - shift: `true` se a instrução usa o campo `shamt`. Opcional e defaulta para `false`.
# - invert: `true` se o disassemble da instrução deve mostrar os operandos na ordem invertida.
# Opcional e defaulta para `false`.
# - load_store: `true` se a instrução faz load/store.
# - half_word: `true` se a instrução só tem
#
# Welp, depois da parte 2 do projeto essa solução não ficou tão ideal.
# Já tive que adicionar duas instruções que não entram nesse pattern -- a mfc1 e a nop.
# Pra isso, coloquei hardcoded nas partes relevantes da macro.
#
# TODO é arrumar isso.
# Instrucoes R
r:
# Core Instruction Set
add:
funct: 0x20
addu:
funct: 0x21
and:
funct: 0x24
jr:
funct: 0x08
one_operand: true
nor:
funct: 0x27
or:
funct: 0x25
slt:
funct: 0x2a
sltu:
funct: 0x2b
sll:
funct: 0x00
shift: true
srl:
funct: 0x02
shift: true
sub:
funct: 0x22
subu:
funct: 0x23
# Arithmetic Core Instruction Set
div:
funct: 0x1A
divu:
funct: 0x1B
mfhi:
funct: 0x10
move_cop: true
mflo:
funct: 0x12
move_cop: true
mfc0:
opcode: 0x10
funct: 0x00
move_cop: true
mtc0:
opcode: 0x10
funct: 0x01
move_cop: true
mult:
funct: 0x18
two_operands_alt: true
multu:
funct: 0x19
two_operands_alt: true
sra:
funct: 0x03
shift: true
syscall:
funct: 0x0c
has_args: false
jalr:
funct: 0x09
two_operands: true
break:
funct: 0x0d
has_args: false
xor:
funct: 0x26
# Instrucoes I
i:
addi:
opcode: 0x08
addiu:
opcode: 0x09
andi:
opcode: 0x0C
beq:
opcode: 0x04
invert: true
bne:
opcode: 0x05
invert: true
lbu:
opcode: 0x24
lb:
opcode: 0x20
load_store: true
lhu:
opcode: 0x25
ll:
opcode: 0x30
lui:
opcode: 0x0F
half_word: true
lw:
opcode: 0x23
load_store: true
ori:
opcode: 0x0D
slti:
opcode: 0x0A
sltiu:
opcode: 0x0B
sb:
opcode: 0x28
sc:
opcode: 0x38
sh:
opcode: 0x29
sw:
opcode: 0x2B
load_store: true
blez:
opcode: 0x06
two_operands: true
bal:
opcode: 0x11
two_operands: true
bgez:
opcode: 0x01
two_operands: true
# Arithmetic Core Instruction Set
lwc1:
opcode: 0x31
load_store: true
target_is_float: true
ldc1:
opcode: 0x35
load_store: true
target_is_float: true
swc1:
opcode: 0x39
load_store: true
target_is_float: true
sdc1:
opcode: 0x3D
# Instrucoes J
j:
j:
opcode: 0x02
jal:
opcode: 0x03
# Instrucoes FR
fr:
# Aritmetica
add.s:
opcode: 0x11
fmt: 0x10
funct: 0x0
add.d:
opcode: 0x11
fmt: 0x11
funct: 0x0
sub.s:
opcode: 0x11
fmt: 0x10
funct: 0x01
sub.d:
opcode: 0x11
fmt: 0x11
funct: 0x01
mul.s:
opcode: 0x11
fmt: 0x10
funct: 0x02
mul.d:
opcode: 0x11
fmt: 0x11
funct: 0x02
div.s:
opcode: 0x11
fmt: 0x10
funct: 0x03
div.d:
opcode: 0x11
fmt: 0x11
funct: 0x03
# Comparacao
c.eq.s:
opcode: 0x11
fmt: 0x10
funct: 0x32
c.lt.s:
opcode: 0x11
fmt: 0x10
funct: 0x3c
two_operands_alt: true
c.le.s:
opcode: 0x11
fmt: 0x11
funct: 0x3e
c.eq.d:
opcode: 0x11
fmt: 0x11
funct: 0x32
c.lt.d:
opcode: 0x11
fmt: 0x11
funct: 0x3c
c.le.d:
opcode: 0x11
fmt: 0x11
funct: 0x3e
# segura o shoehorn!
mfc1:
opcode: 0x11
fmt: 0x00
funct: 0x00
two_operands: true
first_is_float: true
mtc1:
opcode: 0x11
fmt: 0x04
funct: 0x00
two_operands: true
first_is_float: true
# essas nao estao no greencard
mov.s:
opcode: 0x11
fmt: 0x10
funct: 0x06
two_operands: true
mov.d:
opcode: 0x11
fmt: 0x11
funct: 0x06
two_operands: true
# conversao
cvt.d.w:
opcode: 0x11
fmt: 0x14
funct: 0x21
two_operands: true
cvt.s.d:
opcode: 0x11
fmt: 0x11
funct: 0x20
two_operands: true
# Instrucoes FI
fi:
bc1t:
opcode: 0x11
fmt: 0x08
ft: 0x01
bc1f:
opcode: 0x11
fmt: 0x08
ft: 0x00