Question

I need help with this program. It is in Irvine MASM Assembly Language. You are to...

I need help with this program. It is in Irvine MASM Assembly Language.

You are to write a program to compute the results of a postfix expression. The expression has the format operand operand operator   where the operator can be +, -, *. You must use a stack to evaluate the expressions. (The system Stack will not work.) Print out the input expression and the results of the evaluation. Read the data from a file and output to a file. Use functions/procedures. Turn in the assembly listing (.lst) and output files.

Input File:

5 9 +
82 41 -
3 10 4 - *
13 18 * 140 80 - +
1 2 3 4 5 6 7 + + + + + +
1998 900 - 98 -
4596 4300 96 + - 2 2 * *
88 45 + 22 9 * 16 7 93 - * + 55 - +
5 2 * 10 40 * + 5 20 * 70 50 - 20 30 40 + + - + 3 - +
55 66 + 17 3 + 20 10 + * +
5 2 * 10 40 * + 5 20 * 70 50 - 20 30 40 + + - + 3 - +
123456 654321 + 123456 654321 + -
99999 2000 *
0 0
Add a comment Improve this question Transcribed image text
Answer #1
.MODEL  SMALL
.DATA
        NL      DB      0DH,0AH,\'$\'
.CODE

MAIN    PROC
        MOV     AX,@DATA
        MOV     DS,AX
READ_CHAR:
        MOV     AH,01H
        INT     21H
        CMP     AL,0DH
        JE      END_OF_SCAN

        CMP     AL,2BH
        JE      EVAL_PLUS

        CMP     AL,2DH
        JE      EVAL_MINUS
CONV_ASCII:
        CMP     AL,39H
        JLE     CONVERT

        SUB     AL,37H
        JMP     TO_PUSH
CONVERT:
        SUB     AL,30H
TO_PUSH:
        MOV     AH,0
        PUSH    AX
        JMP     READ_CHAR
EVAL_PLUS:
        POP     AX
        POP     BX

        ADD     AX,BX
        PUSH    AX
        JMP     READ_CHAR
EVAL_MINUS:
        POP     AX
        POP     BX

        SUB     AX,BX
        PUSH    AX
        JMP     READ_CHAR
END_OF_SCAN:
        POP     BX
        MOV     CL,4
        MOV     AH,09H
        LEA     DX,NL
        INT     21H

NEXT_HEX:
        MOV     DL,BL
        AND     DL,0F0H
        SHR     DL,CL

        CMP     DL,9H
        JLE     ZERO_TO_9

        ADD     DL,37H
        JMP     DISPLAY
ZERO_TO_9:
        ADD     DL,30H
DISPLAY:
        MOV     AH,02H
        INT     21H
        SHL     BL,CL

         CMP     BL,0H
        JZ      EXIT
        JMP     NEXT_HEX
EXIT:
        MOV     AH,4CH
        INT     21H
MAIN    ENDP
END MAIN
Add a comment
Know the answer?
Add Answer to:
I need help with this program. It is in Irvine MASM Assembly Language. You are to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need the following done in MASM (Assmebly or ASM) This program must use Irvine Library and the outline for the code is...

    I need the following done in MASM (Assmebly or ASM) This program must use Irvine Library and the outline for the code is below (Kip irvine) Write an assembly language program to input a string from the user. Your program should do these two things: 1. count and display the number of words in the user input string. 2. Flip the case of each character from upper to lower or lower to upper. For example if the user types in:   ...

  • ssembly Language Programming with x86, IRVINe MASM 1. Write a program to add 7 12 times...

    ssembly Language Programming with x86, IRVINe MASM 1. Write a program to add 7 12 times and print out the result ------------------------------------------------------------------------------- Write a program to print and add 10 20 30 40 50   ; you can use a loop The output should be “The sum of 10 20 30 40 50 ”

  • I NEED SAMPLE PRINT OUT AS WELL AS CODE PLEASE!!!! Objectives: To gain experience with stacks....

    I NEED SAMPLE PRINT OUT AS WELL AS CODE PLEASE!!!! Objectives: To gain experience with stacks. Documentation: Explain the purpose of the program as detail as possible - 8%. Develop a solution for the problem and mention algorithms to be used -12% List data structures to be used in solution. - 5%. Give a description of how to use the program and expected input/output - 5% Explain the purpose of each class you develop in the program. - 5%. Programming:...

  • JAVA, please You must write a robust program meaning that your program should not crash with...

    JAVA, please You must write a robust program meaning that your program should not crash with any given data. Data validation must be done any time that user enters an input. Write a program that 1. Gets an infix expression form the user and evaluate the expression using stack ADT a. Finds the postfix equivalent of the given infix expression b. Evaluate the created postfix expression. c. Note: your program should not crash when you enter an invalid expression such...

  • Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine...

    Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine library procedures Objectives: 1. using register indirect addressing 2. passing parameters 3. generating “random” numbers 4. working with arrays Description: Write and test a MASM program to perform the following tasks: 1. Introduce the program. 2. Generate ARRAYSIZE random integers in the range [LO = 10 .. HI = 29], storing them in consecutive elements of an array. ARRAYSIZE should be set to 200....

  • You are to write a program name expressionTree.java that evaluates an infix expression entered by the...

    You are to write a program name expressionTree.java that evaluates an infix expression entered by the user. The expression may contain the following tokens: (1) Integer constants (a series of decimal digits). (2)   One alphabetic character - "x" (representing a value to be supplied later). (3)   Binary operators (+, -, *, / and % (modulo)). (4)   Parentheses          You will parse the input expression creating an expression tree with the tokens, then use the postOrder tree traversal algorithm to extract...

  • I need assistance with this code. Is there any way I can create this stack class (dealing with infix to postfix then postfix evaluation) without utilizing <stdio.h> and <math.h>? ________...

    I need assistance with this code. Is there any way I can create this stack class (dealing with infix to postfix then postfix evaluation) without utilizing <stdio.h> and <math.h>? ____________________________________________________________________________________________ C++ Program: #include <iostream> #include <string> #include <stdio.h> #include <math.h> using namespace std; //Stack class class STACK { private: char *str; int N; public: //Constructor STACK(int maxN) { str = new char[maxN]; N = -1; } //Function that checks for empty int empty() { return (N == -1); } //Push...

  • Total point: 15 Introduction: For this assignment you have to write a c program that will...

    Total point: 15 Introduction: For this assignment you have to write a c program that will take an infix expression as input and display the postfix expression of the input. After converting the postfix expression, the program should evaluate the expression from the postfix and display the result. What should you submit? Write all the code in a single file and upload the .c file. Problem We as humans write math expression in infix notation, e.g. 5 + 2 (the...

  • Use Assembly (Masm and Irvine32 library) to write a complete program that: 1. Asks the user...

    Use Assembly (Masm and Irvine32 library) to write a complete program that: 1. Asks the user to enter 2 numbers. Assume that the user enters unsigned 32-bit integers only. 2. Displays the product of the two numbers. Assume that the result will never be larger than 32 bits. 3. This process will continue till the user enters 0 for both inputs. You can’t use mul instruction in your program: You need to use shifting and addition only. Your program must...

  • In C programming Language Write a version of the infix-to-postfix conversion algorithm. Write a program that converts an...

    In C programming Language Write a version of the infix-to-postfix conversion algorithm. Write a program that converts an ordinary infix arithmetic expression (assume a valid expression is entered) with single-digit integers For Example: Infix expression (6 + 2) * 5 - 8 / 4 to a postfix expression is  62+5*84/- The program should read the expression into character array infix and use the stack functions implemented in this chapter to help create the postfix expression in character array postfix. The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT