Question: File: strrstr.s In this part, you will write a program that finds the last occurrence of the target string (called the needle) in the destination

 File: strrstr.s In this part, you will write a program thatfinds the last occurrence of the target string (called the needle) in

File: strrstr.s In this part, you will write a program that finds the last occurrence of the target string (called the needle) in the destination string called the haystack). The index of the start of the last match should be placed in lastMatch. If no match is found, then last Match should be set to -1. You may assume each string contains at least one character besides the null byte. Since the string directive is used to create the strings, there is a null byte at the end of each of them. 4 Hint #1: You can check if a character equals the null byte by seeing if that character equals the ASCII value of the null byte, i.e. 0. Hint #2: As with part #4 of the previous assignment, you should be mindful about the operand sizes and register sizes, and you may find the instruction suffixes helpful for keeping track. Below is an example of how your program should behave. $ cat input-strrstr.s #### # Inputs ### # haystack: . string "xyabcxabcycbx" needle: .string "abc" #### # Output #### assume the initial value last Match: .long -10 # don't $ head -n 3 strrstr.s . data arr: # Row 1. .long 5 2 You need not do these steps, particularly the sorting, in this specific order. I just found it easiest to describe it in this manner. 3 In ECS 34, I heavily discouraged statically allocated two-dimensional arrays, because they are a total pain to use as function arguments 5 .long 8 .long 2 long 4 . long 3 # Row 2 .long 6 .long 1 .long 9 .long 5 . long 7 # Row 3 .long 8 long 2 long 5 .long 1 . long 10 # Row 4. .long 6 long 8 long 5 .long 3 .long 4 numRows: long 4 File: strrstr.s In this part, you will write a program that finds the last occurrence of the target string (called the needle) in the destination string called the haystack). The index of the start of the last match should be placed in lastMatch. If no match is found, then last Match should be set to -1. You may assume each string contains at least one character besides the null byte. Since the string directive is used to create the strings, there is a null byte at the end of each of them. 4 Hint #1: You can check if a character equals the null byte by seeing if that character equals the ASCII value of the null byte, i.e. 0. Hint #2: As with part #4 of the previous assignment, you should be mindful about the operand sizes and register sizes, and you may find the instruction suffixes helpful for keeping track. Below is an example of how your program should behave. $ cat input-strrstr.s #### # Inputs ### # haystack: . string "xyabcxabcycbx" needle: .string "abc" #### # Output #### assume the initial value last Match: .long -10 # don't $ head -n 3 strrstr.s . data arr: # Row 1. .long 5 2 You need not do these steps, particularly the sorting, in this specific order. I just found it easiest to describe it in this manner. 3 In ECS 34, I heavily discouraged statically allocated two-dimensional arrays, because they are a total pain to use as function arguments 5 .long 8 .long 2 long 4 . long 3 # Row 2 .long 6 .long 1 .long 9 .long 5 . long 7 # Row 3 .long 8 long 2 long 5 .long 1 . long 10 # Row 4. .long 6 long 8 long 5 .long 3 .long 4 numRows: long 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!