Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specifically, translate the following C procedure into MIPS Assembly. You are required to follow the conventional use for registers such as temporary vs. saved registers,

image text in transcribed

Specifically, translate the following C procedure into MIPS Assembly. You are required to follow the conventional use for registers such as temporary vs. saved registers, maintaining procedure call stacks, proper parameter passing and returns, etc. Note that this procedure calls another (strchr) which is assumed to also comply with those conventio ns char firstmatch (char *s1, char *s2) *find the first character in string sl that is also in s2 */ char *temp temp sl; do if (strchr( s2, *temp)H0) *if this character is there */ return temp return where we found it* temp++; else look again while (temp!0); return 0 found none of these chars* char * strchr (register const char *s, int c) if (sc return (char )s while (s++); return (0): These are additional instructions to complete this lab assignment. . The program should consist of two segments: .data and .text segments. .Define two strings, strl and str2, in the data segment. . Use lb (load byte) as you manipulate strings not integers The code segment, labeled as .text", should begin with main." because the MARS simulator begins the execution from there In the main code, you should start with load addresses of the defined strl and str2. You need to write two procedures, firstmatch and strchr, in the code segment, each is labeled as the procedure name. After loading string addresses, you pass both strings to firstmatch as in the above C code. Within the firstmatch procedure, you need to call the strchr procedure . . . . Specifically, translate the following C procedure into MIPS Assembly. You are required to follow the conventional use for registers such as temporary vs. saved registers, maintaining procedure call stacks, proper parameter passing and returns, etc. Note that this procedure calls another (strchr) which is assumed to also comply with those conventio ns char firstmatch (char *s1, char *s2) *find the first character in string sl that is also in s2 */ char *temp temp sl; do if (strchr( s2, *temp)H0) *if this character is there */ return temp return where we found it* temp++; else look again while (temp!0); return 0 found none of these chars* char * strchr (register const char *s, int c) if (sc return (char )s while (s++); return (0): These are additional instructions to complete this lab assignment. . The program should consist of two segments: .data and .text segments. .Define two strings, strl and str2, in the data segment. . Use lb (load byte) as you manipulate strings not integers The code segment, labeled as .text", should begin with main." because the MARS simulator begins the execution from there In the main code, you should start with load addresses of the defined strl and str2. You need to write two procedures, firstmatch and strchr, in the code segment, each is labeled as the procedure name. After loading string addresses, you pass both strings to firstmatch as in the above C code. Within the firstmatch procedure, you need to call the strchr procedure

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

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions