I am sorry that i have posted quite a few questions for the past 2 weeks but i went straight to hell doing that time to only find out that i need to find an new way to compare strings WITH-OUT the use of ECX for a while... I need to preserve ECX for latter use and knowing how to do this will be a great thing and it is The SOLUTION to my problem.

Do anyone know how to translate one or both of the code below to use EAX or EDX EAX or EDX as the counter so that it don't have to use ECX.

Also if someone know how to do it using a (.data?) BYTE Buffer as a counter could you please post it. I know it may be slow but it may find use somewhere someday...

Also do anyone have leads to previous post about the subject... I need to stick with the traditional registers.

I can't say this question is the most important one to me but NOW it is. This will be my last question for quite a WEEK :)


mov esi, offset CompareBrowser1
mov edi, offset CompareBrowser2
mov al,
mov ah,
inc esi
inc edi
cmp al, ah
jne _notfound_s1
cmp al, 0
jne Loops1

By bitRAKE
mov al,0
mov edi,offset CompareBrowser1
or ecx,-1
repne scasb
not ecx

mov edi,offset CompareBrowser1
mov esi,offset CompareBrowser2
repe cmpsb
jecxz @Success

TO Hutch:
Posted on 2002-06-02 17:05:20 by cmax
Afternoon, cmax.

If you wish to preserve ecx, then just push and pop ecx outside the code for comparing stirings.

Posted on 2002-06-02 17:25:25 by Scronty
Hello Scronty,

preserve was the wrong word for me to use.... Forget preserve, I need to know how to use any other register as my counter. I am trying not to use ECX at all.

Posted on 2002-06-02 18:06:53 by cmax
You were right, it worked ...

I still got a bug somewhere but at lease i can move on from this point to find it where ever it is....

I really did not think it would work because i did just that but i did not put it in the right place.

But i still like to know how to use registers in a difference way now that i came across the thought. Still i got more good information about all the registers and pointers that i can use better as i go. Time for me to give the board a break. I can find my bug much easier now.

Thanks again

PS: I still NEED to know how to do it with-out using ECX... or if it is even possible
Posted on 2002-06-02 18:46:18 by cmax
If you don't want to use ecx then you can't really use repne scasb. Instead write yor own comparasion loop:

; edi & esi still point to the two string to compare. Here I use edx as counter
mov edx,(Length-1)
@@: mov al,
cmp ,al
jne notEqual
dec edx
jns @F
;if string equal the code ends up here


;if string not equal the code ends up here

And can I apologise in advance for any mistakes here but I'm so drunk I can't walk straight never mind code. :alright:
Posted on 2002-06-02 22:20:59 by Eóin
Thanks E?in,

That's the way i have been all last week because i got piss with fighting wiindows to get my app back to running right... It really help sometimes but don't get hooked or hurt in the process. :)

Anyway, i am near sure that cmp use ECX behind the seen as the code posted above because when i remove it ECX is empty. Do anyone know if this is true or not. I get your idea. I was thinking of subtracting letters like numbers. Like A-A=0 but if a mis-match occurs, like A-B=1 . I don't know but things just keep getting more interesting.

Sleep Well,
Posted on 2002-06-03 01:35:13 by cmax

A trick I use when I am working on an algorithm is to use a number of ordinary memory operands to do stuff like counters or to store values for comparison to preserve the number of registers I still have available.

When you get the algorithm going and reliable, if you have any spare registers, then you can replace the memory operands with them one at a time until you have no spare registers left.

This allows you to most efficiently use the registers available.




I hope you had a great night out and did not have too big a hangover after. :tongue:
Posted on 2002-06-03 02:48:22 by hutch--
Thanks Hutch,

I have not tried yet but got a good idea of what to do. I got one final question about this . When the processer use cmp do it do it with ECX. I am beginning to think it DON'T use ECX. Maybe something processer specific.

Now that i got a real crash course about the registers and EIP, EBP and see how easy this really is i do plan to read the INTEL manual. I really like ASM more than ever now.

Thanks a lot Guys
Posted on 2002-06-03 21:25:49 by cmax
cmax do you mean the microcode
like scasb.
Posted on 2002-06-03 21:48:25 by bdjames
microcode, maybe that what *cmp* is i don't really know and would like to find out.

Example: Would this be considered as microcode and do they use our registers, OR do they only *WORK WITH* using our registers.

Is this an microcode and do it use our ECX to get it job done or do it works things out on it own.

cmp al, ah

Look at Hutch M32.lib example above. It's the perfect example: i don't see ECX being used any where in the code. So i Wonder :confused:
Posted on 2002-06-03 22:14:29 by cmax

ECX is a general purpose register so you can do anything with ECX that you can do with the others. The only registers that are special purpose in a different sense are ESI and EDI and some instructions will only use them and not the others, mainly the string instructions like MOVSB LODSB etc ...

CMP works on any register as long as you observe the normal register rules, you can use,


As long as you don't try and do a direct compare with 2 memory operands,


This will not work because there is no opcode to do direct memory comparison.

I would not worry about microcode in the processors as you have no access to it directly anyway. It will vary from model to model so it would be no use to you anyway.


Posted on 2002-06-03 22:52:52 by hutch--
Wow , Thanks again Hutch... I'm now into and can understand the masm32 Opcodes.hlp...This is really a Great Package ...

The GREATEST ;) ;) ;)
Posted on 2002-06-04 02:09:42 by cmax
cmp al, ah

In this instruction ecx will not be touched. ecx would be modified if you did
repz cmpsb
Posted on 2002-06-04 02:35:52 by Kudos
When you use the following, they will modify ECX. When you use them, you don't put ECX in the source code.


What does it mean when ECX is empty? Did you mean cleared (set to 0)?
Registers (and memory) are never empty. They always contain data.
Posted on 2002-06-04 15:06:32 by tenkey