Department of Electrical and Computer Engineering
University of Texas at Austin
EE 379K, Fall 2000
Y. N. Patt, Instructor
TAs: Kathy Buchheit, Laura Funderburg, Chandresh Jain, Onur Mutlu,
Danny Nold, Kameswar Subramanian, Francis Tseng, Brian Ward
Programming Assignment 5
Due: December 3, 2000 11:59 PM
In this program, we ask you to design an infix calculator. The program
should start by displaying a prompt for the user Input>. The user
will then enter an arbitrary arithmetic expression, using only the operator
+ (denoting the binary operation of addition), the operator - (denoting
the binary operation of subtraction), the left parenthesis, the right parenthesis,
together with decimal valued integer operands. This expression should be
entered using an infix notation (explained below). As this expression is
entered, the program can begin evaluating the expression. Once entry of
the expression is complete (i.e., after the user hits the "ENTER" key),
the program should display the results of calculating the arithmetic expression
entered, followed by a new prompt for further user input. When the user
types "x" in response to the prompt for further input, the program
should display "Have a nice day!" and terminate.
Most people are accustomed to writing arithmetic expressions in INFIX
notation, in which case an operator that denotes a binary operation appears
BETWEEN the two operands, as in
( 2 + 3 )
Using nested parentheses, we can represent more complex expressions such
( 11 + ( ( 19 + 23 ) - ( 4 + 10 ) ) )
You may assume that only valid input expressions are entered.
The numbers and symbols must be separated by exactly one space.
The numbers in the input expression are positive integers up to three decimal
The input expression is fully parenthesized. Examples of expressions
that are NOT fully parenthesized are
1 + 2
( 2 + ( 15 - 12 ) + 5 )
There must be an operator for every pair of parentheses. For example, the
following will not be considered as valid input expressions.
( 5 )
( ( 5 ) - ( 4 + 3 ) )
Your result should be output to the screen using a plus or minus sign followed
by three deciaml digits.
When the result of an expression is zero, you should output +000.
You are strongly encouraged to use a stack in the implementation of your
design. You should allocate a block of 50 entries for the stack in your
You are also encouraged to use subroutines to make your program easier
to work with.
You are free to use any example program in the textbook.
Input> ( 101 - ( ( 23 + 31 ) + 74 ) )
Input> ( 150 - ( 1 + 2 ) )
Input> ( 1 - 1 )
Input> ( ( 200 - ( ( ( ( ( 5 - 3 ) - 75 ) - 18 ) + 5 ) - 7 ) ) + 2
Have a nice day!
Writing and submitting your program
Your code should have a comment block at the beginning of the file.
Include in this comment block, your name, your ECE login name, student
number, and a brief description of the program. Your description should
serve as a general summary of your program's approach to the problem and
will aid in grading. It will also serve as a guideline for assigning partial
credit. It is in your best interest to make all of your ideas clear through
this summary and through commenting within your code.
We request you place your program starting at memory location x3000.
Think carefully about the design of your program before you start writing
your code. Make a flowchart before you start writing code.
Submit your assembly file using the submit program or the submit script.
The program number is 5.
Check your ECE email to verify that you have submitted your program
correctly. If you don't get a confirmation, we might not see your submission.