summaryrefslogtreecommitdiffstats
path: root/ue3/mycpu/ccpu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ue3/mycpu/ccpu.cpp')
-rw-r--r--ue3/mycpu/ccpu.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/ue3/mycpu/ccpu.cpp b/ue3/mycpu/ccpu.cpp
index 6f364f8..b1539a4 100644
--- a/ue3/mycpu/ccpu.cpp
+++ b/ue3/mycpu/ccpu.cpp
@@ -10,23 +10,35 @@
10# include <iomanip> 10# include <iomanip>
11#endif 11#endif
12#include "ccpu.h" 12#include "ccpu.h"
13#include "displays.h"
13 14
14using namespace std; 15using namespace std;
15 16
16CCPU::CCPU(const unsigned cnt) 17CCPU::CCPU(const unsigned cnt)
17 : m_regcnt(cnt), m_memory(NULL), m_program(NULL), m_flagzero(0), m_flagsign(0) 18 : m_regcnt(cnt), m_memory(NULL), m_program(NULL), m_flagzero(false), m_flagsign(false)
18{ 19{
20 /* create registers */
19 m_registers = new CDat[cnt]; 21 m_registers = new CDat[cnt];
20 for(unsigned i = 0; i < cnt; ++i) 22 for(unsigned i = 0; i < cnt; ++i)
21 m_registers[i] = 0; 23 m_registers[i] = 0;
24
25 /* create displays */
26 m_displays.insert(new CDisplayWDEZ);
27 m_displays.insert(new CDisplayWHEX);
22} 28}
23 29
24/*----------------------------------------------------------------------------*/ 30/*----------------------------------------------------------------------------*/
25 31
26CCPU::~CCPU() 32CCPU::~CCPU()
27{ 33{
34 /* delete registers */
28 delete[] m_registers; 35 delete[] m_registers;
29 m_registers = NULL; 36 m_registers = NULL;
37
38 /* delete displays */
39 std::set<CDisplay *>::iterator it;
40 for (it = m_displays.begin() ; it != m_displays.end(); ++it)
41 delete *it;
30} 42}
31 43
32/*----------------------------------------------------------------------------*/ 44/*----------------------------------------------------------------------------*/
@@ -47,7 +59,7 @@ void CCPU::run()
47 59
48 /* end of the program reached */ 60 /* end of the program reached */
49 if (pc == m_program->size()) 61 if (pc == m_program->size())
50 return; 62 break;
51 63
52 /* pc is out of bound */ 64 /* pc is out of bound */
53 if (pc > m_program->size()) 65 if (pc > m_program->size())
@@ -57,8 +69,6 @@ void CCPU::run()
57 m_program->at(pc)->execute(this); 69 m_program->at(pc)->execute(this);
58 ++m_registers[0]; 70 ++m_registers[0];
59 } 71 }
60
61 cout << "LALA" << endl;
62} 72}
63 73
64/*----------------------------------------------------------------------------*/ 74/*----------------------------------------------------------------------------*/