Description
Problem Statement:
Write a MIPS Assembly Program for evaluating an expression in postfix format.
Input: Postfix expression with constant integer operands in the range 09 and operators +, ,
and *.
A C++ program to convert the expression to postfix expression is uploaded on Moodle.
Input to C++ program is an infix expression.
Example:
Input to C++ Program: 3+2*5 (>infix expression)
Output of C++ Program: 325*+ (> Postfix expression)
The postfix expression can be accepted as a string input to the assembly program at run time.
Example: “325*+” (without the quotes).
Example execution for the above expression, using a stack structure:
3 > push onto the stack. Stack contents: 3
2 > push onto the stack. Stack contents: 3 2
5 > push onto the stack. Stack contents: 3 2 5
* > pop the top 2 stack elements, perform the multiplication, then push the result onto the
stack. Stack contents: 3 10
+ > pop the top 2 stack elements, perform the addition, then push the result onto the stack.
Stack contents: 13
Reference for ASCII character to int conversion:
https://stackoverflow.com/questions/15940331/convert-string-of-ascii-digits-to-int-in-mipsassembler
Refer pages 96-97 in the MIPS manual below for reading string/char input:
http://www.egr.unlv.edu/~ed/MIPStextSMv11.pdf
Output: Print the result of the expression.
Other instructions:
Please refer to this document for help on MIPS Assembly language and QtSpim.
http://www.egr.unlv.edu/~ed/MIPStextSMv11.pdf
Please post your doubts on Piazza and we will revert as soon as possible.
MAX marks = 10. Breakup of marks:
1M : For proper inputs reading (inputs can be taken from keyboard)
1M : For printing the correct result
3M : Approach & Code
3M : Test cases
1M : Document
1M : Questions/Viva
Late Penalty: Same as in Assignment 1.