Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 1084 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[FASM] Compare 2 strings

#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
Reply

#2
Not sure if you need explanation, but here is a quick one:

The code compares two strings, str1 and str2, and displays a message indicating whether they are the same or not.

The CmpStr procedure is defined at the end of the code. It takes two string arguments (str1 and str2) and compares them byte by byte. If the strings are the same, it returns a non-zero value in the eax register. If the strings are not the same, it returns a zero value in eax.

After calling CmpStr, the code checks the value in eax using the test instruction and jumps to the not_the_same label if the strings are not the same. Otherwise, it displays a message indicating that the strings are the same and exits the program.
Reply

#3
Quote:(12-12-2022, 10:15 AM)Endeavor Wrote:

[To see links please register here]

Not sure if you need explanation, but here is a quick one:

The code compares two strings, str1 and str2, and displays a message indicating whether they are the same or not.

The CmpStr procedure is defined at the end of the code. It takes two string arguments (str1 and str2) and compares them byte by byte. If the strings are the same, it returns a non-zero value in the eax register. If the strings are not the same, it returns a zero value in eax.

After calling CmpStr, the code checks the value in eax using the test instruction and jumps to the not_the_same label if the strings are not the same. Otherwise, it displays a message indicating that the strings are the same and exits the program.

Quote:If the strings are the same, it returns a non-zero value in the eax register.
The code actually returns -1 in the eax register if the strings are the same, not a non-zero value.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through