PROGRAMMING PROJECT 2:
DISASSEMBLER



Review Of: Chapters 1 - 2.

You may work individually or in groups of 2 people to finish this project. I expect that the programming will be your group's effort and not the effort of other persons.


Disassembler

Write a program that will read in machine language and write out the corresponding assembly language commands.

Behavioral Requirements:

Your program should handle all of the instructions and registers in the MIPS Instructions Table and MIPS Registers Table I have provided online. You should be able to handle all 32 registers and all three instruction formats (R, I, and J), including all forms of addressing (for example, lw addresses, beq addresses, and j addresses). You may find Figures 2.1 (p. 78), 2.6 (p. 100), and 2.14 (p. 121) helpful in addition to the table I have provided.

Design and Coding Tips:

You may find this structure chart useful, although you should not feel constrained by it. For example, you may want to create functions similar to getRegName for getting operation or function codes, which would be fine even though there are no such functions on the current structure chart.

You should be able to use the verifyMIPSInstruction and binToDec functions you wrote for Programming Project #1a, as well as the Makefile, header files, and print functions you downloaded for that program. You may also want to use your modified testpp1a.c file as a template for the main function in disassembler.c. Finally, you may wish to complete and use getRegName, a function that translates register numbers to their corresponding register names. (To use the Makefile for the disassembler, edit it and switch to the commented-out version of the "all" target or, alternatively, type make disassembler at the command line.)

The input file should contain one MIPS instruction (32 bits) in machine language format per line. Your program should:

For example, consider the following machine code. (The columns and spaces are just for readability; the actual file would just have 32 "bit" characters per line, without spaces.)

We could translate the different fields into the following numeric values. The program's output would contain the final mnemonics, including appropriate punctuation (dollar signs, commas, and parentheses). (You don't need to line operands up in clean columns, as they are below, although you should put at least a space between the different parts of an instruction. If you WANT to make use of tabs, use \t to represent a tab in a printf statement.)
     lw   $t0, 1200($t1)
     add  $t0, $s2, $t0
     sw   $t0, 1200($t1)

Ensuring Quality

As specified in the syllabus, your program should adhere to the Kalamazoo College CS Program Style Guide and Documentation Standards, including use of the Braces Line Up style pattern. You may also use the associated template files: the function template file and the header template file.

To ensure that all function calls are syntactically correct (match the function definitions), you should include function declarations for all of your functions in one or more header files, and include the header file(s) in all appropriate C source files (*.c files).

The Makefile I have provided specifies a set of compiler options that will help you catch many errors at compile time. These options generate warnings about questionable constructions that often indicate programmer confusion or actual logic errors. You may have to make adjustments to the Makefile, though, if the specific options or option names for your compiler are somewhat different.

Submission Requirements:

You should submit a zip (or tar or 7z) file that contains:

Your program should also work with other input files that may be developed for consistent grading. (Notes: Before zipping up your directory, please rename it to start with your first name, e.g., Alyce_PP2, so that I don't have a dozen folders with similar names. It is also a good idea to run make clean in the directory before zipping it up; this will remove the machine-specific executable and intermediate "object code" files, since your code will have to be re-compiled on my machine anyway.)

The rubric for grading Programming Project #2 will be based roughly on the following.

  Compiles and runs                                            10 pts
  Correctness (satisfies requirements)                         68 pts
  Internal documentation and coding style                      10 pts
  External Documentation                                        8 pts
  Test Cases                                                    9 pts

  Total:                                                       105 pts