Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MIPS/SPIM programming Analyzes a string of characters input from the keyboard and outputs ONLY the lower case letters in alphabetical order. The program will take

MIPS/SPIM programming

Analyzes a string of characters input from the keyboard and outputs ONLY the lower case letters in alphabetical order. The program will take only up to 17 characters regardless of the string you attempt to input. Program must ignore anything other than lower case characters in the string of 17 characters taken from the input attempted.

The input string should be labeled string 1 in the data statements with a .space directive to reserve enough bytes of memory space so that you will still have a null-terminated string, since .space clears all byte spaces to 0.

. Input the string from the keyboard using a syscall 8. They should be stored in the reserved space labeled string 1.

. Screen and alphabetize the string and output the alphabetized lowercase letters to the simulated console.

. The output of alphabetized letters is preceded by the statement: The alphabetized string is:

Before ending the program, include a prompt to ask the user if they want to run again using syscall 12. If the answer is y (for Yes), it starts over. If the answer is anything but y, the program prints Program terminated message and stops.

Comments about Program and Hint:This is an example of a program which can be done with a recursive loop, . You may use other simpler versions that do not use recursion and the stack.

One such option is to order two characters at a time when needed and re-scan the whole string after you order two characters.

Both methods above require the string to be filtered to keep only lowercase letters either before or after the ordering.

Another option is to use two nested loops. Simply start by comparing all the characters in the input string to a and if there are any a store them in a new string labeled string2 or just print them. When you get to a 0 (since your .space directive has assured that the string is null-terminated), start comparing the whole string again to b, and store any/all b then to c, ., all the way to z. Such a method will also make sure that only a-z are stored or printed.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago