-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
89 lines (74 loc) · 2.9 KB
/
main.cpp
File metadata and controls
89 lines (74 loc) · 2.9 KB
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
89
#include <QApplication>
#include <QString>
#include <iostream>
#include <string>
#include "sim/system.h"
#include "gui/mainwindow.h"
#include "gui/systemthread.h"
#include "sim/syscalls.h"
#include "emu/emuprocess.h"
#include "sim/process.h"
#include "sim/filesystem.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
gui::MainWindow mainWindow;
//sim::Process *p = new sim::DummyProcess(200);
std::function<void(const char *s)> log = [&] (const char *s) -> void {
mainWindow.log(QString::fromStdString(s));
};
sim::System *mainSystem = new sim::System(65536, 200, std::cin, std::cout, "data", log);
gui::SystemThread *mainThread = new gui::SystemThread(mainSystem, 10000);
//mainThread->add(p, "dummy");
mainWindow.mainThread = mainThread;
mainWindow.show();
// Temporary until we have File IO added
char *memory = new char[0x10000];
// Fibonaci Calcutator, calculates n = 20 and stores it in register A
// https://gist.github.com/ehaliewicz/2523345
unsigned char program[] =
{
0x00, 0x7d, 0x05, 0x00, 0xe1, 0x00, 0xc1, 0x84,
0xc2, 0x88, 0xd4, 0x1c, 0x81, 0x7f, 0x20, 0x00,
0x01, 0x84, 0x21, 0x88, 0x41, 0x18, 0x52, 0x84,
0x81, 0x7f, 0x15, 0x00, 0x61, 0x00, 0x62, 0x04,
0x01, 0x04, 0x21, 0x0c, 0x43, 0x88, 0x81, 0x7f,
0x0b, 0x00, 0x00, 0x7d, 0x04, 0x00, 0xc1, 0xaf,
0x00, 0x10, 0x01, 0x7c, 0x00, 0x10, 0x21, 0x88,
0x00, 0x7d, 0x02, 0x00, 0x81, 0x7f, 0x04, 0x00,
0x00, 0x7d, 0x01, 0x00
};
//bool foo = mainSystem->fs.writeFile("fib",0,sizeof program,(char*) program);
//std::cout << (foo?"yay":"nay") << std::endl;
// Hello World, prints "Hello, world!" to the screen
/*unsigned char program[] =
{
0xc1, 0x7f, 0x48, 0x00, 0x00, 0x10, 0xc1, 0x7f,
0x65, 0x00, 0x01, 0x10, 0xc1, 0x7f, 0x6c, 0x00,
0x02, 0x10, 0xc1, 0x7f, 0x6c, 0x00, 0x03, 0x10,
0xc1, 0x7f, 0x6f, 0x00, 0x04, 0x10, 0xc1, 0x7f,
0x2c, 0x00, 0x05, 0x10, 0xc1, 0x7f, 0x20, 0x00,
0x06, 0x10, 0xc1, 0x7f, 0x77, 0x00, 0x07, 0x10,
0xc1, 0x7f, 0x6f, 0x00, 0x08, 0x10, 0xc1, 0x7f,
0x72, 0x00, 0x09, 0x10, 0xc1, 0x7f, 0x6c, 0x00,
0x0a, 0x10, 0xc1, 0x7f, 0x64, 0x00, 0x0b, 0x10,
0xc1, 0x7f, 0x21, 0x00, 0x0c, 0x10, 0xc1, 0xaf,
0x0d, 0x10, 0x01, 0x7c, 0x00, 0x10, 0x21, 0xbc,
0x00, 0x7d, 0x02, 0x00, 0x81, 0x7f, 0x2e, 0x00
};*/
// Copy program into processes memory
memcpy(memory, program, sizeof(program));
// Create process and schedule it
emu::EmuProcess *emu = new emu::EmuProcess((char*) memory, 0x2000);
//mainThread->add(emu, "emu");
// ---
/*sim::FileSystem fs("foo");
fs.writeFile("bar.txt", 3, 4, (char*) "1234");
//std::cout.write(str, 4);
//delete[] str;
std::cout << std::endl;*/
int ret = a.exec();
delete mainThread;
delete mainSystem;
return ret;
}