This repository contains a MIPS CPU core instruction disassembler using a higher level C++. The disassembler is a process where it converts the binary hex instructions that are executed by the MIPS processor to assembly source code that are readable by humans. The inputs were text files with a .obj extension, and the outputs were other text files with a .s extension.
There were three major parts for creating the MIPS disassembler via C++: converting the binary hex input to regular binary, parsing the binary instruction to opcode, rs, rt, rd, shamt, funct, and immediate extension, and last but not least, using them to construct a full readable assembly language. For hex to binary conversion, a function hexToBinary was written, for parsing, a function parseInstruction was used. The main logic was stake the instruction binary as string, use C++ Standard Template Library (STL) and std::stoi to convert those string to intergers, and storing into a struct that contains all the information about the instruction. The struct includes: type, rs, rt, rd, shamt, funct, and immediate extension values. The last part was using findRegister and findInstructionName functions to find the corresponding instruction name or registers with given numbers from input instructions. There could certainly have been a much more efficient way, but the creator tried his best. The main part of those functions were using std::map, another very useful STL member in which the variable can store two things simultaneously: a key (type) variable and a value variable. The decimal values that correspond to register names or instruction names were used.