SHARE
TWEET

Untitled

a guest Apr 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. using namespace std;
  5.   void printingHeader(string progName, string startAddress, string comment){
  6.     //(1-9) (1-6 PROGNAME/Label) plus 3 spaces
  7.       cout << left << setw(6) << setfill(' ') << progName;
  8.       cout << "   ";
  9.     //(10-17) (10-15 "START ") plus 2 more spaces START IS STATIC for header
  10.       cout << "START ";
  11.       cout << "  ";
  12.      
  13.     //(18-35)Starting address
  14.       cout << left << setw(18) << setfill(' ') << startAddress;
  15.  
  16.     //(36-68)comments or space chars
  17.       cout << comment << endl;
  18.   }
  19.  
  20.   void printingTextOrMod(string label, string instruction, string parameter, string comment2){
  21.     //1-8 (1-6 PROGNAME/Label)  including 2 spaces
  22.       cout << left << setw(6) << setfill(' ') << label;
  23.       cout << "  ";
  24.     //(9)+ or space
  25.       //if(e == 1) "+" else print space
  26.       cout << " ";
  27.     //(10-16)(10-15 instruction) and one space
  28.       cout << left << setw(7) << setfill(' ') << instruction;
  29.     //(17)#,@,=,or a space
  30.       cout << " ";
  31.     //(18-35 parameter)
  32.       cout << left << setw(18) << setfill(' ') << parameter;
  33.     //(36-68)comments
  34.       cout << comment2 << endl;
  35.  
  36.   }
  37.   void printingEnd(string endAddress){
  38.     //1-9 all spaces
  39.       cout << "         ";
  40.     //(10-17)(10-15 instruction) and two space
  41.       cout << "END     ";
  42.     //(18-35 parameter)
  43.       cout << left << setw(18) << setfill(' ') << endAddress;
  44.   }
  45.  
  46. int main() {
  47.   //HEADER EXAMPLE
  48.   string progname = "SUM";
  49.   string startingAddress = "0000";
  50.   string comment = "THIS IS HEADER COMMENT ";
  51.  
  52.   //TEXT EXAMPLE
  53.   string label = "LOOP";
  54.   string instrcution = "ADD";
  55.   string parameter = "TABLE";
  56.   string comment2 = "THIS IS TEXT COMMENT ";
  57.  
  58.   string label1 = "";
  59.   string instrcution1 = "TIX";
  60.   string parameter1 = "TABLE2";
  61.   string comment3 = "THIS IS TEXT COMMENT ";
  62.  
  63.   //MODIFICATION EXAMPLE
  64.   string label2 = "";
  65.   string instrcution2 = "RESW";
  66.   string parameter2 = "2000";
  67.   string comment4 = "THIS IS MODIFICATION COMMENT ";
  68.  
  69.   //END EXAMPLE
  70.   string endAddress = "00000";
  71.  
  72.   printingHeader(progname, startingAddress, comment);
  73.   printingTextOrMod(label, instrcution, parameter, comment2);
  74.   printingTextOrMod(label1, instrcution1, parameter1, comment3);
  75.   printingTextOrMod(label2, instrcution2, parameter2, comment4);
  76.   printingEnd(endAddress);
  77. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top