Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function in MIPS assembly language that determines whether parentheses in a character string are valid. The following six characters are considered as parentheses:
Write a function in MIPS assembly language that determines whether parentheses in a character string are valid.
The following six characters are considered as parentheses:
A character string 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, then call the implemented function, and lastly 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 the following result in the attached imageString:
Parentesis validos.
program is finished running
String:
Parentesis invalidos.
program is finished running
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started