-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinary.cpp
More file actions
39 lines (30 loc) · 936 Bytes
/
Binary.cpp
File metadata and controls
39 lines (30 loc) · 936 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
37
38
39
//Name: Maxine Xin
#include "BinaryParser.h"
#include <iostream>
#include <iomanip>
using namespace std;
/* This file reads in a file containing lines of binary encodings at the
* command line. If the file has correct syntax and each encoding is valid,
* the encodings will be translated into string of MIPS instructions and
* printed out to stdout, one per line.
*
*/
int main(int argc, char *argv[]) {
BinaryParser *bParser;
if (argc < 2) {
cerr << "Need to specify a binary encoding file to translate." << endl;
exit(1);
}
bParser = new BinaryParser(argv[1]);
if (bParser -> isFormatCorrect() == false) {
cerr << "Format of input file is incorrect." << endl;
exit(1);
}
Instruction i;
i = bParser -> getNextInstruction();
while (i.getOpcode() != UNDEFINED) {
cout << i.getEncoding() << "\t" << i.getASM() << endl;
i = bParser -> getNextInstruction();
}
delete bParser;
}