-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctsim.cpp
94 lines (78 loc) · 1.73 KB
/
ctsim.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <iostream>
#include "getopt.h"
#include "step68k.h"
/* Globals */
struct {
int opt_verb;
string opt_ctxfile;
string opt_insfile;
} OPTS;
void enable_verbose();
void usage();
void vout(string s);
int main(int argc, char** argv)
{
static struct option loptions[] = {
{ "verbose", no_argument, 0, 'v'},
{ "serial", no_argument, 0, 's' },
{ NULL, 0, 0, 0 }
};
bool done = false;
while (!done) {
int opt_idx;
int c = getopt_long(argc, argv, "vsc:", loptions, &opt_idx);
switch (c) {
case 0:
/* long option */
cout << "long option" << endl;
break;
case -1:
done = true;
break;
case 'c':
OPTS.opt_ctxfile = (string) optarg;
vout("Context file: " + OPTS.opt_ctxfile + "\n");
break;
case 'v':
enable_verbose();
break;
default:
usage();
return -1;
}
}
if (optind >= argc) {
usage();
return -1;
}
OPTS.opt_insfile = argv[optind];
vout("Instruction file: " + OPTS.opt_insfile + "\n");
Step68k step68k;
step68k.setObjectFile(OPTS.opt_insfile);
step68k.runSim();
return 0;
}
void enable_verbose() {
OPTS.opt_verb = 1;
vout("Verbose output enabled.\n");
}
void vout(string s) {
if (!OPTS.opt_verb) {
return;
}
cout << "verbose: " << s;
}
void usage() {
cout << "Usage: ctsim [options] -c <context file> <instruction file>" << endl
<< "OPTIONS:" << endl
<< "\t" << "--verbose|-v"
<< "\t\t" << "Enable verbose output" << endl
<< "\t" << "--serial|-s"
<< "\t\t" << "Disable pipeline analysis" << endl
<< "\t" << "-c <context>"
<< "\t\t" << "Memory context file" << endl;
}
// Local Variables:
// c-basic-offset: 8
// fill-column: 80
// End: