CS 2734
Computer Organization II
Laboratory 10 [Apr 3, 5, 2000]
A Simple Dis-assembler
In this laboratory you will be writing C code to dis-assemble
an input MIPS machine-language program. (It is permissible
to use C++ or Java for these assignments.) To ``dis-assemble''
means to convert the machine-language program back to some form
of assembler language.
- Based on the input machine-language instruction, create
a symbolic form using the following steps:
- Use the program of Lab 9 to tear the instruction into its
component fields (some representing overlapping portions):
- op: op code, bits 26-31
- rs: read reg #1, bits 21-25
- rt: read reg #2, bits 16-20
- rd: write reg, bits 11-15
- sh: shamt, bits 6-10
- ft: funct, bits 0-5
- ai: addr/immed, bits 0-15
- ta: target addr, bits 0-25
- Using the op field, and the ft field in case the
op field is zero,
determine the symbolic operation as a character string.
- Convert any register numbers rs, rt,
and rd to the proper strings.
- For R-type instructions, one only needs to output the op
and the registers in the proper order.
- For beq and bne instructions, get the
offset address, ai,
and multipy this by 4. (You might use the form "PC + 36".)
- For lw and sw instructions,
get the offset, ai, and put
it into the instruction (without multipying by 4) in the
proper place.
- For the jump instruction (j), get the address from ta
and output in the form "J [ta/4]".
- Create a new directory for this assignment.
- Practice your program on the following
Sample input.
Here is the output that my own program for this lab produced:
Sample output.
- You should check off your program with the lab TA.
You must hand the source code
to the TA before he starts checking off the project.
Revision Date: 3/31/00