-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode_instruction.cpp
More file actions
64 lines (57 loc) · 2.23 KB
/
decode_instruction.cpp
File metadata and controls
64 lines (57 loc) · 2.23 KB
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
#include "enums.h"
#include "instructions.h"
#include "instruction.h"
#include "decoder.h"
GROUP getGroup(int number, int n) {
return static_cast<GROUP>(number & ((1 << n) - 1));
}
Instruction16 Decoder::decodeInstruction(uint16_t raw_bytes) {
GROUP last;
for (int i = 3; i < 6; i++) {
last = getGroup(raw_bytes, i);
switch(i) {
case 3:
switch(last) {
case GROUP::ZERO_OP:
return InstructionOneOp(raw_bytes, GROUP::ZERO_OP);
case GROUP::IMM_6:
return InstructionImm6(raw_bytes, GROUP::IMM_6);
case GROUP::IMM_9:
return InstructionImm9(raw_bytes, GROUP::IMM_9);
case GROUP::BR_REL_N:
return InstructionBranchAbsRelN(raw_bytes, GROUP::BR_REL_N);
case GROUP::BR_REL_P:
return InstructionBranchAbsRelP(raw_bytes, GROUP::BR_REL_P);
default:
break;
}
break;
case 4:
switch(last) {
case GROUP::MEM_3:
return InstructionMem3(raw_bytes, GROUP::MEM_3);
case GROUP::SHIFTS:
return InstructionShift(raw_bytes, GROUP::SHIFTS);
case GROUP::ALU3:
return InstructionALU3(raw_bytes, GROUP::ALU3);
default:
break;
}
break;
case 5:
switch(last) {
case GROUP::TWO_OP:
return InstructionTwoOp(raw_bytes, GROUP::TWO_OP);
case GROUP::MEM_2:
return InstructionMem2(raw_bytes, GROUP::MEM_2);
case GROUP::BR_ABS:
return InstructionBranchAbs(raw_bytes, GROUP::BR_ABS);
case GROUP::ALU3_IND:
return InstructionALU3Ind(raw_bytes, GROUP::ALU3_IND)
default:
break;
}
break;
}
}
}