Question

Implement a simple four function calculator in the LC3 assembly language that will run on the...

Implement a simple four function calculator in the LC3 assembly language that will run on the LC-3 simulator. The LC-3 computer only reads a character at a time but is capable of displaying a string of characters. This calculator program will use multiple subroutines that perform purposes such as reading multi-digit numbers, converting them to integers, performing addition, subtraction, multiplication, or division on these numbers, and displaying the result. The inputs to the calculator will not exceed 4 digits. The user interaction with the calculator is shown below in several example runs:

EXAMPLE RUN 1:

Enter the first operand (SRC1):     34

Enter the second operand (SRC2):    27  

Operation (+, -, *, /)?    +

Sum is: 61

Continue (Y, N)? Y

Enter the first operand (SRC1):     378

Enter the second operand (SRC2):    237

Operation (+, -, *, /)? -

Difference is: 141   

Continue(Y, N)? N

EXAMPLE RUN 2:

Enter the first operand (SRC1):     34

Enter the second operand (SRC2):    75  

Operation (+, -, *, /)? -   

Difference is: -41

Continue(Y, N)? N

EXAMPLE RUN 3:

Enter the first operand (SRC1):     24

Enter the second operand (SRC2):    18  

Operation (+, -, *, /)?    *

Product is: 432

Continue(Y, N)? N

0 0
Add a comment Improve this question Transcribed image text
Answer #1

;initializes all registers to zero
AND R0, R0, #0
AND R1, R1, #0
AND R2, R2, #0
AND R3, R3, #0
AND R4, R4, #0
AND R5, R5, #0
AND R6, R6, #0
AND R7, R7, #0

;this block will ask for user input then display it to the monitor

NEXTCHARACTER GETC
OUT
;reads input and determines whether or not it is a valid character
;Space?
LEA R0, PROMPT ;Save the location of the prompt
PUTS ;Print the prompt to the screen
GETC ;Store the character into R0

Add a comment
Know the answer?
Add Answer to:
Implement a simple four function calculator in the LC3 assembly language that will run on the...
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
  • Write an ARM program that implements a simple four-function calculator and prompts the user to enter...

    Write an ARM program that implements a simple four-function calculator and prompts the user to enter a pair of decimal integers (A and B) followed by a character that specifies one of the operators: ‘+’ for addition to compute A+B                             ‘-‘ for subtraction to compute A-B ‘*’ for multiplication to produce the product A*B ‘/’ for division to produce the quotient A/B. Input should be the pair of numbers followed by the operand followed by a return. For example...

  • Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two...

    Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two integer numbers as input and ask the user if he need to compute addition, subtraction, remainder, division, or multiplication then print the result. Hint: you can give each operation a special number. For example, the addition (1), subtraction (2), …. And so on. The output must be something like: Enter the first integer number: 5 Enter the second integer number: 3 Which operation? 1...

  • Write an ARM program that implements a simple four-function calculator and prompts the user to enter...

    Write an ARM program that implements a simple four-function calculator and prompts the user to enter a pair of decimal integers (A and B) followed by a character that specifies one of the operators: ‘+’ for addition to compute A+B                             ‘-‘ for subtraction to compute A-B ‘*’ for multiplication to produce the product A*B ‘/’ for division to produce the quotient A/B. Input should be the pair of numbers followed by the operand followed by a return. For example...

  • 7- (50 points) Write a simple calculator in Python which supports four basic mathematical operators (1.e....

    7- (50 points) Write a simple calculator in Python which supports four basic mathematical operators (1.e. + - / *). You need to define a module which supports addition, deletion, multiplication and subtraction. Then import your module to your calculator file and use it in your code. The following example shows how your basic calculator needs to work. Select operation: 1.Add 2.Subtract 3.Multiply 4.Divide Enter your choice(1/2/3/4): 3 Enter first number: 12 Enter second number: 14 12 * 14 =...

  • PLease IN C not in C++ or JAVA, Lab3. Write a computer program in C which...

    PLease IN C not in C++ or JAVA, Lab3. Write a computer program in C which will simulate a calculator. Your calculator needs to support the five basic operations (addition, subtraction, multiplication, division and modulus) plus primality testing (natural number is prime if it has no non-trivial divisors). : Rewrite your lab 3 calculator program using functions. Each mathematical operation in the menu should be represented by a separate function. In addition to all operations your calculator had to support...

  • Assembly language.    Can u pls send me a copyable code please. If you can run...

    Assembly language.    Can u pls send me a copyable code please. If you can run it. X86. Asm.    Subject: Assembly language If you know x86 asm then only answer it Use x86 asm version send me a written code please send me with out put please send me a copyable code i promise to give you thumbs up, question: Implement a simple 4 functios calculator for 3 digits entry. The user will enter 2 digits for the first...

  • C# ONLY C# ONLY C# ONLY In this assignment you will implement the undo feature for a simple calculator. The undo feature...

    C# ONLY C# ONLY C# ONLY In this assignment you will implement the undo feature for a simple calculator. The undo feature must be implemented using a generic or template-based Stack data structure. You may utilize language supplied libraries (e.g. java.util.stack) or a stack implementation of your own design. No third-party downloads or software installs are allowed. The undo feature must allow for an unlimited number of undo operations. If the user attempts to perform an undo operation and the...

  • **This is for the C Language. Trigonometric Calculator Specification You are required to write a program...

    **This is for the C Language. Trigonometric Calculator Specification You are required to write a program that calculates and displays values of the trigonometric functions sine, cosine, and tangent for user-supplied angular values. The basic program must comply with the following specification. 1. When the program is run, it is to display a short welcome message. TRIG: the trigonometric calculator 2. The program shall display a message prompting the user to enter input from the keyboard. Please input request (h-help,...

  • program should be in c language. thank you for helping me. 1 of 4 CSCI 281...

    program should be in c language. thank you for helping me. 1 of 4 CSCI 281 LAB 5 -STACKS AND A CALCULATOR ASSIGNMENT Using 2 stacks to implement a calculator CALCULATOR 1. User input of two types. Integer values and associated tokens(+ 2. As the user needs to enter the input in the following manner: +5/17-3 9+2 8+7 You should use a looping scanf to allow the user to enter digit, then a char, then a digit, then a car...

  • Code in C++ Function Prototypes For the second part of the lab activity, you will be...

    Code in C++ Function Prototypes For the second part of the lab activity, you will be practicing writing function prototypes. Continue working on the same project from part A. First, rewrite the code so that you are using function prototypes for the functions getNumber.getMessage, and repeat. Remember that the prototypes go at the top of the file, followed by main, then the definitions of the three functions at the end. Second, you will be creating a new function (procedure) called...

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