-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathassembler.cpp
More file actions
36 lines (34 loc) · 733 Bytes
/
Copy pathassembler.cpp
File metadata and controls
36 lines (34 loc) · 733 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
#include <fstream>
#include "VM.h"
#include "VM_binaries.h"
using namespace std;
using namespace VM_BINARIES;
int main(int argc, char const **argv) {
if(argc < 2){
cerr << "please enter a file name to assemble\n";
return 1;
}
string filename = "out.bin";
if(argc >= 3){
filename = argv[2];
}
#ifdef USE_GMP_LIB
mpf_set_default_prec(1024);
#endif
ofstream ofile;
ofile.open(filename);
ifstream fin;
fin.open(argv[1]);
vector<Value> prog;
string line;
while(getline(fin, line)){
for(Value val : VM::assemble(line)){
prog.push_back(val);
}
}
fin.close();
cout << "----------SAVING TO " + filename + "----------" << endl;
ofile << mkBin(prog);
ofile.close();
return 0;
}