Question: Write a program in MIPS assembly language that does the following: Alphabetizes a list of small (non-capital) letters. For consistency, make the string 12-15 random
Write a program in MIPS assembly language that does the following:
Alphabetizes a list of small (non-capital) letters. For consistency, make the string 12-15 random small letters. Label the sequence String 1 in the data statements, followed by a .space directive to reserve 20 - 30 byte spaces (extra room in case you input a few extra characters, and so that you will still have a null - terminated string, since .space clears all byte spaces to 0 ).
Inputs the string from the keyboard using syscall 8 and places it in the space labeled string 1.
Alphabetizes the string using a loop and outputs the alphabetized string to the simulated console..
Removes any characters that are not small letters ( capitals, punctuation, numbers, etc. ).
Outputs the ordered letters, preceded by a statement: The alphabetized string is:
5. Program Description: Write a program that does the following: Alphabetizes a list of small (non-capital) letters. For consistency, make the string 12-15 random small letters. Label the sequence "string 1" in the data statements, followed by a 'space" directive to reserve 20-30 byte spaces (extra room in case you input a few extra characters, and so that you will still have a null-terminated string, since ".space" clears all byte spaces to 0). Inputs the string from the keyboard using syscall 8 and places it in the space labeled "string l." Alphabetizes the string using a loop and outputs the alphabetized string to the simulated console. Removes any characters that are not small letters (capitals, punctuation, numbers, etc.). Outputs the ordered letters, preceded by a statement: The alphabetized string is: 6. Comments About Program and Hint: This program can be done with a recursive loop, as demonstrated in class. However, there is an easier approach. Start by looking for a's." If there are any "a's,', store them in a new string (labeled "string 2"). Then compare to "b, c, etc. Such a loop will also let you assure that each character is a-z. If not, throw it away and do the next compare. When you get to a null, stop, since your ".space" command has assured that the string is null-terminated. Although you have to go through the input letters 26 times (a-z), the loop is so fast that this is not a problem. You can do a recursive sort/compare such as in the homework problem noted above (only going through the string of letters once, but going back-and-forth a great deal!), but the approach described above is easier to implement. 5. Program Description: Write a program that does the following: Alphabetizes a list of small (non-capital) letters. For consistency, make the string 12-15 random small letters. Label the sequence "string 1" in the data statements, followed by a 'space" directive to reserve 20-30 byte spaces (extra room in case you input a few extra characters, and so that you will still have a null-terminated string, since ".space" clears all byte spaces to 0). Inputs the string from the keyboard using syscall 8 and places it in the space labeled "string l." Alphabetizes the string using a loop and outputs the alphabetized string to the simulated console. Removes any characters that are not small letters (capitals, punctuation, numbers, etc.). Outputs the ordered letters, preceded by a statement: The alphabetized string is: 6. Comments About Program and Hint: This program can be done with a recursive loop, as demonstrated in class. However, there is an easier approach. Start by looking for a's." If there are any "a's,', store them in a new string (labeled "string 2"). Then compare to "b, c, etc. Such a loop will also let you assure that each character is a-z. If not, throw it away and do the next compare. When you get to a null, stop, since your ".space" command has assured that the string is null-terminated. Although you have to go through the input letters 26 times (a-z), the loop is so fast that this is not a problem. You can do a recursive sort/compare such as in the homework problem noted above (only going through the string of letters once, but going back-and-forth a great deal!), but the approach described above is easier to implement
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
