-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
33 lines (28 loc) · 791 Bytes
/
main.cpp
File metadata and controls
33 lines (28 loc) · 791 Bytes
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
#include "computer.hpp"
#include <fstream>
#include <string>
int main(int argc, char **argv) {
std::string filename;
if (argc < 2) {
printf("Usage: %s code.bit", argv[0]);
return 1;
} else {
filename = argv[1];
}
std::fstream code;
code.open(filename);
if (!code.is_open()) {
printf("Could not open code file %s.", filename.c_str());
return 1;
}
std::vector<MEMORY::Register> ROMMem;
std::string line;
while(std::getline(code, line)){ //read data from file object and put it into string.
ROMMem.push_back(atoi(line.c_str()));
}
code.close();
MEMORY::ROM ROM(ROMMem);
COMPUTER::Computer computer(ROM);
computer.run();
printf("A Register: %i", computer.getLastA());
}