tables/dispatch_tables.txt

This file contains the MIPS bytecode decoding tables.

These tables are utilised by mipsgen to create the switch statements that make up the core dispatch routines of a disassembler.

This data is derived from the CPU Opcode Map in the "MIPS32 4K Processor Core Family Software User's Manual".

See MD00016-2B-4K-SUM-01.18.pdf p169.

tables/asm_format.txt

This file contains the human readable format records of MIPS bytecodes.

These format records are used by mipsgen to generate print statements that decode opcodes into human readable disassembly for output.

This data is derived from the individiual instruction listings in "MIPS32 Architecture For Programmers Volume II: The MIPS32 Instruction Set".

See MIPS_Vol2.pdf p34.

tables/field_format.txt

This file contains extra decoding metadata required to output an opcode field as human readable text.

This data is used by mipsgen to build both the format string for a printf statement, as well as gather the arguments for it.

This data is derived formats come from "MIPS32 Architecture For Programmers Volume II: The MIPS32 Instruction Set".

See MIPS_Vol2.pdf p34.

tables/opcode_bits.txt

This file contains the bitwise layout of the MIPS bytecodes supported by the mipsgen disassembler.

These tables are utilised by mipsgen to check that instructions are valid.

This data is derived from the individiual instruction listings in "MIPS32 Architecture For Programmers Volume II: The MIPS32 Instruction Set".

See MIPS_Vol2.pdf p34.

codegen/parse.rb

This file contains the routines for parsing and verifying the textual data that drives the disassembler code generator.

codegen/ancillary.rb

This file contains routines for buliding ancillary data that the mipsgen code generator requires.

codegen/util.rb

This file contains various formatting and parsing utilities.

codegen/cgen.rb

This file contains the C code generator for mipsgen. See docs/cgen.md for more information.

codegen/rbgen.rb

This file contains the ruby code generator for mipsgen. See docs/rbgen.md for more information.

codegen/jsgen.rb

This file contains the javascript code generator for mipsgen. See docs/jsgen.md for more information.

scripts/mipsgen.rb

mipsgen is a command line tool that generates code for MIPS bytecode disassemblers.

The current code generation flavours are c, javascript and ruby.

usage:

mipsgen.rb c
mipsgen.rb rb
mipsgen.rb js

disasm/c/mips_dispatch.h

This file contains autogenerated C routines for dispatching and disassembling MIPS opcodes.

disasm/c/mipsdis.c

mipsdis is a simple command line MIPS disassembler. The core dispatch and decoding routines are autogenerated by mipsgen.

usage:

mipsdis input.txt

The expected input format is the first two columns from objdump:

hex_addr   hex_opcode
80001678:  27bd0008

The decoder will ignore any extra columns, and any lines not matching the above format.

The output format is similar to objdump output:

hex_addr   hex_opcode  asm
80001678:  27bd0008    addiu  $29,$29,8

This is not a fully featured disassembler, as it lacks quite a few usability features, but it is sufficient for debugging and exercising the code generator.

disasm/rb/mips_dispatch.rb

This file contains autogenerated ruby routines for dispatching and disassembling MIPS opcodes.

disasm/rb/mipsdis.rb

mipsdis is a simple ruby-based command line MIPS disassembler.

See disasm/c/mipsdis.c for the C code this is based on. See codegen/rbgen.rb for more information.

disasm/js/mips_dispatch.js

This file contains autogenerated javascript routines for dispatching and disassembling MIPS opcodes.

disasm/js/sprintf.js

This file contains a javascript implementation of sprintf.

disasm/js/mipsdis.js

mipsdis is a simple javascript-based command line MIPS disassembler.

See disasm/c/mipsdis.c for the C code this is based on. See codegen/jsgen.rb for more information.

test/input.txt

This is the master test input file for mipsdis/mipsgen.

The data was generated with a fuzzer script using tables/opcode_bits.txt as input. The aim is to get a large amount of coverage of odd cases with a small amount of effort.

The first column is the address in hex. The second column is the opcode in hex.

See test/expected.txt for the expected result of running this file through mipsdis.

test/expected.txt

This is the expected output from running test/input.txt through mipsdis.

The known good disassembly comes from running test/input.txt through objdump and filtering the result slightly.

test/test.sh

This file runs the test cases that cover the code generator and the different versions of mipsdis.

At present, there is one test, which is to check that running test/input.txt through each version of the mipsdis disassembler produces the results in test/expected.txt.