-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpcodeTable.h
More file actions
60 lines (51 loc) · 1.67 KB
/
Copy pathOpcodeTable.h
File metadata and controls
60 lines (51 loc) · 1.67 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
#include <stdexcept>
#include <iostream>
#include "types.h"
#include "SystemInformation.h"
#include "opcode/Opcode.h"
#include "opcode/BinaryOperation.h"
#include "opcode/UnaryOperation.h"
#include <random>
#ifndef __opcode_table_h
#define __opcode_table_h
class OpcodeTable;
using Routine = void (OpcodeTable::*)(OPCODE);
class OpcodeTable {
public:
OpcodeTable(SystemInformation *sysInfo);
void executeOpcode(OPCODE command);
private:
void setupTable();
unsigned int getOpcodeTableIndex(OPCODE command);
unsigned int get0thOpcodeTableIndex(OPCODE command);
unsigned int get8thOpcodeTableIndex(OPCODE command);
void callMachineCode(OPCODE);
void clearDisplay(OPCODE);
void subReturn(OPCODE);
void jump(OPCODE);
void call(OPCODE);
void skipIfRegisterEqualToConstant(OPCODE);
void skipIfRegisterNotEqualToConstant(OPCODE);
void skipIfRegistersEqual(OPCODE);
void setRegisterToConstant(OPCODE);
void addConstantToRegister(OPCODE);
void set(OPCODE);
void binaryOr(OPCODE);
void binaryAnd(OPCODE);
void binaryXOR(OPCODE);
void add(OPCODE);
void subtract(OPCODE);
void shiftRight(OPCODE);
void subtractn(OPCODE);
void shiftLeft(OPCODE);
void skipIfRegistersNotEqual(OPCODE);
void setI(OPCODE);
void jumpWithOffset(OPCODE);
void rand(OPCODE);
void skipNextInstructionIf(bool);
SystemInformation *sysInfo;
std::array<Routine, NUM_OPCODES> table;
std::mt19937 gen{100};
std::uniform_int_distribution<> distrib{0, 255};
};
#endif