From bafce57ad94cdb761215b37db6c586a13da44c9c Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Tue, 27 Dec 2016 05:05:26 +0100 Subject: [PATCH] more intelligent decoding --- cpu.c | 73 +++++++++++-------------------------------------------------------------- 1 file changed, 11 insertions(+), 62 deletions(-) diff --git a/cpu.c b/cpu.c index a04e1f6..e07966c 100644 --- a/cpu.c +++ b/cpu.c @@ -245,88 +245,37 @@ void decode_instruction(uint16_t opcode, uint16_t *arg1, uint16_t *arg2, uint16_ switch(opcode) { case HALT: - break; - case MOV: - *arg1 = fetch(); - *arg2 = fetch(); + case RET: + case NOP: break; case PUSH: - *arg1 = fetch(); - break; case POP: - *arg1 = fetch(); - break; - case TEQ: - *arg1 = fetch(); - *arg2 = fetch(); - *arg3 = fetch(); - break; - case TGT: - *arg1 = fetch(); - *arg2 = fetch(); - *arg3 = fetch(); - break; case JMP: + case CALL: + case OUT: + case IN: *arg1 = fetch(); break; + case MOV: case JNZ: - *arg1 = fetch(); - *arg2 = fetch(); - break; case JZ: + case NOT: + case LOAD: + case STOR: *arg1 = fetch(); *arg2 = fetch(); break; + case TEQ: + case TGT: case ADD: - *arg1 = fetch(); - *arg2 = fetch(); - *arg3 = fetch(); - break; case MUL: - *arg1 = fetch(); - *arg2 = fetch(); - *arg3 = fetch(); - break; case MOD: - *arg1 = fetch(); - *arg2 = fetch(); - *arg3 = fetch(); - break; case AND: - *arg1 = fetch(); - *arg2 = fetch(); - *arg3 = fetch(); - break; case OR: *arg1 = fetch(); *arg2 = fetch(); *arg3 = fetch(); break; - case NOT: - *arg1 = fetch(); - *arg2 = fetch(); - break; - case LOAD: - *arg1 = fetch(); - *arg2 = fetch(); - break; - case STOR: - *arg1 = fetch(); - *arg2 = fetch(); - break; - case CALL: - *arg1 = fetch(); - break; - case RET: - break; - case OUT: - *arg1 = fetch(); - break; - case IN: - *arg1 = fetch(); - break; - case NOP: - break; default: break; } -- libgit2 0.22.2