summaryrefslogtreecommitdiffstats
path: root/ue3/mycpu/cinstruction.h
diff options
context:
space:
mode:
Diffstat (limited to 'ue3/mycpu/cinstruction.h')
-rw-r--r--ue3/mycpu/cinstruction.h196
1 files changed, 196 insertions, 0 deletions
diff --git a/ue3/mycpu/cinstruction.h b/ue3/mycpu/cinstruction.h
new file mode 100644
index 0000000..d393e09
--- /dev/null
+++ b/ue3/mycpu/cinstruction.h
@@ -0,0 +1,196 @@
1/**
2 * @module cinstruction
3 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
4 * @brief abstract class cpu instructions
5 * @date 17.04.2009
6 */
7
8#ifndef CINSTRUCTION_H
9#define CINSTRUCTION_H
10#include <map>
11#include <vector>
12#include "cmem.h"
13
14
15
16/**
17 * @class CInstruction
18 *
19 * Parses a simple line based scriptfile with some limitations:
20 * first function (starting a block) must be a read-command,
21 * last must be a write-command (ending this block).
22 *
23 * read- and write-commands have hard coded parameters, number#1 being a filetype.
24 * Classes handling certain filetypes must be of type CFile.
25 * Custom functions will be passed to CFile::callFunc().
26 *
27 * On error ParserError will be thrown.
28 */
29class CInstruction
30{
31 public:
32
33
34
35
36 /**
37 * @method ~CInstruction
38 * @brief Default dtor
39 * @param -
40 * @return -
41 * @globalvars none
42 * @exception none
43 * @conditions none
44 */
45 virtual ~CInstruction()
46 {}
47
48
49 virtual void exec(CMem& mem, std::vector<std::string>& instr) = 0;
50
51
52
53
54};
55
56
57
58
59class CFlagInstruction : public CInstruction
60{
61 public:
62
63 void exec(CMem& mem, std::vector<std::string>& instr)
64 {}
65 virtual void exec(CMem& mem, std::vector<std::string>& instr, bool& flag) = 0;
66
67
68};
69
70
71
72class CInc : public CInstruction
73{
74 public:
75 virtual void exec(CMem& mem, std::vector<std::string>& instr);
76};
77
78
79class CDec : public CInstruction
80{
81 public:
82 virtual void exec(CMem& mem, std::vector<std::string>& instr);
83};
84
85
86
87class CAdd : public CInstruction
88{
89 public:
90 virtual void exec(CMem& mem, std::vector<std::string>& instr);
91};
92
93
94
95class CSub : public CInstruction
96{
97 public:
98 virtual void exec(CMem& mem, std::vector<std::string>& instr);
99};
100
101
102
103class CMul : public CInstruction
104{
105 public:
106 virtual void exec(CMem& mem, std::vector<std::string>& instr);
107};
108
109
110
111class CDiv : public CInstruction
112{
113 public:
114 virtual void exec(CMem& mem, std::vector<std::string>& instr);
115};
116
117
118
119class CLoad : public CInstruction
120{
121 public:
122 virtual void exec(CMem& mem, std::vector<std::string>& instr);
123};
124
125
126
127class CStore : public CInstruction
128{
129 public:
130 virtual void exec(CMem& mem, std::vector<std::string>& instr);
131};
132
133class CTest : public CFlagInstruction
134{
135 public:
136 void exec(CMem& mem, std::vector<std::string>& instr, bool& flag)
137 {}
138 virtual void test(CMem& mem, std::vector<std::string>& instr,
139 bool& f_zero, bool& f_sign);
140};
141
142
143class CLabel : public CInstruction
144{
145 public:
146 void exec(CMem& mem, std::vector<std::string>& instr)
147 {}
148
149};
150
151
152class CJumpa : public CInstruction
153{
154 public:
155 CJumpa(std::map<std::string, unsigned int>& jumpaddr)
156 : m_jumpaddr(jumpaddr)
157 {}
158 virtual void exec(CMem& mem, std::vector<std::string>& instr);
159 protected:
160 std::map<std::string, unsigned int> m_jumpaddr;
161};
162
163
164class CJumpz : public CFlagInstruction
165{
166 public:
167 CJumpz(std::map<std::string, unsigned int>& jumpaddr)
168 : m_jumpaddr(jumpaddr)
169 {}
170 virtual void exec(CMem& mem, std::vector<std::string>& instr, bool& f_zero);
171 protected:
172 std::map<std::string, unsigned int> m_jumpaddr;
173};
174
175
176class CJumps : public CFlagInstruction
177{
178 public:
179 CJumps(std::map<std::string, unsigned int>& jumpaddr)
180 : m_jumpaddr(jumpaddr)
181 {}
182 virtual void exec(CMem& mem, std::vector<std::string>& instr, bool& f_sign);
183 protected:
184 std::map<std::string, unsigned int> m_jumpaddr;
185};
186
187
188
189class CWrite : public CInstruction
190{
191 public:
192 virtual void exec(CMem& mem, std::vector<std::string>& instr);
193};
194
195#endif
196/* vim: set et sw=2 ts=2: */