This project presents a modified version of a MIPS assembler. The assembler is capable of converting MIPS assembly code into machine code. This documentation provides an overview of the code structure, functionalities, and usage.
The code is structured into a single Java class, MIPSAssembler
, which contains all the necessary methods and functionalities to assemble MIPS code.
assemble(String filename)
: Assembles MIPS code from the specified file.initialize()
: Initializes instruction codes and registers.assembleCode()
: Assembles the MIPS code read from the file.parseInstruction(String[] parts)
: Parses MIPS instructions and converts them into machine code.getLabels()
: Extracts labels and their corresponding line numbers from the MIPS code.parse8DigitHex(int dec)
: Converts decimal integers to 8-digit hexadecimal strings.getFile()
: Opens a file browser dialog for selecting a file.main(String[] args)
: Entry point of the program. Prompts the user to select a file and assembles the code.
To use the Modified MIPS Assembler:
- Compile the Java file:
javac MIPSAssembler.java
- Run the compiled program:
java MIPSAssembler
- Select a MIPS assembly file using the file browser dialog.
- The assembled code will be displayed in the console.
public class Main {
public static void main(String[] args) {
String filename = ModifiedMIPSAssembler.getFile();
System.out.println("Assembled code:\n" + ModifiedMIPSAssembler.assemble(filename));
}
}
- Java Swing library for file browser dialog.
- This project is licensed under the APACHE 2.0 License.