Tu mets cela dans BinSearch.cpp
__declspec(naked) unsigned int __stdcall BinSearch(int *array, int count, int tofind)
{
__asm {
push ebx
push esi
mov edx, [esp+16] ; count
xor ecx, ecx ; ECX = first
mov ebx, [esp+20] ; EBX = tofind
dec edx ; EDX = last = count - 1
mov esi, [esp+12] ; ESI = array
whlFirstInfegLast: ; while(first <= last)
lea eax, [edx+ecx] ; mid = (last + first)
cmp ecx, edx
jg short notfound
shr eax, 1 ; mid = (last + first) / 2
cmp [esi+eax*4], ebx
je short found
jl short infVal
lea edx, [eax-1] ; last = --mid
jmp short whlFirstInfegLast
infVal:
lea ecx, [eax+1] ; first = ++mid
jmp short whlFirstInfegLast
notfound:
mov eax, -1
found:
pop esi
pop ebx
ret 12
}
}
BinSearch.cpp est FINI.
Tu mets cela dans BinSearch.h
#ifndef BINSEARCH_H
#define BINSEARCH_H
unsigned int __stdcall BinSearch(int *array, int count, int tofind);
#endif
BinSearch.h est FINI.
BinSearch() retourne idx de position trouvee ou -1.
Dans ton prog avec main() tu mets
#include "BinSearch.h"
et tu peux te servir de cette func.
Le main() c'est pas pour moi.
BruNews, ciao...
-------------------------------
Réponse au message :
-------------------------------
>
AKETOSTAR>
> Salut, c'est la première fois que j'écris ici.
>

>
> je recherche le code source de la recherche dichotomique de tableau d'entiers trié en ordre croissant. Donc j'aimerais les différentes fonctions et/ou procédures + le main pour tester cela dans un programme. Merci d'avance.
>
> ps: je précise que je n'ai pas vu les pointeurs donc ce serait bien si vous ne m'en mettiez pas. Merci