forked from 21-cpu-group2/sim_binary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_pc_label.cpp
More file actions
56 lines (52 loc) · 1.18 KB
/
make_pc_label.cpp
File metadata and controls
56 lines (52 loc) · 1.18 KB
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
54
55
56
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
typedef struct {
string label;
unsigned long pc;
}label_pc;
int compare(const void* a, const void* b) {
if (((label_pc*)a)->pc > ((label_pc*)b)->pc) {
return 1;
}
else {
return -1;
}
}
int main(int argc, char** argv){
label_pc data[10000];
string file_path = argv[1];
ifstream ifs(file_path);
if (ifs.fail()){
return 1;
}
// cout << "floating-point imm table" << endl;
string str;
int ind = 0;
while (getline(ifs, str)){
istringstream iss(str);
string l, p;
iss >> l >> p;
if (l.at(0) == 'l'){
// cout << str << endl;
}
else {
data[ind].label = l;
data[ind].pc = stoul(p, nullptr, 10);
ind++;
}
}
// cout << endl;
// cout << "pc -> label" << endl;
qsort(data, ind, sizeof(label_pc), compare);
for (int i=0; i<ind; i++){
cout << data[i].pc << " " << data[i].label << endl;
}
// ¥é¥Ù¥ë¤ÎÆÉ¤ß¹þ¤ßÍÑ
cout << "-1 break" << endl;
return 0;
}