dusty97 0 Newbie Poster

Hello-

I'm currently working on a little assembly program that is meant to take in string A, then string B, and check string B to see if it contains string A. I figured out how to make it search for a single character, but i'm having difficulties in searching for a string. I've thought of approaching this by making a loop to where it looks for a match for the first char in string A in string B, but I'm not sure how to split up the chars of the string to run the loops.

This is my code for searching through for the single char.

;read the string and check for the char
Begin: call ReadChar
	cmp al, 0dh
	je Nope
	cmp al, value
	je Yup
	call WriteChar
	jmp Begin
		
Yup: call Crlf
	call WriteChar
	call Crlf
	mov edx, OFFSET yes
	call WriteString
	exit

Nope: call Crlf
	mov edx, OFFSET no
	call WriteString	
	exit

Here is my code as I've modified it so far to look for string A in string B

; read the pattern
	mov edx, OFFSET buffer
	mov ecx, SIZEOF buffer
	call ReadString
	mov byteCount, eax
	mov pattern, edx
	
	; print prompt2
	mov edx, OFFSET prompt2
	call WriteString
	
	; read the string
	mov edx, OFFSET buffer
	mov ecx, SIZEOF buffer
	call ReadString
	mov byteCount, eax
	mov string, edx
	
Check:
	mov edi, OFFSET string
	mov eax, pattern
	mov ecx, LENGTHOF string
	cld
	repne scasb
	jnz Nope
	dec edi
		
Yup: call Crlf
	call WriteChar
	call Crlf
	mov edx, OFFSET yes
	call WriteString
	exit

Nope: call Crlf
	mov edx, OFFSET no
	call WriteString	
	exit

Does anyone have any tips as to where I would go from here? Basically right now the 2nd code set is just running through the repne scasb line without doing anything and returning the Yup: statement.

Any tips would be greatly appreciated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.