-
Notifications
You must be signed in to change notification settings - Fork 1
/
opcode_extension.cpp
86 lines (85 loc) · 2.87 KB
/
opcode_extension.cpp
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
#include "opcode_extension.hpp"
#include "utility_functions.hpp"
#include "opcodes/opcodes.hpp"
void mapOpcodeExtendedInstructions(InstructionArguments *ins_arg, Reader *reader, RegisterBank *rb, Memory *memory) {
uint8_t modrm_byte;
if (!reader->isEOF()) {
modrm_byte = reader->peekNextByte();
uint32_t reg = (uint32_t)((modrm_byte & ((uint8_t)7<<3))>>3);
switch(ins_arg->opcode) {
case 0x80:
case 0x81:
case 0x82:
case 0x83:
switch(reg) {
case 0:
add(ins_arg, reader, rb, memory);
break;
case 1:
or_(ins_arg, reader, rb, memory);
break;
case 4:
and_(ins_arg, reader, rb, memory);
break;
case 5:
sub(ins_arg, reader, rb, memory);
break;
default:
opcodeExtUnsupportedError(ins_arg->opcode);
break;
}
break;
case 0xc6:
switch(reg) {
case 0:
mov(ins_arg, reader, rb, memory);
break;
default:
opcodeExtUnsupportedError(ins_arg->opcode);
break;
}
break;
case 0xc7:
switch(reg) {
case 0:
mov(ins_arg, reader, rb, memory);
break;
default:
opcodeExtUnsupportedError(ins_arg->opcode);
break;
}
break;
case 0xfe:
switch (reg) {
case 0:
inc(ins_arg, reader, rb, memory);
break;
case 1:
dec(ins_arg, reader, rb, memory);
break;
default:
opcodeExtUnsupportedError(ins_arg->opcode);
break;
}
break;
case 0xff:
switch (reg) {
case 0:
inc(ins_arg, reader, rb, memory);
break;
case 1:
dec(ins_arg, reader, rb, memory);
break;
default:
opcodeExtUnsupportedError(ins_arg->opcode);
break;
}
break;
default:
opcodeExtUnsupportedError(ins_arg->opcode);
break;
}
} else {
printf("Incomplete instruction");
}
}