HOMEWORK 8 Due on 06/27/2015 before 8:00 AM INTRODUCTION: In Reverse Polish(post
ID: 3685755 • Letter: H
Question
HOMEWORK 8 Due on 06/27/2015 before 8:00 AM INTRODUCTION: In Reverse Polish(postfix) notation the operators follow their operands; for instance, to add three and four one would write "3 4+" rather than "3+ 4". If there are multiple operations, the operator is given immediately after its second operand; so the expression written "3 -45" in conventional infix notation would be written "3 4-5+" in RPN: first subtract 4 from 3, then add 5 to that. An advantage of RPN is that it obviates the need for parentheses that are required by infix. While "3-4+ 5" can also be written "(3 - 4)+5", that means something quite different from "3 (4+ 5)", and only the parentheses disambiguate the two meanings. In postfix, the latter would be written "3 45+ ", which unambiguously means "3 (4 5 )". Interpreters of Reverse Polish notation are stack-based; that is, operands are pushed onto a stack, and when an operation is performed, its operands are popped from a stack and its result pushed back on. Stacks, and therefore RPN, have the advantage of being easy to implement and very fast Please complete the implementation of the two functions given in the questions section below Test your functions using the main program given. After you complete the homework rename the file "HW8_AssemblyFunctions.S" to "HW8_yourredID.S" and submit only this file on blackboard. Do not include main.c or add contents of main.c to this file. QUESTION 1: Write a function to convert a given function from infix to postfix in assembly. The basic structure of the function is given in the attached assembly language file QUESTION 2: Write a function to convert a given function from postfix to infix in assembly language. The basic structure of the function is given in the attached assembly language fileExplanation / Answer
Hi sorry for the prvious code, Below i have written the code in C# and given you an algorithm to to it, also i have given evaluation postfix expression in assembly for your reference,
Algorithm of Postfix to Infix
§ While there are input symbol left
§ Read the next symbol from input.
§ If the symbol is an operand (i.e. value)
§ Push it onto the stack.
§ Otherwise, the symbol is an operator.
§ If there are fewer than 2 values on the stack
§ (Error) The user has not input sufficient values in the expression.
§ Else, Pop the top 2 values from the stack (operand1 & operand 2).
§ Put the operator, with the values as arguments and form a string (like : operand1 operator operand2).
§ Encapsulate the resulted string with parenthesis. (like: (a+b) if operand1 =’a’, operand2 =’b’, operator = ‘+’ )
§ Push the resulted string back to stack.
§ If there is only one value in the stack
§ That value in the stack is the desired infix string.
§ If there are more values in the stack
§ (Error) The user input has too many values.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.