Simple Integer Calculator Assignment

Project: Simple Integer Calculator

Given this modified definition of the <assign> statement from the Compiler Modules grammar:

<assign> ::= Id = Int op Int

where Id = alphabetic variable name, 1 to 6 characters

Int = positive integer value < 1000

op = one of {+ add | - subtract | * multiply | / divide}

Write a correct program in MIPS - QtSpim assembly language that: 

  • Interprets the <assign> statement from the grammar.
  • Accepts as input a string of up to 20 characters.
  • Parses the string according to the grammar.
  • Calculates the correct integer arithmetic result.
  • Writes the calculated result value to the QtSpim display screen.

For Example:

input -- Total = 63 * 72 (entered by the program user)

output -- Total = 4536

Use the System Service calls on page A-44 of the textbook for the input and output.

Your program should display a message when it stops.

A loop to allow testing would be helpful.

The work products of this assignment are:

  • A copy of the source program text file.
  • Screen captures showing the multiple test output results.