Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions