Problem 3. Write a LC-3 program. In this problem, you will need to write a progr
ID: 3573306 • Letter: P
Question
Problem 3. Write a LC-3 program.
In this problem, you will need to write a program for reversing a string input from the keyboard, and then output the reversed string. The string end is denoted by the character '#'. You will need to do the following things. Read an input character from the keyboard. Test if the character is '#'. If the character is '#', then stop reading characters. Store the string input from the keyboard into the memory (such as starting at times 4000) Reverse the order of the string. The reversed string could still be in the same memory(times 4000) location or could be in another memory location (times 5000). Display the reversed string. An example run of the program is as follows: Input: 'Hello#' Output: 'olleH' For this problem, you will write a program that continuously takes single characters from the keyboard as input and outputs a character to the monitor depending on their case. It will use a subroutine called CheckCase to perform this operation. You must implement a subroutine or you will not receive credit for your answer! Your program should do the following:Explanation / Answer
.ORIG x3000 LEA R0, STRINGS ; Load the address of the first char of the list of strings Loop until # is found, signaling end of the string. LEA R1, the address above ; stores the address of the last char LDR R2, #0 Offset +1 ; load the first char to be flipped, Check if # or not LDR R3, #0 Offset +2 ; load the last char to be flipped, Check if # or not STR R3, #0 Offset +1 ; store the last char in the mem addr of the first STR R2, #0 Offset +2 ; store the first char in the addr of the last ADD R1, R1 + 1 ; increment the addr of the first char to move to the second ADD R2, R2 - 1 ; decrement the addr of the last char the move the second-to-last loop back to beginning somehow
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.