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
Why is the OSI reference model useful?
sveticcg [70]
The answer to this question is B.

3 0
3 years ago
ASAP!!!!!!! 6.From Excel to PowerPoint, you can copy and paste
KIM [24]
Your answer is A.

<em>Let me know if you have any other questions! ♥</em>
4 0
3 years ago
Write a regular expression of the language havingstrings that either start or end with "00" and have nomore zeroes. Where the al
Brut [27]

Answer:

001*|1*00

Explanation:

The language consists of strings in {0,1} that either start with 00 or end with 00 and have no more zeros.

The requirement can be divided into two parts:

1) Strings that start with 00 and have no more zeros

2) Strings that end with 00 and have no more zeros

Generating regular expressions for these parts:

1) 001*  - starts with two zeros and can have zero or more 1s later

2)1*00  - starts with zero or more 1s and ends with two zeros

So on combining with the or operator(|), the overall regular expression for the strings in the language becomes:

001*|1*00

3 0
3 years ago
________(fill in the blank) in online education refer(s) to how fairly the particular needs of particular groups of students are
STatiana [176]

Answer:

Accessability

Explanation:

6 0
2 years ago
What is the output of the following code fragment? int i = 1; int sum = 0; while (i &lt;= 11) { sum = sum + i; i++; } System.out
valentina_108 [34]

Answer:

The value of sum is 66

Explanation:

i = 1

sum = 0

while (i <= 11) {  

sum = sum + i;

i++;  

}

i = 1

  • sum = sum + i
  • sum = 0 + 1
  • sum = 1

i = 2

  • sum = sum + i
  • sum = 1 + 2
  • sum = 3

i = 3

  • sum = sum + i
  • sum = 3 + 3
  • sum = 6

i = 4

  • sum = sum + i
  • sum = 6 + 4
  • sum = 10

i = 5

  • sum = sum + i
  • sum = 10 + 5
  • sum = 15

i = 6

  • sum = sum + i
  • sum = 15 + 6
  • sum = 21

i = 7

  • sum = sum + i
  • sum = 21 + 7
  • sum = 28

i = 8

  • sum = sum + i
  • sum = 28 + 8
  • sum = 36

i = 9

  • sum = sum + i
  • sum = 36 + 9
  • sum = 45

i = 10

  • sum = sum + i
  • sum = 45 + 10
  • sum = 55

i = 11

  • sum = sum + i
  • sum = 55 + 11
  • sum = 66

i = 12 --> does not comply with the condition "i < = 11", the while loop is over

7 0
3 years ago
Other questions:
  • What makes this web page look different from a web page that is not adapted for mobile
    14·1 answer
  • What is the best anime that you like the most (give me 3 plz)
    7·2 answers
  • By placing the chorale melody in the highest voice and using a simple harmonization, bach made it easier for congregation member
    5·1 answer
  • What is the purpose of exporting your public key to the directory services server?
    11·1 answer
  • Which of the following likely comes last in developing a presentation outline
    6·2 answers
  • Reading log of any book with page numbers​
    5·1 answer
  • 3.1.1 What type of goods are car radio and remote control.​
    12·1 answer
  • How are most databases organized?
    15·1 answer
  • are you in active recovery from a substance use disorder (addiction)? active recovery is defined as being free from an alcohol o
    11·1 answer
  • a data analyst is working with a spreadsheet that has very long text strings. rather than counting the characters themselves to
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!