Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an LC-3 program (starting at memory location 0x3000) that checks if a stri

ID: 3825900 • Letter: W

Question

Write an LC-3 program (starting at memory location 0x3000) that checks if a string is hte reverse of another string...

Please answer the question as stated. These are old HW questions that I'm using to review for our final, so please show all of your work. Thanks!

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. If S2 is the reverse of si, 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: abcdaa# Input: aadcba# Input: aaec# Ouput: Y Ouput: N Input: abcdaa# Input: aaecba# Ouput: N

Explanation / Answer

The program reverses the user input string. .ORIG x3000 LEA R0, MSG TRAP x22 LEA R1, FCHAR ADD R3, R1, 0 LD R2, ENT NEXT TRAP x20 TRAP x21 ADD R4, R0, R2 BRz OUTPUT STR R0, R3, 0 ADD R3, R3, 1 BRnzp NEXT OUTPUT ADD R3, R3, -1 NOT R1, R1 ADD R1, R1, 2 LEA R0, PRINT TRAP x22 LOOP ADD R4, R1, R3 BRz DONE LDR R0, R3, 0 TRAP x21 ADD R3, R3, -1 BRnzp LOOP DONE HALT MSG .STRINGZ "Please enter a string (max length 8): " PRINT .STRINGZ "Output: " ENT .FILL -10 FCHAR .BLKW 10 .END

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote