Question: Low Level Breakdown This assignment comprises five tasks: 1 . Prompt the user, and read two numeric characters ( ' 0 ' . . .

Low Level Breakdown
This assignment comprises five tasks:
1. Prompt the user, and read two numeric characters ('0'...'9') from the user using Trap x20
(GETC). Echo the characters to the console as they are received (OUT), and store them as
character data in separate registers.
2. Output to the console the operation being performed e.g.
5-7=
(how will you print the "-"? How will you print the "="? Note the double quotes!!)
3. Once the setup is printed, convert the numeric characters into the actual numbers they
represent (e.g. convert the ASCII code for 7 into the binary representation of the number 7).
4. Perform the subtraction operation (by taking the two's complement of the second operand and
adding), and determine the sign (+/-) of the result;
if it is negative, determine the magnitude of the result (i.e. take the 2's complement to turn it
back into a positive number).
5. Convert the resulting number back to a printable character and output it, together with a minus
sign if necessary. Remember, the number -4 when converted to text is actually two separate
ascii characters, '-' and '4'.
Example, with a detailed algorithm (we won't always give you this!)
Program prompts for user input (two characters):
user enters 5, which is echoed to console (followed by a newline) and copied to a register.
user enters 7, which is echoed to console (followed by a newline) and copied to a different
register.
Program outputs the text
5-7=
(this will actually require at least 4 distinct output steps using OUT and PUTS)
Program converts 5(ascii code) into 5(number) and stores it back in the same register.
Program converts 7 into 7 and stores it back in the same register.
Program takes 2's complement of 7, and stores the result back into the same register.
Program adds the contents of the two registers - i.e. it performs the operation (5-7) and stores
the result (-2) in a third register.
Program recognizes that the result is negative, obtains the magnitude of -2(=2), and outputs '-'
(minus sign).
Program converts 2(number) into '2'(ascii code), and stores it back in the same register.
Program outputs '2' followed by a newline.
Expected/ Sample output
In this assignment, your output must exactly match the following, including:
the prompt, followed by newline (provided in the starter code)
Each digit input "echoed" and followed by a newline
the subtraction operation, including spaces as shown, also followed by a newline:
(Difference is Positive)
(Difference is Zero)
(Difference is Negative)
Your code will obviously be tested with a range of different operands giving all possible results.
Make sure you test your code likewise!
NOTES:
All console output must be NEWLINE terminated.
We will test only with positive single digit numeric inputs
NO error message is needed for invalid input (i.e. we will not test with non-numeric inputs)Console (click to focus)
x
(Difference is Positive)
Console (click to focus)
x
ENTER two numbers (1.e '0',..'9')6
6
6-6=0
--- Halting the LC-3--I
(Difference is Zero)
Console (click to focus)
ENTER two numbers (i,e 10'dots..9')
2
7
2-7--5
--- Halting the LC-3
Low Level Breakdown This assignment comprises

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!