Write an LC-3 assembly language program that converts a value represented in ASC
ID: 3621040 • Letter: W
Question
Write an LC-3 assembly language program that converts a value represented in ASCII
into its appropriate binary value. Your program should output a few appropriate
words to prompt the user to enter a non-negative decimal value followed by a carriage
return. For example, you could have your program print, Please enter a non-negative
number followed by the enter key." After reading the ASCII characters the user enters,
convert the value it represents to its corresponding binary value and store the result
in R1. For example, if the user typed '4058' at the keyboard (ie., the ASCII character
for 4, followed by the ASCII character for 0, followed by the ASCII character for 5,
followed by the ASCII character for 8, followed by the carriage return), the hex value
stored in R1 should be x0FDA.
Note that the user could enter any number of characters with the end of the input
signified with a carriage return. However, you need to store only 16 bits of the final
value.
Hint: Figure 10.19 in the textbook shows an ASCII-to-binary conversion program
limited to three digits that uses look-up tables. This program may give you some
ideas on how to get started. Since you must accept an arbitrary number of input
characters, your program must do the conversion without using any look-up tables,
though.
Explanation / Answer
Steps for convert ASCII to binary equivalent: 1. Save contents of all registers 2. Make binary result = 0; 3. subtract 30H from the character typed on the keyboard to convert it to BCD 4. multiply the results by 10 and then add the BCD digit. 5. repeat the steps 2 & 3 until the character typed is not an ASCII codded number 6. Restore register contents. I hope this will helps to You !
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.