From 34483e07a0548d32651cda4ca4282f3cf8cae870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Neuwirth?= Date: Tue, 12 May 2009 15:27:58 +0200 Subject: adding rest of files --- ue3/mycpu/ccpu.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 ue3/mycpu/ccpu.cpp (limited to 'ue3/mycpu/ccpu.cpp') diff --git a/ue3/mycpu/ccpu.cpp b/ue3/mycpu/ccpu.cpp new file mode 100644 index 0000000..72ad96c --- /dev/null +++ b/ue3/mycpu/ccpu.cpp @@ -0,0 +1,97 @@ +/** + * @module ccpu + * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) + * @brief class for processing a program + * @date 11.05.2009 + */ + +#include +#include +#include + +#include "ccpu.h" +#include "cinstruction.h" +#include "cprogram.h" +#include "cmem.h" + + +using namespace std; +using namespace boost; + +CCPU::CCPU(const std::string& progfile, const std::string& memfile) + : m_program(progfile), m_memory(memfile) +{ + m_instrtype["inc"] = new CInc(); + m_instrtype["dec"] = new CDec(); + m_instrtype["add"] = new CAdd(); + m_instrtype["sub"] = new CSub(); + m_instrtype["mul"] = new CMul(); + m_instrtype["div"] = new CDiv(); + m_instrtype["load"] = new CLoad(); + m_instrtype["store"] = new CStore(); + m_instrtype["test"] = new CTest(); + m_instrtype["label"] = new CLabel(); + m_instrtype["jumpa"] = new CJumpa(m_program.getJumpAddrs()); + m_instrtype["jumpz"] = new CJumpz(m_program.getJumpAddrs()); + m_instrtype["jumps"] = new CJumps(m_program.getJumpAddrs()); + m_instrtype["write"] = new CWrite(); +} + + +void CCPU::proceed() +{ + + while (m_memory.getRegister("R0") < m_program.getMaxProgramCount()) + { + std::vector& i_list = m_program.getInstruction( + m_memory.getRegister("R0") + ); + + /* switch (m_instrtype[i_list[0]]) + { + case INC: + cout << "fick mich"<< endl<& i_list) +{ + + +} + -- cgit v1.2.3