Question: OR MIPS PROGRAMMING PLEASE SOLVE Exercise 1 Write a program that prompts the user for a string. Read the string into a buffer (allocated with
OR MIPS PROGRAMMING PLEASE SOLVE
Exercise 1
Write a program that prompts the user for a string. Read the string into a buffer (allocated with a .space directive). Using the stack, reverse the string in the buffer. To reverse the string, push a NUL character (\0) onto the stack. Then set a pointer to the base of the string buffer and scan the string until you find the NUL at the end, pushing each character as you go. After you read the terminating NUL, reset your pointer to the base of the string buffer, then pop characters from the stack and copy them into the buffer until you pop the NUL byte. Print the resulting string. Remember, you load/store bytes in the string, but words on the stack.
Exercise 2 Write a program that prompts the user for a string. Read the string into a buffer. Push a NUL onto the stack. Then scan the string from right to left starting with the right-most character (this is the one just before the NUL terminator). Push each non-vowel character onto the stack. Skip over vowels. For this exercise, a vowel is one of 'a', 'e', 'i', 'o' or 'u'. You may assume all lower-case letters in the string. Now pop the stack character by character back into the buffer. Put characters back into the buffer from left to right. Stop popping, and end the string with the NUL byte you pushed first. The buffer will now contain the string, in the correct order, without vowels. Print out the final string
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
