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

1. Using SPIM, write a program that determines if an ASCII stringentered into th

ID: 3613509 • Letter: 1

Question

1. Using SPIM, write a program that determines if an ASCII stringentered into the
console is a palindrome. A palindrome is a string that is the sameforwards and
backwards. For example, the word radar is a palindrome, but theword Radar is not.
The string of ASCII characters is input into a single line on theconsole followed by a
new line (carriage return) with code like
inpt: li $v0, 8 #sys call code for read_str
syscall #read it
The read_string input command (system call code 8) reads up to n-1ASCII
characters into a buffer and terminates the string with a nullbyte. The string is left in a
buffer in memory whose address is contained in $a0 and its lengthis recorded in $a1.
Your program should determine if the string is a palindrome andthen output to the
console
The string <string> <is | is not> a palindrome
Console output is accomplished by placing the ASCII characters tobe output in memory
at the address contained in $a0 and issuing a print_string outputcommand (system
call code 4) as follows
oupt: li $v0, 4 #sys call code for print_str
syscall #print it
You may assume the input string will be no more than tencharacters. The only illegal
string character is a carriage return. [Extra credit (1 point):Modify your program so that
if a nonalpha character appears anywhere in the string, yourprogram stops and output the
value –1.]


Explanation / Answer

p