-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstr.h
More file actions
44 lines (39 loc) · 1.02 KB
/
Copy pathinstr.h
File metadata and controls
44 lines (39 loc) · 1.02 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
#ifndef INSTR_H
#define INSTR_H
#include <cmath>
#include <cstdint>
#include <map>
#include <string>
class CPU;
class Instr {
private:
uint32_t m_opcode;
uint32_t m_r1;
uint32_t m_r2;
uint32_t m_r3_imm;
public:
static std::map<std::string, uint32_t> m_instrsDict;
static void prepareDict() {
#define _ISA(_opcode, _name, _execute, _asmargs, _disasmargs, _dumpregs) \
m_instrsDict[#_name] = _opcode;
#include "ISA.h"
#undef _ISA
}
void clear();
void executeCode(CPU *cpu, uint32_t code);
void execute(CPU *cpu);
std::string assembler(std::stringstream &input);
std::string disasm();
std::string dumpRegs(CPU *cpu);
uint32_t code();
void decode(uint32_t code);
void setOpcode(uint32_t opcode) { m_opcode = opcode; }
};
/* #define _ISA(_opcode, _name, _execute, _asmargs, _disasmargs, _dumpregs)\
class Instr_##_name : public Instr {\
void execute(CPU& cpu) {_execute};\
void disasm(std::stringstream &input) {std::string arg; _disasm }\
};
#include "ISA.h"
#undef _ISA */
#endif // INSTR_H