If you get a match you jump to "next", which keeps on searching.
You probably want to jump to "done".

Also take care, "mov ebx,x" will move the contents of x, not it's address.
That's w2hat you want to do if "x" is a parameter, but NOt if X is the array itself.
Use "mov ebx,offset x" or "lea ebx,x" to load the address.

asm
{
push ebx ;always save
mov ecx,cursize
mov ebx,x ;it is never a good idea to use ebx in a functon
;this register is used by the compiler and if it is changed
;and you compile a release mode your porgram will
;CRASH. You should update your x[] pointer in another
;function
or ecx,ecx ;much faster than jecxz and give
jz notFound ;zero search length should also be an error
mov edx,[target]
or eax,0 ;make eax = 0
top:
cmp edx,[ebx+eax*4] ;this is an int so 4 byte steps
je done
inc eax
cmp eax,ecx
jne top
notFound:
mov eax,-1
done:
pop ebx ;restore ebx
}

Ok I messed up on the last one. It is and eax,0 this makes eax == 0 and aligns the
code on a 4 byte boundary.

asm
{
push ebx ;always save
mov ecx,cursize
mov ebx,x ;it is never a good idea to use ebx in a functon
;this register is used by the compiler and if it is changed
;and you compile a release mode your porgram will
;CRASH. You should update your x[] pointer in another
;function
or ecx,ecx ;much faster than jecxz and give
jz notFound ;zero search length should also be an error
mov edx,[target]
and eax,0 ;make eax = 0
top:
cmp edx,[ebx+eax*4] ;this is an int so 4 byte steps
je done
inc eax
cmp eax,ecx
jne top
notFound:
mov eax,-1
done:
pop ebx ;restore ebx
}

0

Featured Post

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).

Internet Business Fax to Email Made Easy -
With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number.
You'll receive secure faxes in your email, fr…

You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes.
Assigning simple products to configurable: We assigned simple products…