Question
Write an LC-3 program (starting at memory location 0x3000) that checks if a string is the reverse of another string. The end of the string
Write an LC-3 program (starting at memory location 0x3000) that checks if a string is the reverse of another string. The end of the string is denoted by #. Your program should take both the strings as inputs from the keyboard. If the two strings are reverse of each other, you need to print Y to the screen, else you need to print N to the screen.
In particular, your code should do the following things:
a) Read an input character from the keyboard.
b) Test if the character is #. If the character is #, you successfully read the first string
S1.
c) Start reading input character from the keyboard again.
d) Test if the character is #. If the character is #, you successfully read the second
string S2.
e) Compare the two input strings S1 and S2.
f) If S2 is the reverse of S1, display Y else display N.
NOTE: The size of the two input strings S1 and S2 can be different. If the sizes are different, S2 is clearly not the reverse of S1. You may assume the size of the input strings are always non-zero, and do not exceed 10. The output Y or N should be uppercase. Sample runs:
Input: abcdaa# Input: aadcba# Ouput: Y
Input: abcdaa# Input: aaecba# Ouput: N
***Please have your response in LC-3 computer language***
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started