PLEASE HELP ME WITH THIS MIPS PROGRAM , thank. Description In this project,you w
ID: 3678414 • Letter: P
Question
PLEASE HELP ME WITH THIS MIPS PROGRAM , thank.
Description
In this project,you will create a simple MIPS simulator. Your simulator will read a binary file containing a MIPS program and execute that program. This will occur in two steps. First, your program will generate the assembly code for the given MIPS program (disassembler).Second, your program will create an instruction-by-instruction simulation of the MIPS program. This simulation will execute instructions sequentially (non-pipelined) and output the contents of all registers and memory (the state of the processor and memory) after each instruction. You will not have to implement exception/interrupt handling
You will be given the expected output for each input program. Your output must exactly match the expected output. The program will be graded simply by using the diff program. The diff program simply lists the differences between two files. Your output should have no differences with the expected output. We will suppress white space differences, so if you have a space instead of a tab, that is OK.
Your disassembler can be reused for the next project, so try to write it in a way such that you can separate it from your code to execute the program. In fact, it is easier to write and debug the disassembler first, then write the emulation portion of the project.
Implementation:
You may implement this project in any programming language of your choosing. You MUST include instructions in a README file that indicate how to compile (if necessary) and run your program. You MUST include a makefile to compile the code if it is in a language that requires compilation. Examples are linked on the course web site. Your code will be graded on linux on the home server. The only reason it will not be graded there is if you use such an obscure language that home does not have the correct compilers/interpreters for it. C/C++, and Java program must be able to run on home. You may develop locally, then test on home at the end. This program should require NO system libraries, except I/O, so there should be no trouble.
Details:
Refer to the MIPS instruction set architecture PDF that is posted along with the course notes on the course website. It provides the details for all MIPS instructions. NOTE that we are making the following changes to the instruction set architecture:
Instead of a 6 bit opcode, we will use a 5 bit opcode that is preceded by a valid bit. The valid bit will be set to 1 if the instruction is valid and should be executed. If the valid bit is set to 0, then the instruction has no effect (it is effectively a NOP). The opcodes will be the same as those in the MIPS instruction set, just ignore the most significant bit (the first bit). We will not change the functionality of any instruction, simply we use this convention for the opcode. The table below illustrates this change:
Bit 31:Valid bit
Bits 30 - 26: Opcode
Bits 25 - 0:The rest of the instruction
A suggestion to make coding the program easier. First, read the entire file and simply print if each instruction is valid or not. This will force you to get the general structure of the disassembler in place and debugged before you begin the more complicated step of disassembly.
You will be given an input file containing a sequence of 32 bit instruction words. Assume that the first instruction is at memory address 96. The final instruction in an instruction sequence is ALWAYS a “BREAK” instruction. Following the break instruction is a sequence of 32 bit 2’s compliment signed integers for the program data. These continue until the end of file.
Your simulator/disassembler must support the following MIPS instructions. Check the MIPS manual for details on instruction representation and operation for each instruction.
J, JR, BEQ, BLTZ
ADD, ADDI,SUB
SW, LW
SLL, SRL
MUL,
AND, OR,
MOVZ
NOP
Input:
Your program must accept command line arguments for execution. The following arguments must be supported (Executable named "mipssim"):
mipssim –i INPUTFILENAME –o OUTPUTFILENAME
Your program will produce 2 output files. One named OUTPUTFILENAME_sim.txt, which contains the simulation output, and one named OUTPUTFILENAME_dis.txt, which contains the disassembled program code for the input MIPS program.
Your program will be graded both with the sample input and output provided to you, and with input and output that is not provided to you. It is recommended you construct your own input programs for testing.
Output:
Your program will produce 2 output files.
One named OUTPUTFILENAME_sim.txt, which contains the simulation output
One named OUTPUTFILENAME_dis.txt, which contains the disassembled program code for the input MIPS program.
The disassembled output file should contain one line per word in the input file. It should be separated into 4 columns, each separated by tab character. The columns contain the following information:
1. The binary representation of the instruction word. If the word is an instruction (as opposed to memory data after the BREAK instruction), the instruction should be split into seven groups of digits: the valid bit, the opcode bits, four groups of 5 bits, and a final group of 6 bits.
2. The address of the memory location (in decimal)
3. The disassembled instruction opcode
4. If it is an instruction, print the operation, followed by a tab character, then print each argument separated by a comma and a space ( “, “).
The simulation file must have the following format:
20 equal signs and a newline
cycle: [cycle number] [tab] [instruction address] [tab] [instruction string (same as step 4 above)]
[blank lane]
registers:
r00: [tab] [integer value of R00][tab] [integer value of R01][tab] . . . [integer value of R07]
r08: [tab] [integer value of R08][tab] [integer value of R09][tab] . . . [integer value of R15]
r16: [tab] [integer value of R16][tab] [integer value of R17][tab] . . . [integer value of R23]
r24: [tab] [integer value of R24][tab] [integer value of R25][tab] . . . [integer value of R31]
[blank line]
[data address]: [tab] [show 8 data words, with tabs in between] ... [continue until last data word]
Hint: Spend some time creating an output function or class or module or whatever fits your language of choice that handles printing out the various data in this format. Spending a little time to do it right in the beginning will save you a lot of time later. Another hint, the register file and memory can simply be implemented as arrays. Go ahead and make them global variables so you don’t have to pass them around to a bunch of functions. This just makes the code a little more simple to write.
Instructions and arguments should be in capital letters. All integer values should be in decimal. Immediate values should be preceded by a # sign. Be careful and consider which instructions take signed values and which take unsigned values. Be sure to use the correct format depending on the context.
You output will be graded with the diff command. Test your output against the provided sample outputs!Any differences reported by the diff command are assumed to be incorrect output!
Sample files will be provided with the following extensions:
.c – C code
.mips – the compiled version of the C code
.bin – the binary version of the .mips file
sample output files
a file named similar to sample_bin.txt which is a text version of the .bin file for your reference. Note that your program must accept the .bin file, not the text version.
Input and Expected Output:
The remainder of the document contains PDF versions of the expected output. The input files and text files of the expected output will be available on the course webpage. The final two pages of this document contain programs to convert text files containing binary strings to binary files, and vice versa. Use those programs to develop your own MIPS executables for debugging and testing. Note that your program MUST USE A BINARY FILE AS INPUT. The test1 example contains a text representation of the input file as well as the c version of the program. These are there for informational purposes only. Your program only needs to read the binary file and produce the disassembled file and simulation file.
Explanation / Answer
Hi i have written the following code for your reference that will read binary file in MIPS
LBU load byte unsigned<br>
LW load word<br> SB store byte<br> SW store word<br> LUI load upper immediate<br> ADD add<br> ADDI add immediate<br> ADDU add without overflow<br> ADDIU add immediate without overflow<br> AND and<br> MULT multiply<br> MULTU unsigned multiply<br> OR or<br> ORI or immediate<br> XOR xor<br> SLL shift left logical<br> SRA shift right arithmetic<br> SRL shift right logical<br> SUB subtract with overflow<br> SUBU subtract without overflow<br> SLT set less than<br> SLTI set less than immediate<br> SLTU set less than unsigned<br> SLTIU set less than immediate unsigned<br> BEQ branch on equal<br> BGEZ branch on greater than equal zero<br> BGTZ branch on greater than zero<br> BLEZ branch on less than equal zero<br> BLTZ branch on less than zero<br> BNE branch on not equal<br> J jump<br> JAL jump and link<br> JR jump register<br> MFHI move from HI register<br> MFLO move from LO register<br>Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.