Question: Perform these steps using LC - 3 assembly that does not reference the run time stack. Learning Subroutines Programming Lab # 3 CEG 3 3

Perform these steps using LC-3 assembly that does not reference the run time stack. Learning Subroutines
Programming Lab #3
CEG 3310/5310: Computer Organization
PURPOSE
The average computer scientist programs in assembly very rarely. However, some familiarity with assembly level
programming is necessary to develop the fundamental understanding of how high-level programs get executed (which
itself is necessary to understand high-end performance issues). Subroutines are one of the most important fundamental
assembly language concepts.
ASSIGNMENT
In this lab you will create a simple calculator program. Calculator programs are common in higher level language
programming courses but implementing them in assembly is not so simple.
To create this calculator program you will have to implement 4 subroutines:
1. GETNUM
a. Captures a positive two digit (0-99) number from the keyboard
2. GETOP
a. Captures an operation from the keyboard (+,-, or *)
3. CALC
a. Calculates the correct mathematical result when provided two positive two digit numbers and an
operation
4. DISPLAY
a. Displays up to a 4 digit positive or negative number
In the main program loop, the program will prompt the user to enter the first number. After the user enters their first
number, the program will prompt the user for an operation (+,-,*). Lastly, the program will prompt the user for the
second number. Using the first number, operation, and second number, the calculator program will display the
mathematical result. Once the output is displayed, the program will loop endlessly to allow the user to enter in more
combinations of numbers and operations.
For the subroutines in your program, use registers to take inputs and provide outputs. Do not implement a runtime stack
for this lab. As an example, the CALC subroutine could receive the first number on R0, the second number on R1, the
operation on R2, and output the final result on R0.
A sample program is provided to get you started.
The following is an example output of the program:
Enter first number (0-99): 5
Enter an operation (+,-,*): -
Enter second number (0-99): 23
Result: -18
Enter first number (0-99): 75
Enter an operation (+,-,*): *
Enter second number (0-99): 49
Result: 3675
Enter first number (0-99): 50
Enter an operation (+,-,*): +
Enter second number (0-99): 70
Result: 120

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!