-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPass2.cpp
More file actions
59 lines (48 loc) · 1.62 KB
/
Pass2.cpp
File metadata and controls
59 lines (48 loc) · 1.62 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
57
58
59
/*
Team:
Nicholas Dibello-Hitta, cssc4049, RedID: 828490930
Dylan Agoncillo, cssc4051, RedID: 824340550
*/
#include "Assembler.h"
#include "AppendixA.h"
#include <fstream>
#include <vector>
#include <iostream>
#include <sstream>
#include <iomanip>
//We should pass the input file, symtab, and littab into Pass 2
void pass_2(std::string sourceFile) {
std::cout << "In pass 2 ----------------------------------------------------------------------------" << std::endl; // just for me :)
//open necessary files
std::vector<std::string> currentLine(5);
std::string tempFileName = sourceFile.substr(0, sourceFile.length() - 4) + ".temp";
inputFile.exceptions(std::ifstream::failbit);
inputFile.open(tempFileName);
std::string outputFileName = sourceFile.substr(0, sourceFile.length() - 4) + ".lis";
outputFile.exceptions(std::ofstream::failbit);
outputFile.open(outputFileName);
assemblerPass = 2;
//*SETUP
//pass first comment line to temp file
processLine(currentLine);
outputToFile(currentLine);
//next line should be start
processLine(currentLine);
if (currentLine[2].find("START") != currentLine[2].npos){
outputToFile(currentLine);
}
//* Main loop
while(currentLine[2].find("END") == currentLine[2].npos) {
std::cout << "processLine" << std::endl;
processLine(currentLine);
std::cout << "assemble_object" << std::endl;
assemble_object(currentLine);
std::cout << "outputToFile" << std::endl;
outputToFile(currentLine);
std::cout << "end of loop" << std::endl;
}
//housekeeping
inputFile.close();
outputFile.close();
return;
}