IUP Computer Science
CO 300   Assembly Language
Spring 1988

Program #4    (due 28 March 1988)


    Write a VAX assembly language program to read in a simple arithmetic expression and to display the result.

    All arithmetic expressions are in the form:     number operator number

with NO spaces anywhere in the expression.  All numbers are in the range -32768 to +32767.  There are no parentheses.  All positive numbers have a + sign; and negative numbers have a - sign immediately to the left of the first digit.  There are four lowercase words that are operators:  plus (to add), minus (to subtract), times (to multiply), and by (to divide).  The following are examples of valid expressions:
+2plus+2    +357minus+5071   -127times+7   +24569by+19   +5569minus-298   -90times-4487
    Your program should prompt the person at the terminal to enter such an expression, read in the expression and evaluate it, and display the result, with appropriate annotation.  The arithmetic should be done using WORD values.  If the divisor in a division expression is zero, the program should display an error message rather than attempt the division.  If there is overflow in an evaluation, the program should display an error message rather than the result.  The program should loop:  prompting,   reading in, evaluating and displaying until the person at the terminal enters a % instead of an expression.

    Your program may assume that an expression is in the right form (as described above); however, the program must verify that the operator is one of the four allowed.  If the operator is NOT valid, the program should display an error message rather than attempt an evaluation. If you enter an invalid number as part of an expression, your program will almost certainly terminate with a reserved operand fault.

    Hand in a .LIS listing of your program and a PHOTO log that shows the execution of your program and demonstrates its capabilities, results and error messages.