I only started to program in assembly is a couple of days and I got stuck trying to make to compare two strings. This is what I tried:
//snip,snip
.data
password db "password",0
//snip,snip
invoke GetDlgItemText,hWnd,IDC_EDIT,ADDR buffer,512
mov eax,
mov edx,
test eax,edx
.IF ZERO?
invoke MessageBox,NULL,ADDR right,ADDR right,MB_OK
.else
invoke MessageBox,NULL,ADDR wrong,ADDR wrong,MB_OK
.endif
//snip,snip
Since I am a extreme newbie can anyone tell me the proper way to compare two strings?
Posted on 2002-01-13 10:13:53 by neetocin
Take a look at 'lstrcmp API:


invoke lstrcmp, addr szCmdBuffer, addr szll
.if eax == 0 ; equal?
call ListLong
jmp @B
.endif
Posted on 2002-01-13 10:28:22 by bazik
By doing what you've written : mov eax, ,
you just put 4 caracters in eax. If you enter 'password', you get in eax : 73736170h. If you don't want to use api, you can make your own macro comparing caracter by caracter, but you can nevertheless use the api function described above.

PS:Am I right if I say 'caracter', I don't remember if it's the right word (I'm French). (I thought that was character, but it shouldn't)
Posted on 2002-01-13 14:32:11 by Vom-bonjour:-()
Hi Vm-bonjour ;)
i think it's character (and I'm french too ;) )
For the comp of the string here is an example:

mov Res,1
Again:
mov al,byte ptr
cmp al,byte ptr
je Continue
mov Result,0
Continue:
inc ecx
cmp ecx,Length the biggest number
jne Again

This piece of code give 1 if the string are the same
and 0 if there are different,
For the Length of the biggest:
You could use something like:
mov eax,Length1
cmp eax,dword ptr Length2
jl Second
Mov LengthOfTheBiggest,eax
jmp EndLength
Second:
mov eax,Length2
mov LengthOfTheBiggest,eax
End:

I don't know if all of these lines are good
because i'm writing them now,without testing but
I'm think everything should run ;)
Farad77
Posted on 2002-01-13 14:59:26 by Farad77
I made a mistake (only one??)
In the first line:Res=Result of course


Farad77:stupid:
Posted on 2002-01-13 15:03:16 by Farad77
Great!, welcome to you Farad77. Pas mal le pseudo !, tu aurais pu prendre Celcius35, a moins qu'en reunion vous utilisez le Farad, ou a moins que ca n'a rien a voir.
Yeah, I think this code should work.
We could also use loop, but I don't the one faster. But I must work.
Posted on 2002-01-13 16:55:26 by Vom-bonjour:-()
Thanks all of you!

I chose to stick with the API because I am a extreme newbie.
The reason I created the program is to upload to the school computer and lock out Minesweeper from everyone except me (and to impress people).

The program is basically a hacked Icezlion tutorial 10 - 2 with some merging from tutorial 14. I think this is pretty good for some who started programming in assembly for 2 days ;)

Finally, I chose assembly instead of C/C++ because it produced extremely tight program code. A teacher comes in frequently to monitor us and uploading a C/C++ program will take too long.
Posted on 2002-01-13 18:13:55 by neetocin
Another good reason to use Assembly language... :grin:
Posted on 2002-01-13 19:24:24 by S/390

Finally, I chose assembly instead of C/C++ because it produced extremely tight program code.

If you know what you're doing, C/C++ can produce just as tight
program code as assembly. Well, almost, and so little it doesn't
really matter :).

Btw, I think your application sounds a little fishy... don't do anything
too naughty, mmm'kay?
Posted on 2002-01-14 05:51:43 by f0dder
f)dder

If you know what you're doing, C/C++ can produce just as tight
program code as assembly. Well, almost, and so little it doesn't
really matter


Make that if you use C, or use C++ as if you are using C. You could get something that is very near assembly.

classes and heritance have their performance hits. So avoid them is performance is an issue.

also operator overloading can be a performance drain on some compilers. (because the need to copy from a temporary structure).

However strong type cheking and inline functions are features that makes C++ much better than C, even if you opt to use C++ as C.
Posted on 2002-01-14 18:51:20 by dxantos
Yep, you're right dxantos. Properly designed (and I do mean carefully
designed) C++ classes can be okay as well (as long as you perhaps
violate a few of the "good principles" of OOP). After all, if your C/Asm
code would "push structure / call function", you might as well write
it in (careful) C++. Operator overloading can be annoying though.
Posted on 2002-01-15 05:29:15 by f0dder
Just keep up the good work neetocin but don't get yourself into trouble at school. :) Assembler can be a lot of fun when you get the swing of it.

Regards,

hutch@movsd.com
Posted on 2002-01-15 05:39:13 by hutch--
If you know what you're doing, C/C++ can produce just as tight

Yes, I've heard that blind people with proper traning can move almost as well as normal :)
Posted on 2002-01-15 05:42:49 by The Svin