So, I'm fairly new to assemlby. My task is to check for a substring in a string and print out yes/no answer. Both strings are put in by the user.
I have put offset of the string into bx register, offset of the substring into bp register. Using index numbers in di and si registers, I want to compare characters of my strings. Both of my index registers are set to 2, which should be the first character of the string.
mov dl,[bx+di]
mov al,[bp+si]
cmp dl,al
jz AnswerYes
jmp AnswerNo
I used this to compare first characters in each string.
When I put 'a' in both string, the program should jump to AnswerYes and print out 'yes'. When I print [bx+di] and [bp+si], it prints out 'a' for both of them, which means they are the same, but the program always jumps to AnswerNo.
If I do this:
cmp dl,'a'
it prints our yes, meaning they are the same.
When I do this:
cmp al,'a'
it prints out no, even though they are the same.
I suspect the problem is with me using bp register, since I've never used it before. I always used only one string in my program, for which I always used bx register.
Thanks for help in advance.