Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a design document, outline the design and implementation strategy for an assembly pro - cedure called strstr that searches for a string within a

In a design document, outline the design and implementation strategy for an assembly pro-
cedure called strstr that searches for a string within a string. The procedure takes as its
two parameters the addresses of two (null-terminated) strings. If a sequence of characters in
the first string matches the entire second string, the procedure returns the starting index of
that sequence. If no sequence of characters in the first string matches the second string, the
procedure returns -1. Your procedure should also handle empty strings correctly. If either
string is empty, the procedure should return -1.
Write, and test using QEMU, the RISC-V assembly procedure strstr. Also, write a main
program to test your procedure. The program should prompt the user to input two strings
(you can assume that the strings will be at most 40 characters each, not including the zero
byte delimiter), call the function, display the result of the function, and finally terminate.
Your code must use the standard conventions covered in class for passing
parameters, returning results, and using the stack.
Question 7[14 points]
In a design document, outline the design and implementation strategy for a recursive as-
sembly procedure called fact(n) that computes the factorial of any number n, and a main
program to test it. The procedure should take as its single parameter the nonnegative integer
n.
f act(0)=1
f act(1)=1
f act(n)= n f act(n 1)
Write, and test using QEMU, the RISC-V assembly procedure fact(n). Also, write a
main program to test your procedure. The program should prompt the user to enter the
number n, then display the result of fact(n), and finally terminate. Your code must use
3

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

1. Identify the sources for this conflict.

Answered: 1 week ago

Question

3. The group answers the questions.

Answered: 1 week ago