Create the following program using the LC-3 assembly language : The main body of
ID: 3902431 • Letter: C
Question
Create the following program using the LC-3 assembly language:
The main body of your program should do the following: Print your class template Ask the user to input a number 0-9 (echo to screen) Print the number spelled out Print an error message if an incorrect input Repeat until a (x21) is input Print out Done message HALT the program Your screen should look like this when the program runs: CS Student Name Project Input a number 0-9: 5 five Input a number 0-9: 0 zero Input a number 0-9: X Error! You did not input a number. Input a number 0-9:! Done! Assemble your program and experiment with the simulator to confirm that your program is working properly. Check all the boundary cases to make sure all characters work properlyExplanation / Answer
This code will work only till 2. Modify as per your need.
.orig 0x3000
ONE .STRINGZ "One"
TWO .STRINGZ "Two"
THREE .STRINGZ "Three'
// take input in R2
GETC ;
ADD R3 , R0 , x0 ; Copy R0 into R3
ADD R3 , R3 , #?16 ; Subtract 48 , the ASCII value of 0
ADD R3 , R3 , #?16
ADD R3 , R3 , #?16 ; R3 now contains the actual value
ADD R2, R3, 0x; move original to R2
ADD R5, R5, #1
NOT R4, R5
ADD R4, R4, #1 ; R4 = -R5
ADD R5, R2, R4; R5 = R3 - 1
BRz print_one
ADD R5, R5, #2
NOT R4, R5
ADD R4, R4, #1 ; R4 = -R5
ADD R5, R2, R4; R5 = R3 - 1
BRz print_two
print_one LEA R0 , ONE ;
PUTS
print_two LEA R0 , TWO ;
PUTS
HALT
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.