Programming Language Interpreter Design MIPS

Programming Language Interpreter Design MIPS

Objective:

The goal of this assignment is to apply your understanding of MIPS assembly language to implement a program that simulates a simple esoteric language interpreter, specifically for a language called “Brainfry.” This task will test your ability to work with memory manipulation, loops, and conditional branches in MIPS.

Description:

Brainfry is an esoteric programming language that operates on a virtual “tape” consisting of memory cells, where each cell can hold a single byte. The tape is manipulated by moving a “tape head” (a pointer to the current memory cell) left or right, and by incrementing or decrementing the value at the current memory cell.

You will implement a MIPS program that reads a series of Brainfry commands and executes them on a simulated tape of 5,000 memory cells. The following Brainfry commands must be supported in your MIPS implementation:

  • >: Move the tape head to the right.
  • <: Move the tape head to the left.
  • +: Increment the value of the current memory cell.
  • -: Decrement the value of the current memory cell.
  • .: Output the value of the current memory cell as an ASCII character.
  • ,: Input a value from the user and store it in the current memory cell.
  • [: If the value of the current memory cell is 0, jump to the corresponding ] command.
  • ]: If the value of the current memory cell is not 0, jump to the corresponding [ command.
  • All other characters should be ignored by your MIPS program. The end of the program is signified by a ~ character, after which the input to the Brainfry program follows.

    Constraints:

  • The tape is limited to 5,000 memory cells.
  • The tape head should not go into negative indexes.
  • Assume the program starts with all memory cells initialized to 0.
  • Example Input:

    >++[–<]~

    Expected Output:

  • This program should manipulate the tape accordingly and produce any output defined by the . command within the Brainfry code.
  • Task:

    1. Implement the MIPS program: Write a MIPS assembly program that correctly interprets and executes a Brainfry program as described above.

    2. Test your program: Make sure your MIPS program works correctly with different Brainfry inputs.