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.h133
1 files changed, 118 insertions, 15 deletions
diff --git a/ue3/mycpu/cinstruction.h b/ue3/mycpu/cinstruction.h
index b16c067..57fcff1 100644
--- a/ue3/mycpu/cinstruction.h
+++ b/ue3/mycpu/cinstruction.h
@@ -10,9 +10,8 @@
10 10
11#include <iostream> 11#include <iostream>
12#include <list> 12#include <list>
13//#include "ccpu.h"
14 13
15/* declare CCPU */ 14/* forward declare CCPU */
16class CCPU; 15class CCPU;
17 16
18/** 17/**
@@ -26,7 +25,7 @@ class CInstruction
26 /** 25 /**
27 * @method CInstruction 26 * @method CInstruction
28 * @brief Default ctor 27 * @brief Default ctor
29 * @param - 28 * @param name name of instruction
30 * @return - 29 * @return -
31 * @globalvars none 30 * @globalvars none
32 * @exception none 31 * @exception none
@@ -34,7 +33,7 @@ class CInstruction
34 */ 33 */
35 CInstruction(std::string name) 34 CInstruction(std::string name)
36 : m_name(name) 35 : m_name(name)
37 {}; 36 {}
38 37
39 /** 38 /**
40 * @method ~CInstruction 39 * @method ~CInstruction
@@ -46,46 +45,150 @@ class CInstruction
46 * @conditions none 45 * @conditions none
47 */ 46 */
48 virtual ~CInstruction() 47 virtual ~CInstruction()
49 {}; 48 {}
50 49
51 /* TODO */ 50 /**
51 * @method operator==
52 * @brief implementation of operator ==
53 * @param reference to std::string
54 * @return true if instructionname is name
55 * @globalvars none
56 * @exception none
57 * @conditions none
58 */
52 virtual bool operator==(std::string& name) 59 virtual bool operator==(std::string& name)
53 { 60 {
54 return name == m_name; 61 return name == m_name;
55 } 62 }
56 63
57 /* TODO */ 64 /**
65 * @method getName
66 * @brief returns instruction name
67 * @param -
68 * @return name of instruction
69 * @globalvars none
70 * @exception none
71 * @conditions none
72 */
58 virtual const std::string& getName() 73 virtual const std::string& getName()
59 { 74 {
60 return m_name; 75 return m_name;
61 } 76 }
62 77
63 /* TODO */ 78 /**
79 * @method isLabel
80 * @brief returns true if the instruction defines a label
81 * @param -
82 * @return true if the instruction defines a label
83 * @globalvars none
84 * @exception none
85 * @conditions none
86 */
87 virtual const bool isLabel()
88 {
89 return false;
90 }
91
92 /**
93 * @method getLabelName
94 * @brief returns labelname if the instruction defines a label
95 * @param -
96 * @return labelname if the instruction defines a label
97 * @globalvars none
98 * @exception none
99 * @conditions none
100 */
101 virtual const std::string getLabelName()
102 {
103 return "";
104 }
105
106 /**
107 * @method dump
108 * @brief dumps information about instruction to outputstream
109 * @param stream outputstream
110 * @return reference to outputstream
111 * @globalvars none
112 * @exception none
113 * @conditions none
114 */
64 virtual std::ostream& dump(std::ostream& stream) 115 virtual std::ostream& dump(std::ostream& stream)
65 { 116 {
66 stream << m_name; 117 stream << m_name;
67 return stream; 118 return stream;
68 } 119 }
69 120
70 /* TODO */ 121 /**
122 * @method operator<<
123 * @brief Shift/output operator for outputstream
124 * @param stream reference to outputstream
125 * @param cdat object which will be printed to stream
126 * @return reference to outputstream
127 * @globalvars none
128 * @exception none
129 * @conditions none
130 */
71 friend std::ostream& operator<<(std::ostream& stream, CInstruction& instr) 131 friend std::ostream& operator<<(std::ostream& stream, CInstruction& instr)
72 { 132 {
73 return instr.dump(stream); 133 return instr.dump(stream);
74 } 134 }
75 135
76 /* TODO */ 136 /**
137 * @method parseRegister
138 * @brief parses register syntax Rx (e.g. "R1")
139 * @param str register in assembler syntax
140 * @return registernumber
141 * @globalvars none
142 * @exception runtime_error
143 * @conditions none
144 */
77 virtual const unsigned parseRegister(const std::string& str); 145 virtual const unsigned parseRegister(const std::string& str);
78 146
79 /* TODO */ 147 /**
80 virtual void checkRegister(CCPU *cpu, unsigned regidx); 148 * @method checkRegister
149 * @brief performs a register boundary check
150 * does the register exist in cpu?
151 * @param cpu pointer to cpu
152 * @param regidx registernumber
153 * @return -
154 * @globalvars none
155 * @exception runtime_error
156 * @conditions none
157 */
158 virtual void checkRegister(CCPU *cpu, const unsigned regidx);
81 159
82 /* TODO */ 160 /**
161 * @method factory
162 * @brief creates a new instance of this instruction
163 * @param -
164 * @return new instruction instance
165 * @globalvars none
166 * @exception none
167 * @conditions none
168 */
83 virtual CInstruction *factory() = 0; 169 virtual CInstruction *factory() = 0;
84 170
85 /* TODO */ 171 /**
172 * @method compile
173 * @brief parses instruction parameters and prepares the
174 * instruction for executing
175 * @param params list of parameters of this instruction
176 * @return -
177 * @globalvars none
178 * @exception runtime_error
179 * @conditions none
180 */
86 virtual void compile(std::list<std::string>& params) = 0; 181 virtual void compile(std::list<std::string>& params) = 0;
87 182
88 /* TODO */ 183 /**
184 * @method execute
185 * @brief executes the instruction
186 * @param cpu pointer to cpu
187 * @return -
188 * @globalvars none
189 * @exception runtime_error
190 * @conditions none
191 */
89 virtual void execute(CCPU *cpu) = 0; 192 virtual void execute(CCPU *cpu) = 0;
90 193
91 protected: 194 protected: