blob: 3055c9cf33bb819b217403c43f763861cf98c028 (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>mycpu: mycpu/cinstruction.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>mycpu/cinstruction.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00008"></a>00008 <span class="preprocessor">#ifndef CINSTRUCTION_H</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define CINSTRUCTION_H 1</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span>
<a name="l00011"></a>00011 <span class="preprocessor">#include <iostream></span>
<a name="l00012"></a>00012 <span class="preprocessor">#include <list></span>
<a name="l00013"></a>00013
<a name="l00014"></a>00014 <span class="comment">/* forward declare CCPU */</span>
<a name="l00015"></a>00015 <span class="keyword">class </span><a class="code" href="classCCPU.html">CCPU</a>;
<a name="l00016"></a>00016
<a name="l00022"></a><a class="code" href="classCInstruction.html">00022</a> <span class="keyword">class </span><a class="code" href="classCInstruction.html">CInstruction</a>
<a name="l00023"></a>00023 {
<a name="l00024"></a>00024 <span class="keyword">public</span>:
<a name="l00034"></a><a class="code" href="classCInstruction.html#263195c9e1f109bf44f7040727dcfa78">00034</a> <a class="code" href="classCInstruction.html#263195c9e1f109bf44f7040727dcfa78" title="Default ctor.">CInstruction</a>(std::string name)
<a name="l00035"></a>00035 : <a class="code" href="classCInstruction.html#0c3b94ae1323d6201d2afd20c8686194">m_name</a>(name)
<a name="l00036"></a>00036 {}
<a name="l00037"></a>00037
<a name="l00047"></a><a class="code" href="classCInstruction.html#d2ded1d8675749bc39a085a8c50a6612">00047</a> <span class="keyword">virtual</span> <a class="code" href="classCInstruction.html#d2ded1d8675749bc39a085a8c50a6612" title="Default dtor.">~CInstruction</a>()
<a name="l00048"></a>00048 {}
<a name="l00049"></a>00049
<a name="l00059"></a><a class="code" href="classCInstruction.html#395c9bde315efbc0eefd0bbb1586950a">00059</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classCInstruction.html#395c9bde315efbc0eefd0bbb1586950a" title="implementation of operator ==">operator==</a>(std::string& name)
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061 <span class="keywordflow">return</span> name == <a class="code" href="classCInstruction.html#0c3b94ae1323d6201d2afd20c8686194">m_name</a>;
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063
<a name="l00073"></a><a class="code" href="classCInstruction.html#b5b2364b0cccc6db2f5c3aaccee8aa43">00073</a> <span class="keyword">virtual</span> <a class="code" href="classCInstruction.html">CInstruction</a>& <a class="code" href="classCInstruction.html#b5b2364b0cccc6db2f5c3aaccee8aa43" title="implementation of operator (CCPU)">operator()</a>(<a class="code" href="classCCPU.html">CCPU</a> *cpu)
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075 <a class="code" href="classCInstruction.html#127fd09a772e9f584550cd342af770d1" title="executes the instruction">execute</a>(cpu);
<a name="l00076"></a>00076 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00077"></a>00077 }
<a name="l00078"></a>00078
<a name="l00088"></a><a class="code" href="classCInstruction.html#e8187580097fd2ced5a8bc6e6e09fe44">00088</a> <span class="keyword">virtual</span> <span class="keyword">const</span> std::string& <a class="code" href="classCInstruction.html#e8187580097fd2ced5a8bc6e6e09fe44" title="returns instruction name">getName</a>()
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090 <span class="keywordflow">return</span> <a class="code" href="classCInstruction.html#0c3b94ae1323d6201d2afd20c8686194">m_name</a>;
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092
<a name="l00102"></a><a class="code" href="classCInstruction.html#040a2394e2161a65f37ef31d16bb6a35">00102</a> <span class="keyword">virtual</span> std::ostream& <a class="code" href="classCInstruction.html#040a2394e2161a65f37ef31d16bb6a35" title="dumps information about instruction to outputstream">dump</a>(std::ostream& stream)
<a name="l00103"></a>00103 {
<a name="l00104"></a>00104 stream << <a class="code" href="classCInstruction.html#0c3b94ae1323d6201d2afd20c8686194">m_name</a>;
<a name="l00105"></a>00105 <span class="keywordflow">return</span> stream;
<a name="l00106"></a>00106 }
<a name="l00107"></a>00107
<a name="l00118"></a><a class="code" href="classCInstruction.html#7651b4c147411bca34a0393adf03507d">00118</a> <span class="keyword">friend</span> std::ostream& <a class="code" href="classCInstruction.html#7651b4c147411bca34a0393adf03507d" title="Shift/output operator for outputstream.">operator<<</a>(std::ostream& stream, <a class="code" href="classCInstruction.html">CInstruction</a>& instr)
<a name="l00119"></a>00119 {
<a name="l00120"></a>00120 <span class="keywordflow">return</span> instr.<a class="code" href="classCInstruction.html#040a2394e2161a65f37ef31d16bb6a35" title="dumps information about instruction to outputstream">dump</a>(stream);
<a name="l00121"></a>00121 }
<a name="l00122"></a>00122
<a name="l00132"></a>00132 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <a class="code" href="classCInstruction.html#2723f8875ff0cc4e48d840db1ae5b4a8" title="parses register syntax Rx (e.g. &quot;R1&quot;)">parseRegister</a>(<span class="keyword">const</span> std::string& str);
<a name="l00133"></a>00133
<a name="l00145"></a>00145 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCInstruction.html#8e938360a34f1cd3bf799f21e2ce6f6c" title="performs a register boundary check does the register exist in cpu?">checkRegister</a>(<a class="code" href="classCCPU.html">CCPU</a> *cpu, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> regidx);
<a name="l00146"></a>00146
<a name="l00156"></a>00156 <span class="keyword">virtual</span> <a class="code" href="classCInstruction.html">CInstruction</a> *<a class="code" href="classCInstruction.html#fae8dc231b375db91f874df0d085b7dc" title="creates a new instance of this instruction">factory</a>() = 0;
<a name="l00157"></a>00157
<a name="l00168"></a>00168 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCInstruction.html#15e2ce88b04fcf208ba43c43f7dd57aa" title="parses instruction parameters and prepares the instruction for executing">compile</a>(std::list<std::string>& params) = 0;
<a name="l00169"></a>00169
<a name="l00179"></a>00179 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCInstruction.html#127fd09a772e9f584550cd342af770d1" title="executes the instruction">execute</a>(<a class="code" href="classCCPU.html">CCPU</a> *cpu) = 0;
<a name="l00180"></a>00180
<a name="l00181"></a>00181 <span class="keyword">protected</span>:
<a name="l00182"></a>00182 <span class="comment">/* members */</span>
<a name="l00184"></a><a class="code" href="classCInstruction.html#0c3b94ae1323d6201d2afd20c8686194">00184</a> std::string <a class="code" href="classCInstruction.html#0c3b94ae1323d6201d2afd20c8686194">m_name</a>;
<a name="l00185"></a>00185 };
<a name="l00186"></a>00186
<a name="l00187"></a>00187 <span class="preprocessor">#endif</span>
<a name="l00188"></a>00188 <span class="preprocessor"></span>
<a name="l00189"></a>00189 <span class="comment">/* vim: set et sw=2 ts=2: */</span>
</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 14 18:19:16 2009 for mycpu by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>
|