-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_ins_ids.cpp
53 lines (41 loc) · 1 KB
/
gen_ins_ids.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
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
#include "ins_map.h"
int main() {
const std::string ARG_TYPES[] =
{
"STR",
"NUM",
"DAT",
"REG",
"VAR",
"LBL",
"NUM_F",
"CHR",
"MEM",
};
//const size_t ARG_LSIZE = 9;
const size_t ARG_LSIZE = sizeof(ARG_TYPES) / sizeof(ARG_TYPES[0]);
const size_t INSTRUCTION_SIZE = sizeof(INSTRUCTION_IDS) / sizeof(INSTRUCTION_IDS[0]);
std::stringstream strm;
strm << "#ifndef DK9H_INS\n";
strm << "#define DK9H_INS\n";
size_t i = 0;
for (; i < INSTRUCTION_SIZE; i++) {
strm << "#define i_" << INSTRUCTION_IDS[i] << " " << i << "\n";
}
for (size_t j = 0; j < ARG_LSIZE; j++) {
strm << "#define v_" << ARG_TYPES[j] << " " << (10 * i + j) << "\n";
}
strm << "#endif";
std::ofstream file("instruction_ids.h");
if (!file) {
std::cerr << "FILE FAILED TO OPEN\n";
exit(1);
}
file << strm.str();
file.close();
return 0;
}