1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vinvika [58]
3 years ago
8

Write a procedure named Str_find that searches for the first matching occurrence of a source string inside a target string and r

eturns 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 and EAX is undefined.
Computers and Technology
1 answer:
kirill115 [55]3 years ago
6 0

Answer: Provided in the explanation section

Explanation:

Str_find PROTO, pTarget:PTR BYTE, pSource:PTR BYTE

.data

target BYTE "01ABAAAAAABABCC45ABC9012",0

source BYTE "AAABA",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

stop DWORD ?

lenTarget DWORD ?

lenSource DWORD ?

position DWORD ?

.code

main PROC

  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

; Compare source string to current target

  cld

  mov ecx,lenSource    ; length of source string

L1:

  pushad

  repe cmpsb           ; compare all bytes

  popad

  je found           ; if found, exit now

  inc edi               ; move to next target position

  cmp edi,stop           ; has EDI reached stop position?

  jae notfound           ; yes: exit

  jmp L1               ; not: continue loop

notfound:                   ; string not found

  or eax,1           ; ZF=0 indicates failure

  jmp done

found:                   ; string found

  mov eax,edi           ; compute position in target of find

  sub eax,pTarget

  cmp eax,eax    ; ZF=1 indicates success

done:

  ret

Str_find ENDP

END main

cheers i hoped this helped !!

You might be interested in
1. Of Facebook, Twitter, and LinkedIn, which do you think is the best platform for marketing your personal brand? Explain.
lord [1]
Facebook cuz a lot more people on Facebook to see your personal brand
3 0
3 years ago
What website or search engine that helps people find the web pages that they are looking for by tying in the subject they want?​
Effectus [21]

Amazon can be use to search

4 0
3 years ago
Jeson will download a file of 10 MB, he has internet plans of 10 Mbps speed. How much total time does Jeson require to download
kondaur [170]

Answer:

8 seconds

Explanation:

8 Mbps (Megabit / sec) = 1 MBps (Megabyte / sec)

Therefore 10 Mbps = 1.25 MBps

Now divide the file 10MB by his download speed of 10Mbps (which is 1.25 MBps) and you can get 8 seconds.

8 0
3 years ago
Please create a brute force password cracker using python
serg [7]

Answer:

0

2

I need to make small programs for school to brute force crack different types of passwords; I'm looking to create a brute force python code that will run through every possible combination of alphabetical and alphanumerical passwords and give me the password and the amount of time it took to crack.

I did the same with purely numerical passwords and got this:

import datetime as dt

Password4 = 123456

def crack_password():

   start = dt.datetime.now()

   for n in range(1000000):

       password_guess = '{0:04d}'.format(n)

            if password_guess == str(Password4):

               end = dt.datetime.now()

               print("Password found: {} in {}".format(password_guess, end - start))

              break

   guesses = crack_password()

I then tried to do something somewhat similar for alphabet/alphanumerical passwords but did not work whatever I tried:

   import random

   letters = [str(i) for i in range('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p')]

   s = [''.join([a,b,c,d,e,f,g,h]) for a in letters for b in letters for c   in letters for d in letters for e in letters for f in letters for g in letters  for h in letters]

   random.shuffle(s)

   real_password = 'aaaaaaaa'

   i = 0

Explanation:

8 0
3 years ago
When you respond to an e-mail message, a good skill to develop is ___________-editing, which involves inserting your responses t
Drupady [299]

Answer: Down editing

Explanation:

Down editing is a method of replying emails which allows you to respond point by point to an email. It add certainty, precision and quality to your response and helps prevent misunderstanding of email response.

7 0
3 years ago
Other questions:
  • Changing the position of the wing will
    9·1 answer
  • Which single OSPF network statement will correctly include all the interfaces on a device whose IP addresses only begin with a 1
    12·1 answer
  • 5. Question<br> The control flag that isn't really in use by modern networks is the<br> flag.
    15·1 answer
  • What is the default text-wrapping option when inserting images into a Word document?
    5·2 answers
  • __________ contain(s) remnants of word processing documents, e-mails, Internet browsing activity, database entries, and almost a
    9·1 answer
  • A final class can't be extended.TrueFalse
    5·1 answer
  • If you weigh 100 pounds, and your 150 pound big sister is sitting 15 feet from the fulcrum of a seesaw, how far from the fulcrum
    15·1 answer
  • The auxiliary device used to store large volume of data and program for future is called​
    10·1 answer
  • ASAP! WILL MARK BRAINLIEST + 100 POINTS!!<br><br> Match each word to its description.
    11·2 answers
  • A _______________ is a particular type of network that uses circuits that run over the Internet but that appears to the user to
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!