Question: Debug Help for Assembly Language X86. I am trying to create a program in visual studio to do the following. 1. Enter String to search:

Debug Help for Assembly Language X86. I am trying to create a program in visual studio to do the following.

1. Enter String to search: food

2. Enter characters to find: odx

3. Found Characters: od

Here is the code I started so far, it is compiling fine, but is only counting the second string numbers, instead of comparing both for similar letters.

include Irvine32.inc

.data

buf BYTE 101 DUP(?) ; storage buffer for the user text

match BYTE 101 DUP(?) ; storage buffer for the second user text

bufSize = LENGTHOF buf ; number of text buffer characters

matchSize = LENGTHOF match ; number of match characters

letter DWORD 0 ; How many letters

indLetter DWORD 0 ; what individual letter is on

prompt BYTE "Enter a sentence: ",0

prompt2 BYTE "Enter letters you want to find in sentence : ",0

prompt3 BYTE "letters found include: ",0

.code

main PROC

;output prompt

mov edx, OFFSET prompt

call CrLf

call WriteString

;read the user's text

;edx - pointer to string

;ecx - max numbers of characters plus one

;returns eax - numbers of char actually read

mov edx, OFFSET buf

mov ecx, SIZEOF buf

call ReadString

;output prompt 2

mov edx, OFFSET prompt2

call CrLf

call WriteString

;read the user's match text

;edx - pointer to string

;ecx - max numbers of characters plus one

;returns eax - numbers of char actually read

mov edx, OFFSET buf

mov ecx, SIZEOF buf

call ReadString

mov ecx,matchSize ; loop counter

mov edi,0

COUNT:

mov indLetter, ecx ; set which letter number it is at

call findChar ; checks for similar letters.

loop COUNT ; loops the strings checker

mov edx, OFFSET prompt3 ; print out things found

call WriteString ; writes edx to screen

call WriteDec ; writes out something???

call CrLf

call WaitMsg

exit

main ENDP

;**************************************************

findChar proc ; this is how to find similar letters in prompt and prompt2

pushad ; save all registers

mov ecx, bufSize ; loop counter

mov esi,0 ; index 0 in buffer

mov edi,0 ; index 0 in the match

mov ebx,0 ; 0 out ebx

mov ebp, indLetter ; create a pointer

mov bl, match[ebp-1] ; sets the letter to look for

L1: mov al,buf[edi] ; get first letter byte in buf

cmp match[esi],0 ; Null Byte?

jz BYE ; if yes, leave the loop

cmp match[esi], bl

jz letterMatched

inc esi ; point to next byte in buffer

inc edi ; point to next letter byte in match

mov edi,0 ; no? reset key index to 0

L2: loop L1 ; repeat the loop

BYE:

popad ; restore registers

ret

letterMatched:

inc letter ; adds to letter

inc esi ; moves the pointer

inc edi ; moves the pointer

loop L1 ; loop for the next letters

findChar ENDP

END main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!