summaryrefslogtreecommitdiffstats
path: root/ue3/mycpu/cmem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ue3/mycpu/cmem.cpp')
-rw-r--r--ue3/mycpu/cmem.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/ue3/mycpu/cmem.cpp b/ue3/mycpu/cmem.cpp
new file mode 100644
index 0000000..d27f74e
--- /dev/null
+++ b/ue3/mycpu/cmem.cpp
@@ -0,0 +1,65 @@
1/**
2 * @module cprogram
3 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
4 * @brief class for parsing and saving a program
5 * @date 11.05.2009
6 */
7
8#include <fstream>
9#include <sstream>
10#include <string>
11#include <boost/tokenizer.hpp>
12#include <boost/algorithm/string.hpp>
13#include "cdat.h"
14#include "cmem.h"
15
16
17
18using namespace std;
19using namespace boost;
20
21CMem::CMem(const std::string& memfile) :
22 m_memfile(memfile)
23{
24
25 dump(std::cout);
26
27}
28
29/*----------------------------------------------------------------------------*/
30
31CMem::~CMem()
32{
33
34}
35
36/*----------------------------------------------------------------------------*/
37
38CDat& CMem::getRegister(const string reg)
39{
40 istringstream stmp (
41 reg.substr(reg.find_first_of("R") + 1, reg.size())
42 );
43
44 unsigned int regnr;
45 stmp >> regnr;
46
47 // if (regnr >= MAX_REGISTER )
48
49 if (regnr == m_registers.size())
50 {
51 m_registers.push_back(CDat((int)0));
52 return m_registers[m_registers.size() - 1];
53 }
54
55 return m_registers[regnr];
56}
57/*----------------------------------------------------------------------------*/
58
59#ifdef DEBUG
60void CMem::dump(std::ostream& out)
61{
62 out << endl << "Memory file:" << endl << m_memfile << endl;
63 out << endl << "Memory file content:" << endl;
64}
65#endif