-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
96 lines (67 loc) · 4.12 KB
/
main.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
89
90
91
92
93
94
95
96
/*
██████╗ ██╗ █████╗ ████████╗███████╗ ██████╗ ██████╗ ███╗ ███╗ ███████╗██╗███╗ ███╗██╗ ██╗██╗ █████╗ ████████╗ ██████╗ ██████╗
██╔══██╗██║ ██╔══██╗╚══██╔══╝██╔════╝██╔═══██╗██╔══██╗████╗ ████║ ██╔════╝██║████╗ ████║██║ ██║██║ ██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗
██████╔╝██║ ███████║ ██║ █████╗ ██║ ██║██████╔╝██╔████╔██║ ███████╗██║██╔████╔██║██║ ██║██║ ███████║ ██║ ██║ ██║██████╔╝
██╔═══╝ ██║ ██╔══██║ ██║ ██╔══╝ ██║ ██║██╔══██╗██║╚██╔╝██║ ╚════██║██║██║╚██╔╝██║██║ ██║██║ ██╔══██║ ██║ ██║ ██║██╔══██╗
██║ ███████╗██║ ██║ ██║ ██║ ╚██████╔╝██║ ██║██║ ╚═╝ ██║ ███████║██║██║ ╚═╝ ██║╚██████╔╝███████╗██║ ██║ ██║ ╚██████╔╝██║ ██║
╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
*/
#include <iostream>
#include <string>
#include <fstream>
#include <cstddef>
#include <exception>
#include "./include/hardware.hpp"
#include "./include/mem.hpp"
#include "./include/bus.hpp"
#include "./include/cpu.hpp"
#include "./include/display.hpp"
#include "./include/platform.hpp"
using namespace std;
string getFileContents (ifstream& File)
{
string Lines = ""; //All lines
if (File) //Check if everything is good
{
while (File.good ())
{
string TempLine; //Temp line
getline (File , TempLine); //Get temp line
TempLine += "\n"; //Add newline character
Lines += TempLine; //Add newline
}
return Lines;
}
else //Return error
return "ERROR File does not exist.";
}
int main(int argc, char* argv[]){
/* ---------Logo---------*/
ifstream Reader ("Logo.txt"); //Open file
string Art = getFileContents (Reader); //Get file
cout << Art << endl; //Print it to the screen
Reader.close (); //Close file
/*--------END Logo-------*/
Platform platform;
if( argc<3 ){
cout << "ERROR : too few arguments" << endl;
return EXIT_FAILURE;
}
if( platform.load( argv[1] ) == EXIT_FAILURE) {
cout << "ERROR : no file or wrong file specified" << endl;
return EXIT_FAILURE;
}
platform.bind();
if( platform.simulate( stoi(argv[2]) ) == EXIT_FAILURE){
cout << "ERROR : no simulating cycle specified" << endl;
return EXIT_FAILURE;
}
/* ---------Logo---------*/
Reader.open("end.txt"); //Open file
Art = getFileContents (Reader); //Get file
cout << Art << endl; //Print it to the screen
Reader.close (); //Close file
/*--------END Logo-------*/
cout << "//////////////////////THE END/////////////////////////" << endl;
return EXIT_SUCCESS;
}