Computers and Technology

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

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:00, king514
6. the is particularly susceptible to the effects of alcohol because it receives a large portion of total blood flow and has a high concentration of neurons. a. heart b. pancreas c. brain d. liver
Answers: 2
image
Computers and Technology, 22.06.2019 09:50, shadow29916
What is a rush associated with alcohol?
Answers: 1
image
Computers and Technology, 22.06.2019 17:00, Dweath50
1. so if i wanted to build a linux server for web services(apache) with 1cpu and 2 gb of memory.-operating at 75% of memory capacity2. a windows server with 2 cpu/ 4gb memory- operating at 85% of memory capacity3. a storage server with 1 cpu/ 2gb memory- operating at 85% of memory capacityhow much memory do i have to add for each server. so that the utilization rate for both cpu and memory is at a baseline of 60%."the details for the cpu like its processor or the memory's speed isnt to be concerned" yeah i kept asking my teacher if he's even sure about the but the whole class seems to be confused and the project is due in 3 days..this is a virtualization project where i have to virtualize a typical server into an exsi hypervisor.
Answers: 2
image
Computers and Technology, 22.06.2019 21:30, Nathaliasmiles
The graph shows median weekly earnings for full-time workers according to education level. which can you not conclude?
Answers: 2
Do you know the correct answer?
Description: Write a procedure named Str_find that searches for the
first matching occurrence...

Questions in other subjects:

Konu
History, 05.12.2020 09:00
Konu
Mathematics, 05.12.2020 09:00
Konu
Social Studies, 05.12.2020 09:00
Konu
Mathematics, 05.12.2020 09:00