Build me a parser
Budget: $30 – $250 USD
This project will be focused 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 project, 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
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.
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 implementation.
Compilation: The command make will be used to compile your program. You MUST provide an appropriate.
Executable Name: Please generate your disassembler executable file with a name disassem. Make sure to use the “-o” disassem flag in your Makefile compilation command, also the Makefile should use a “-g” compile flag to enable gdb debugging.
Executable Command Line Arguments: The disassembler should use the object code file name as the command line arguments for execution. If the object code file is not present, then the program should exit by displaying a message “missing the input file” asking for the missing input file. The following shows how your executable will be called:
./disassem test.obj
Have added example input and output files below as well.
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
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.
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 implementation.
Compilation: The command make will be used to compile your program. You MUST provide an appropriate.
Executable Name: Please generate your disassembler executable file with a name disassem. Make sure to use the “-o” disassem flag in your Makefile compilation command, also the Makefile should use a “-g” compile flag to enable gdb debugging.
Executable Command Line Arguments: The disassembler should use the object code file name as the command line arguments for execution. If the object code file is not present, then the program should exit by displaying a message “missing the input file” asking for the missing input file. The following shows how your executable will be called:
./disassem test.obj
Have added example input and output files below as well.