-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASM.cpp
More file actions
39 lines (30 loc) · 879 Bytes
/
ASM.cpp
File metadata and controls
39 lines (30 loc) · 879 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
#include "ASMParser.h"
#include <iostream>
using namespace std;
/* This file reads in a MIPS assembly file specified at the command line.
* If the file is correct syntactically, each instruction in the file
* will be translated into its 32 bit MIPS binary encoding and printed
* to stdout, one per line.
*
*/
int main(int argc, char *argv[])
{
ASMParser *parser;
if(argc < 2){
cerr << "Need to specify an assembly file to translate."<<endl;
exit(1);
}
parser = new ASMParser(argv[1]);
if(parser->isFormatCorrect() == false){
cerr << "Format of input file is incorrect " << endl;
exit(1);
}
Instruction i;
//Iterate through instructions, printing each encoding.
i = parser->getNextInstruction();
while( i.getOpcode() != UNDEFINED){
cout << i.getEncoding() << endl;
i = parser->getNextInstruction();
}
delete parser;
}