-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (34 loc) · 877 Bytes
/
Copy pathmain.cpp
File metadata and controls
43 lines (34 loc) · 877 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
34
35
36
37
38
39
40
41
42
#include <fstream>
#include <iomanip>
#include "registers.h"
#include "decoder.h"
#include "instruction.h"
#include "labels.h"
#include "memory.h"
#include "data.h"
using namespace std;
int main(int argc, char* argv[])
{
Decoder decoder;
Registers registers;
Labels labels;
Memory memory;
Data *data = new Data(1000);
*data = 0;
memory.insert(data);
memory[992] = 0;
ifstream inf(argv[1]);
inf >> memory;
inf.clear();
inf.seekg(0);
inf >> labels;
registers.set(Registers::eip, labels.find("main"));
while(registers.get(Registers::eip) != 0)
{
const Instruction& instruction = memory.fetch(®isters);
decoder.parse(instruction, ®isters, memory, labels);
decoder.execute(instruction, ®isters, memory);
cout << left << setw(20) << instruction << registers;
} // while eip not zero
return 0;
} // main()