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

Input: abcdaa# Input: aaec# Ouput: N

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 Databases Questions!