Question: Write a function in MIPS assembly language that determines whether parentheses in a character string are valid. The following six characters are considered parentheses: (
Write a function in MIPS assembly language that determines whether parentheses in a character string are valid.
The following six characters are considered parentheses:
A string of characters with valid parentheses does the following:
Every opening parenthesis must be closed with the same type of parenthesis.
Open parentheses must be closed in the correct order.
Every closing parenthesis has a corresponding opening parenthesis.
Function specification
The function interface has these inputs and outputs:
Entry: $a the memory address of an ASCIIZ character array.
Output: $v the validation result; if the parentheses are valid, if not.
Write a main program in which you print the string of characters, then make the call to the implemented function, and finally print valid parentheses or invalid parentheses depending on the return value of the function.
Suggestion. Remember that the stack is a LIFO Last In First Out type structure. Consider how you can take advantage of this property to simplify the validations you must do with each pair of opening and closing parentheses.
An example of what should be seen in the terminal is in the first attached image.
In the second attached image are the pseudo instructions which cannot be used in the code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
