[FASM] Compare 2 strings 09-15-2022, 04:14 PM
#1
Code:
include 'win32ax.inc'
str1 db '1111111111',0
str2 db '1111111112',0
start:
stdcall CmpStr,str1,str2
test eax,eax
jz not_the_same
invoke MessageBox,0,'Both strings are alike!!','FASM',MB_OK
jmp exit
not_the_same:
invoke MessageBox,0,'Both strings are Wrong','FASM',MB_OK
exit:invoke ExitProcess,0
proc CmpStr uses esi edi ecx,str1,str2; returns 0 when strings are not the same.
cld
mov ecx,0ah
mov esi,[str1]
mov edi,[str2]
repe cmpsb
jnz @f
mov eax,-1
ret
@@:
xor eax
include 'win32ax.inc'
str1 db '1111111111',0
str2 db '1111111112',0
start:
stdcall CmpStr,str1,str2
test eax,eax
jz not_the_same
invoke MessageBox,0,'Both strings are alike!!','FASM',MB_OK
jmp exit
not_the_same:
invoke MessageBox,0,'Both strings are Wrong','FASM',MB_OK
exit:invoke ExitProcess,0
proc CmpStr uses esi edi ecx,str1,str2; returns 0 when strings are not the same.
cld
mov ecx,0ah
mov esi,[str1]
mov edi,[str2]
repe cmpsb
jnz @f
mov eax,-1
ret
@@:
xor eax