80.6k views
0 votes
A palindrome is a word or phrase that reads the same from left to right as right to left. A simple palindrome is "kayak," for example. Other rules are that you ignore punctuation and letter case. For example, "Madam, I’m Adam" is a palindrome despite commas, spaces, and upper and lower case differences. Palindromes can also contain digits, such as "12421".

Write a program in MIPS language that works in MARS Simulator that does the following
1. Request a string from the user. If it is zero length (the first character is ‘\\’) exit the program.
2. Determine if the string is a palindrome. If so, print "Palindrome." If not, print "Not a palindrome."
3. Return to request another string.

User Nrako
by
7.5k points

1 Answer

3 votes

Final answer:

The question asks for a MIPS assembly language program that checks if a user-input string is a palindrome, outputs the appropriate message, and then repeats the process. The program should handle zero-length inputs and ignore non-alphanumeric characters and case differences.

Step-by-step explanation:

The question relates to writing a MIPS assembly language program to determine if a given string is a palindrome. The MIPS program should prompt the user to input a string and then check if that string reads the same both forwards and backwards, ignoring punctuation, spaces, and case differences. The program should follow these steps:

  • Request a string from the user and check if the first character is '\\' to determine if the string length is zero. If so, exit the program.
  • Determine if the entered string is a palindrome. This involves comparing characters from the start and end of the string, moving towards the center, and ignoring non-alphanumeric characters and case differences.
  • Output 'Palindrome.' if the string is a palindrome, or 'Not a palindrome.' if it is not.
  • Repeat the process by returning to request another string.

Please note that creating such a program requires a good understanding of the MIPS assembly language and how to interact with I/O operations, manipulate strings, and control program flow within the MARS simulator.

User Beardo
by
7.4k points