-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathasm_main.cpp
executable file
·45 lines (33 loc) · 987 Bytes
/
asm_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
#include <iostream>
#include "Assembler.hpp"
using namespace std;
int main(int argc, const char* argv[])
{
if (argc != 2)
{
cout << "Pass a file to assemble" << endl;
return 2;
}
Assembler ass(argv[1]);
const vector<char>& bin = ass.Bin();
ofstream fout("out.bin");
for (vector<char>::const_iterator it = bin.begin(); it != bin.end(); ++it)
{
fout << *it;
}
fout.close();
ofstream dbg("out.dbg");
const map<int, map<string, int> >::const_iterator end = ass.debugInfo().end();
map<int, map<string, int> >::const_iterator it = ass.debugInfo().begin();
for (; it != end; ++it)
{
const map<string, int>::const_iterator end2 = it->second.end();
map<string, int>::const_iterator it2 = it->second.begin();
for (; it2 != end2; ++it2)
{
dbg << it->first << ' ' << it2->first << ' ' << it2->second << '\n';
}
}
dbg.close();
return 0;
}