I need help debuging my code. Basically it compares str1 with str2. If str1 is equal to str2 it prints on screen "Good". If they are not equal it prints "Bad".
My problem is that the result I get when 2 strings are equal is:
Good
Bad
abcdeabcde
And when they are diferent:
Bad
abcdeabbde
Here I leave my code:
Code: Select all
section .data
msg1: db 'Good',10 ; msg1
msg2: db 'Bad',10 ; msg2
str1: db 'abcde' ; str1
str2: db 'abcde' ; str2
lenmsg1: equ $-msg1 ; length msg1
lenmsg2: equ $-msg2 ; length msg2
lenstr1: equ $-str1 ; length str1
lenstr2: equ $-str2 ; length str2
section .text
global _start
_start:
mov esi,str1
mov edi,str2
mov ecx,lenstr2
cld
repe cmpsb
jecxz good
; If bad
mov eax,4
mov ebx,1
mov ecx,msg2
mov edx,lenmsg2
int 80h
jmp exit
good:
mov eax,4
mov ebx,1
mov ecx,msg1
mov edx,lenmsg1
int 80h
exit:
mov eax,1
mov ebx,0
int 80h