From ddf63e2765a6b225d18c59321595e69e1a126e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Neuwirth?= Date: Tue, 12 May 2009 23:00:03 +0200 Subject: adding tha rest --- ue3/mycpu/cmem.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 6 deletions(-) (limited to 'ue3/mycpu/cmem.cpp') diff --git a/ue3/mycpu/cmem.cpp b/ue3/mycpu/cmem.cpp index ec60b56..165747b 100644 --- a/ue3/mycpu/cmem.cpp +++ b/ue3/mycpu/cmem.cpp @@ -37,13 +37,9 @@ CMem::~CMem() CDat& CMem::getRegister(const string reg) { - istringstream stmp ( - reg.substr(reg.find_first_of("R") + 1, reg.size()) - ); - unsigned int regnr; - stmp >> regnr; - + unsigned int regnr = getRegNr(reg); + // if (regnr >= MAX_REGISTER ) if (regnr >= m_registers.size()) @@ -55,6 +51,68 @@ CDat& CMem::getRegister(const string reg) return m_registers[regnr]; } + +/*----------------------------------------------------------------------------*/ + +string CMem::getMemAt(const std::string addr) +{ + int pos = getRegister(addr).getTypeValue(); + /* open and read mem */ + ifstream file(m_memfile.c_str(), ios::in); + string cur_line; + for (int i = 0; i <= pos; i++) + getline(file, cur_line); + + file.close(); + if (cur_line.empty()) + return ""; + trim(cur_line); + return cur_line; +} +void CMem::setMemAt(const std::string addr, const CDat& value) +{ + unsigned int pos = getRegister(addr).getTypeValue(); + /* open and read mem */ + ifstream ifile(m_memfile.c_str() ); + vector tmp; + unsigned int i = 0; + while (ifile.good()) + { + string cur_line; + getline(ifile, cur_line); + if(!cur_line.empty()) + tmp.push_back(cur_line); + i++; + } + ifile.close(); + cout << tmp.size()<<"sasa"<> regnr; + return regnr; +} + /*----------------------------------------------------------------------------*/ #ifdef DEBUG -- cgit v1.2.3