Commit bafce57ad94cdb761215b37db6c586a13da44c9c
1 parent
746fe14d
more intelligent decoding
Showing
1 changed file
with
11 additions
and
62 deletions
cpu.c
... | ... | @@ -245,88 +245,37 @@ void decode_instruction(uint16_t opcode, uint16_t *arg1, uint16_t *arg2, uint16_ |
245 | 245 | switch(opcode) |
246 | 246 | { |
247 | 247 | case HALT: |
248 | - break; | |
249 | - case MOV: | |
250 | - *arg1 = fetch(); | |
251 | - *arg2 = fetch(); | |
248 | + case RET: | |
249 | + case NOP: | |
252 | 250 | break; |
253 | 251 | case PUSH: |
254 | - *arg1 = fetch(); | |
255 | - break; | |
256 | 252 | case POP: |
257 | - *arg1 = fetch(); | |
258 | - break; | |
259 | - case TEQ: | |
260 | - *arg1 = fetch(); | |
261 | - *arg2 = fetch(); | |
262 | - *arg3 = fetch(); | |
263 | - break; | |
264 | - case TGT: | |
265 | - *arg1 = fetch(); | |
266 | - *arg2 = fetch(); | |
267 | - *arg3 = fetch(); | |
268 | - break; | |
269 | 253 | case JMP: |
254 | + case CALL: | |
255 | + case OUT: | |
256 | + case IN: | |
270 | 257 | *arg1 = fetch(); |
271 | 258 | break; |
259 | + case MOV: | |
272 | 260 | case JNZ: |
273 | - *arg1 = fetch(); | |
274 | - *arg2 = fetch(); | |
275 | - break; | |
276 | 261 | case JZ: |
262 | + case NOT: | |
263 | + case LOAD: | |
264 | + case STOR: | |
277 | 265 | *arg1 = fetch(); |
278 | 266 | *arg2 = fetch(); |
279 | 267 | break; |
268 | + case TEQ: | |
269 | + case TGT: | |
280 | 270 | case ADD: |
281 | - *arg1 = fetch(); | |
282 | - *arg2 = fetch(); | |
283 | - *arg3 = fetch(); | |
284 | - break; | |
285 | 271 | case MUL: |
286 | - *arg1 = fetch(); | |
287 | - *arg2 = fetch(); | |
288 | - *arg3 = fetch(); | |
289 | - break; | |
290 | 272 | case MOD: |
291 | - *arg1 = fetch(); | |
292 | - *arg2 = fetch(); | |
293 | - *arg3 = fetch(); | |
294 | - break; | |
295 | 273 | case AND: |
296 | - *arg1 = fetch(); | |
297 | - *arg2 = fetch(); | |
298 | - *arg3 = fetch(); | |
299 | - break; | |
300 | 274 | case OR: |
301 | 275 | *arg1 = fetch(); |
302 | 276 | *arg2 = fetch(); |
303 | 277 | *arg3 = fetch(); |
304 | 278 | break; |
305 | - case NOT: | |
306 | - *arg1 = fetch(); | |
307 | - *arg2 = fetch(); | |
308 | - break; | |
309 | - case LOAD: | |
310 | - *arg1 = fetch(); | |
311 | - *arg2 = fetch(); | |
312 | - break; | |
313 | - case STOR: | |
314 | - *arg1 = fetch(); | |
315 | - *arg2 = fetch(); | |
316 | - break; | |
317 | - case CALL: | |
318 | - *arg1 = fetch(); | |
319 | - break; | |
320 | - case RET: | |
321 | - break; | |
322 | - case OUT: | |
323 | - *arg1 = fetch(); | |
324 | - break; | |
325 | - case IN: | |
326 | - *arg1 = fetch(); | |
327 | - break; | |
328 | - case NOP: | |
329 | - break; | |
330 | 279 | default: |
331 | 280 | break; |
332 | 281 | } | ... | ... |