Question: USE LC 3 This is a programming assignment that will be graded and scored as a home work since it is so simple. This one

USE LC3
This is a programming assignment that will be graded and scored as a home work since it is so simple.
This one is less simple than previous assignments
Write a subroutine for the LC3 that will stop and wait for the user to enter a single digit number from 0
to 9. The subroutine should function in a way like GETC but should not return until a digit is pressed. If
anything other than a numeric character is pressed the program should simply ignore the character.
The "MAIN" part of your program (the top lines) should look like this.
\.orig x3000
MAIN
JSR GETNUM
JSR GETNUM ;Yes, there are TWO calls to GETNUM
HALT
GETNUM waits for a digit to be pressed then returns the value of that digit in R0. So, if a 5 is pressed,
the number 5 should be stored in R0 after GETNUM returns. NOTE that this is the number 5 and not the
ASCII code for 5. You will have to convert since GETC returns ASCII codes.
Since you are running GETNUM twice from main, it means you will have to type TWO digits for the
program to finish. Only the second digit will be stored in R0 after the program ends since the second call
to GETNUM will overwrite the value of the first call.
ALL OTHER INPUTS SHOULD BE TREATED AS IF THEY DIDN'T HAPPEN.
Some examples:
If you run the program and type wxyz56, the first call to GETNUM should ignore w, x, y, and z and return
with 5 in R0. Then GETNUM will be called again and will return 6 in R0. So after your program runs, if
you type wxyz56, the number 6 should be in R0 and NOT decimal 54 or the hex value 36.
If you run the program again and type abce!!:*7ww}}{{8, the first call to GETNUM will ignore everything
up to the 7 and return with 7 in R0. Then GETNUM will be called again and will ignore the ww}}{{ and
return with the number 8 in R0.

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 Databases Questions!