summaryrefslogtreecommitdiff
path: root/instruction.h
blob: 1924e8944fb692c327f564bd93157af79ee07b40 (plain)
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

#ifndef INSTRUCTION_H_
#define INSTRUCTION_H_

#include <vector>

#include "evaluator.h"
#include "register_address.h"

class emulator;

class instruction {

public:
	instruction(
		const char * name,
		evaluator * evaluator,
		std::vector<register_address> dst,
		unsigned int src_reg_count);
	virtual void execute(emulator & emulator) = 0;
	virtual void add_src_reg(std::vector<register_address> src_reg);

protected:
	const char * m_name;
	evaluator * m_evaluator;
	std::vector<register_address> m_dst;
	std::vector<std::vector<register_address> > m_src_regs;
	unsigned int m_src_reg_count;
};

class add_instruction : public instruction {
public:
	add_instruction(
		std::vector<register_address> dst,
		std::vector<register_address> src0,
		std::vector<register_address> src1);

	add_instruction(std::vector<register_address> dst);
	void execute(emulator & emulator);
private:
	std::vector<register_address> m_src0;
	std::vector<register_address> m_src1;
};

class mov_instruction : public instruction {
public:
	mov_instruction(std::vector<register_address> dst);
	void execute(emulator & emulator);
};

class mul_instruction : public instruction {
public:
	mul_instruction(std::vector<register_address> dst);
	void execute(emulator & emulator);
};

/**
 * dst = src0 * src1 + src2
 */
class mad_instruction : public instruction {
public:
	mad_instruction(std::vector<register_address> dst);
	void execute(emulator & emulator);
};

#endif //INSTRUCTION_H_