Question: Program this C + + assignment, it focuses on reading and parsing the SIC / XE object code and printing out the details of each

Program this C++ assignment, it focuses on reading and parsing the SIC/XE object code and printing out the details of each instruction in the text records of the object code in the order of how they appear in the object code. Each instruction has its opcode (mnemonic), operand/s, and addressing mode/s. The composition of the object code structure includes the header record, the text records where each text record contains a series of instructions, modification records (if there are any), and the end record. In this assignment, you would ONLY need to focus on the text records.
Input and Output Files
Input File:
Object Code file: test.obj
This file name would be passed as a command line argument to your project.
Output File:
Object code structure in text form: obj_struct.txt.
Note:
Your program should produce the output file with the exact name obj_struct.txt to work.
The obj_struct.txt file should follow exactly what appears in the sample example_obj_struct.txt using the exact format.
The output file will have the following 5 columns in that order: Instruction, Format, Operand Addressing Type, Target Address Addressing Mode, and Object Code.
Instruction print the mnemonic (big case) of the instruction: LDA, ADD, ...
Format print the format number: 2,3, or 4. Do NOT need to consider format 1 in this assignment.
Operand Addressing Type print the addressing mode for computing the operand: simple, immediate, indirect
Target Address Addressing Mode print the addressing mode for computing the target address: pc, base, or absolute (equivalent to direct)
If indexed addressing mode is used, then print pc_indexed, base_indexed, or direct_indexed.
Object Code print Object code for each instruction
The output file should print the first line with the column header acronyms (exactly as below):
INSTR FORMAT OAT TAAM OBJ
There need to be some spaces separating columns in the obj_struct.txt. The number of spaces for the separation is flexible. It is recommended to set the columns with a consistent width of 16 characters so the output format looks consistent with autograder output.
Some columns might be blank, such as format 2 addressing modes, if that is the case, leave the addressing mode columns blank. (It would be good to still add spaces to keep columns lined up for easier reading.)
Required Features
Your program MUST support format 2,3,4 instructions and does NOT need to support format 1 instructions.
Your program shall support the parsing of all 59 instructions (except format 1 instructions) and their corresponding mnemonics in the SIC/XE architecture, for example, the mapping between the following two arrays. Note: you do NOT have to use the following data structures in your assignment implementation.
const static string ops[]={
"18","58","90","40","B4","28",
"88","A0","24","64","9C","C4",
"C0","F4","3C","30","34","38",
"48","00","68","50","70","08",
"6C","74","04","D0","20","60",
"98","C8","44","D8","AC","4C",
"A4","A8","F0","EC","0C","78",
"54","80","D4","14","7C","E8",
"84","10","1C","5C","94","B0",
"E0","F8","2C","B8","DC"
};
const static string mnemonics[]={
"ADD", "ADDF", "ADDR", "AND", "CLEAR", "COMP",
"COMPF", "COMPR", "DIV", "DIVF", "DIVR", "FIX",
"FLOAT", "HIO", "J", "JEQ", "JGT","JLT",
"JSUB", "LDA", "LDB","LDCH","LDF","LDL",
"LDS","LDT","LDX","LPS", "MUL", "MULF",
"MULR", "NORM", "OR","RD", "RMO", "RSUB",
"SHIFTL", "SHIFTR", "SIO", "SSK", "STA", "STB",
"STCH","STF", "STI", "STL","STS","STSW",
"STT","STX", "SUB", "SUBF", "SUBR", "SVC",
"TD", "TIO", "TIX", "TIXR", "WD"
};
const static bool format2[]={
false,false,true,false,true,false,
false,true,false,false,true,false,
false,false,false,false,false,false,
false,false,false,false,false,false,
false,false,false,false,false,false,
true,false,false,false,true,false,
true,true,false,false,false,false,
false,false,false,false,false,false,
false,false,false,false,true,true,
false,false,false,true,false
};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!