Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- void printingHeader(string progName, string startAddress, string comment){
- //(1-9) (1-6 PROGNAME/Label) plus 3 spaces
- cout << left << setw(6) << setfill(' ') << progName;
- cout << " ";
- //(10-17) (10-15 "START ") plus 2 more spaces START IS STATIC for header
- cout << "START ";
- cout << " ";
- //(18-35)Starting address
- cout << left << setw(18) << setfill(' ') << startAddress;
- //(36-68)comments or space chars
- cout << comment << endl;
- }
- void printingTextOrMod(string label, string instruction, string parameter, string comment2){
- //1-8 (1-6 PROGNAME/Label) including 2 spaces
- cout << left << setw(6) << setfill(' ') << label;
- cout << " ";
- //(9)+ or space
- //if(e == 1) "+" else print space
- cout << " ";
- //(10-16)(10-15 instruction) and one space
- cout << left << setw(7) << setfill(' ') << instruction;
- //(17)#,@,=,or a space
- cout << " ";
- //(18-35 parameter)
- cout << left << setw(18) << setfill(' ') << parameter;
- //(36-68)comments
- cout << comment2 << endl;
- }
- void printingEnd(string endAddress){
- //1-9 all spaces
- cout << " ";
- //(10-17)(10-15 instruction) and two space
- cout << "END ";
- //(18-35 parameter)
- cout << left << setw(18) << setfill(' ') << endAddress;
- }
- int main() {
- //HEADER EXAMPLE
- string progname = "SUM";
- string startingAddress = "0000";
- string comment = "THIS IS HEADER COMMENT ";
- //TEXT EXAMPLE
- string label = "LOOP";
- string instrcution = "ADD";
- string parameter = "TABLE";
- string comment2 = "THIS IS TEXT COMMENT ";
- string label1 = "";
- string instrcution1 = "TIX";
- string parameter1 = "TABLE2";
- string comment3 = "THIS IS TEXT COMMENT ";
- //MODIFICATION EXAMPLE
- string label2 = "";
- string instrcution2 = "RESW";
- string parameter2 = "2000";
- string comment4 = "THIS IS MODIFICATION COMMENT ";
- //END EXAMPLE
- string endAddress = "00000";
- printingHeader(progname, startingAddress, comment);
- printingTextOrMod(label, instrcution, parameter, comment2);
- printingTextOrMod(label1, instrcution1, parameter1, comment3);
- printingTextOrMod(label2, instrcution2, parameter2, comment4);
- printingEnd(endAddress);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement