-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBridge.cpp
88 lines (70 loc) · 1.78 KB
/
Bridge.cpp
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
86
87
88
#include "Bridge.h"
#include "Utility.h"
#include <QObject>
#include <QThread>
#include "Console.h"
#include "ThreadManager.h"
//#include "Simulator.h"
#include "computer.h"
bool Bridge::isRunning = false;
bool Bridge::isHalting = false;
Bridge::Bridge(ThreadManager::RunUntil protocol) : QObject(nullptr)
{
runningMode = protocol;
}
Bridge::~Bridge()
{
Bridge::isRunning =false;
}
void Bridge::doWork()
{
// emit simPrep();
// QThread::sleep(4);
}
void Bridge::process()
{
if(Bridge::isRunning)
{
qDebug("Already running");
return;
}
Bridge::isRunning = true;
// int ok =0;
switch(runningMode)
{
case ThreadManager::RunUntil::Next:
{
val_t target_PC = Computer::getDefault()->getRegister(PC)+1;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// I added a function called executeUntilAddress() that does this.
// Logic like this belongs into the computer
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// TODO update
qDebug("Am I done? Starting at"+ QString().setNum(target_PC).toLocal8Bit());
Computer::getDefault()->executeUntilAddress(target_PC);
Bridge::isHalting = false;
break;
}
case ThreadManager::RunUntil::Step:
{
qDebug("Steppin");
executeCommand(step,nullptr);
// qDebug(QString().setNum(&ok).toLocal8Bit());
break;
}
case ThreadManager::RunUntil::Flag:
{
qDebug("Until Break");
executeCommand(_continue,nullptr);
}
default:qDebug("Welp");
}
qDebug("Hiya");
qDebug("AGAIN");
emit finished();
isRunning=false;
}
void Bridge::beginHalt()
{
Bridge::isHalting = true;
}