aboutsummaryrefslogtreecommitdiff
path: root/qtmips_cli/main.cpp
blob: 4c4652b8ddfab6978ced001fb626ca1031c12717 (plain)
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
#include <QCoreApplication>
#include <QCommandLineParser>
#include <iostream>
#include "tracer.h"

using namespace machine;

void create_parser(QCommandLineParser &p) {
    p.setApplicationDescription("QtMips CLI machine simulator");
    p.addHelpOption();
    p.addVersionOption();

    p.addPositionalArgument("FILE", "Input ELF executable file");
}

void configure_machine(QCommandLineParser &p, MachineConfig &cc) {
    QStringList pa = p.positionalArguments();
    if (pa.size() != 1) {
        std::cerr << "Single ELF file has to be specified" << std::endl;
        exit(1);
    }
    cc.set_elf(pa[0]);

    // TODO
}

void configure_tracer(QCommandLineParser &p, Tracer &tr) {
    // TODO
    tr.reg_pc();
}

int main(int argc, char *argv[]) {
    QCoreApplication app(argc, argv);
    app.setApplicationName("qtmips_cli");
    app.setApplicationVersion("0.1");

    QCommandLineParser p;
    create_parser(p);
    p.process(app);

    MachineConfig cc;
    configure_machine(p, cc);
    QtMipsMachine machine(cc);

    app.connect(&machine, SIGNAL(program_exit()), &app, SLOT(quit()));

    Tracer tr(&machine);
    configure_tracer(p, tr);

    machine.play(); // Run machine
    return app.exec();
}