Computer Science 324 |
Lab 2: Decoding MIPS Instructions
Due: 11:59 PM, Monday, September 24, 2007
As you have seen in class and in the readings from Patterson and Hennessy, MIPS machine instructions are encoded as 32-bit values. Each 32-bit value representing an instruction is viewed as a collection of fields that determine the instruction's operation and its operands. Your task for this week's lab assignment is to implement a MIPS instruction decoder in C. You are to work individually for this lab assignment.
Your program should read in MIPS instructions as hexadecimal numbers from standard input. Each instruction (which you should read into an unsigned int) is then to be passed to a function that will parse the instruction bit fields and return a structure that contains these values in a more convenient format. It should then call another function that prints out the values of the fields.
A starter framework for this lab assignment can be found on the CS Lab Linux systems (or remotely on babyred.mtholyoke.edu) in
/home/jteresco/shared/cs324/labs/mipsdecode/mipsdecode.tar.gzCopy that file to your account, extract it to an appropriate work area, and change to that directory. You should find five files:
Your task is to fill in the missing implementations of the functions parseMipsInstruction and dumpMipsInstruction in mipsInstruction.c, and main in driver.c.
I have provided .o files that you can link with to try out my implementations of driver.c and/or mipsInstruction.c. See the Makefile for details. Your program's behavior should be identical to that of mine when you have completed the assignment.
Your main tasks to complete this lab:
Your code should compile with no warnings when using the -Wall flag to gcc (as is used by the provided Makefile). You should be careful to free any allocated memory at an appropriate time.
I will test your program on a larger input set than that provided in the instructions file. It is up to you to make sure you test all cases that may not be covered in that file. Your program will be graded on style, correctness, and documentation.
Submit a single tar file called lab2.tar that will extract its contents into a directory lab2. The tar file should include four files: Makefile, driver.c, mipsInstruction.h, and mipsInstruction.c. Make sure your name is in the C files that you modified. Please do not include any additional files, such as emacs backup files, object files, or your executable.