subject

Description: Write a procedure named Str_find that searches for the
first matching occurrence of a source string inside a target string
and returns the matching position. The input parameters should be a
pointer to the source string and a pointer to the target string. If
a match is found, the procedure sets the Zero flag and EAX points to
the matching position in the target string. Otherwise, the Zero
flag is clear.
TODO: Complte Str_find PROC
!
INCLUDE Irvine32.inc
Str_find PROTO, pTarget:PTR BYTE, pSource:PTR BYTE
.data
promptTargetStr BYTE "Enter target string: ",0
promptSourceStr BYTE "Enter source string: ",0
str1 BYTE "Source string found at position ",0
str2 BYTE " in Target string (counting from zero).",0Ah,0Ah,0Dh,0
str3 BYTE "Unable to find Source string in Target string.",0Ah,0Ah,0Dh,0
MAX = 80 ;max chars to read
target BYTE MAX+1 DUP (?)
source BYTE MAX+1 DUP (?)
stop DWORD ?
lenTarget DWORD ?
lenSource DWORD ?
position DWORD ?
.code
main PROC
; prompt input target string
mov edx, OFFSET promptTargetStr
call WriteString
mov edx, OFFSET target
mov ecx, MAX ;buffer size - 1
call ReadString
call Crlf
; prompt input source string
mov edx, OFFSET promptSourceStr
call WriteString
mov edx, OFFSET source
mov ecx, MAX ;buffer size - 1
call ReadString
call Crlf
INVOKE Str_find, ADDR target, ADDR source
mov position, eax
jz wasfound ; ZF=1 indicates string found
mov edx, OFFSET str3 ; string not found
call WriteString
jmp quit
wasfound: ; display message
mov edx, OFFSET str1
call WriteString
mov eax, position ; write position value
call WriteDec
mov edx, OFFSET str2
call WriteString
quit:
exit
main ENDP
;
Str_find PROC, pTarget:PTR BYTE, ;PTR to Target string
pSource:PTR BYTE ;PTR to Source string
;
; Searches for the first matching occurrence of a source
; string inside a target string.
; Receives: pointer to the source string and a pointer
; to the target string.
; Returns: If a match is found, ZF=1 and EAX points to
; the offset of the match in the target string.
; IF ZF=0, no match was found.
;
INVOKE Str_length, pTarget ; get length of target
mov lenTarget, eax
INVOKE Str_length, pSource ; get length of source
mov lenSource, eax
mov edi, OFFSET target ; point to target
mov esi, OFFSET source ; point to source
; Compute place in target to stop search
mov eax, edi ; stop = (offset target)
add eax, lenTarget ; + (length of target)
sub eax, lenSource ; - (length of source)
inc eax ; + 1
mov stop, eax ; save the stopping position
; TODO: Compare source string to current target
ret
Str_find ENDP
END main

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:30
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 2
question
Computers and Technology, 22.06.2019 22:20
Avariable of the data type arrays is storing 10 quantities. what is true about these quantities? a. the quantities all have different characteristics. b. the quantities all have the same characteristics. c. five quantities have the same and five have different characteristics. d. it is necessary for all quantities to be integers. e. it is necessary for all quantities to be characters.
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Choose the answers that best complete each sentence. on average,are more expensive than other kinds of postsecondary schools. the cost of room and board includes. to save money, some students attend auniversity in their home state.
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
Now you’re on your own. include a short summary of this section with plots in your lab report. write a matlab script file to do steps (a) through (d) below. include a listing of the script file with your report. 1 the soundsc(xx,fs) function requires two arguments: the first one (xx) contains the vector of data to be played, the second argument (fs) is the sampling rate for playing the samples. in addition, soundsc(xx,fs) does automatic scaling and then calls sound(xx,fs) to actually play the signal. mcclellan, schafer, and yoder, dsp first, 2e, isbn 0-13-065562-7. prentice hall, upper saddle river, nj 07458. c 2015 pearson education, inc. 4 mcclellan, schafer and yoder, signal processing first. prentice hall, upper saddle river, new jersey, 2003. c 2003 prentice hall. (a) generate a time vector (tt) to cover a range of t that will exhibit approximately two cycles of the 4000 hz sinusoids defined in the next part, part (b). use a definition for tt similar to part 2.2(d). if we use t to denote the period of the sinusoids, define the starting time of the vector tt to be equal to t , and the ending time as ct . then the two cycles will include t d 0. finally, make sure that you have at least 25 samples per period of the sinusoidal wave. in other words, when you use the colon operator to define the time vector, make the increment small enough to generate 25 samples per period. (b) generate two 4000 hz sinusoids with arbitrary amplitude and time-shift. x1.t / d a1 cos.2
Answers: 1
You know the right answer?
Description: Write a procedure named Str_find that searches for the
first matching occurrence...
Questions
question
English, 18.03.2021 03:30
question
Mathematics, 18.03.2021 03:30
question
Mathematics, 18.03.2021 03:30
question
Social Studies, 18.03.2021 03:30
question
Mathematics, 18.03.2021 03:30
question
Mathematics, 18.03.2021 03:30
Questions on the website: 13722367