MIPS Disassembler (Hex to Assembly)
I created this project with Nick Weldum for the Computer Architecture class. The objective was to write a program in the MIPS assembly language that would read lines of hexadecimal from a file and output a corresponding MIPS assembly file. I had a lot of fun with this project. It was a great way to demonstrate our understanding of how MIPS works under the hood, file I/O, and other technical skills.
The Process
Each line of hexadecimal needed to be converted from a string to an integer and separated into its pertinent parts using bit manipulation.
![](/assets/posts/2021/08/mips/instruction-diagram.jpg)
The real crux of the project is how the program matches the code to its corresponding string for output. I’m sure a large portion of the class hard-coded if statements to match opcodes to their string, but I borrowed an idea from MIPS. I produced a table very similar to a MIPS processor’s error jump table. Instead of matching error codes to their handler’s memory addresses, I matched opcode/funct codes to their corresponding strings.
This allowed me to very easily and rapidly add more than the required 18 instructions. My program was able to disassemble 43 different instructions.
Last Updated: August 2021