I'm doing a program whose objective is to compare two values (Strings). One value is entered by the user, the other is already declared. I have trouble comparing the two strings.
I leave my code below:
Code: Select all
section .data
string1 db 'abcde' ; I want to compare this string with the one entered by the user.
msg1 db 'Input: '
msg2 db 'Good'
msg3 db 'Bad'
len1 db $-msg1
len2 db $-msg2
len3 db $-msg3
section .bss
input resb 5
section .text
global _start
_start:
; Print msg1
mov ebx,1
mov ecx,msg1
mov edx,len1
mov eax,4
int 80h
; Get input
mov ebx,0
mov ecx,input
mov edx,5
mov eax,3
int 80h
; Compare Input with string1
cmp string1,input ; HERE IS THE PROBLEM!
jz good
jmp bad
good:
; Print msg2
mov ebx,1
mov ecx,msg2
mov edx,len2
mov eax,4
int 80h
jmp exit
bad:
; Print msg3
mov ebx,1
mov ecx,msg3
mov edx,len3
mov eax,4
int 80h
exit:
mov eax,1
mov ebx,0
int 80h
Thanks you very much