BruNews
Messages postés
21040
Date d'inscription
jeudi 23 janvier 2003
Statut
Modérateur
Dernière intervention
21 août 2019
13 juin 2009 à 22:25
JUSTE POUR LE FUN, NE PAS RALER (faut bien se divertir un samedi soir).
J'ai réduit le test sur 4 valeurs au lieu de 500 (10 * 50).
Pour ton cas, suffira d'appeler:
BYTE btres[10][50];
EcartDbl5PZ(tab1, tab2, 500, btres);
btres sera rempli de 1 si diff >= 5.0 sinon 0.
---------------------------------
double tabA[4] = {1.2, 12.8, 24.5, -58.2};
double tabB[4] = {0.5, 1.0, 20.0, -59.7};
char szappname[] = "dblCOMP";
const DWORD BN32ABS[2] = {0x7FFFFFFF, 0xFFFFFFFF};
const double CINQPZ = 5.0;
__declspec(naked) void __fastcall EcartDbl5PZ(double *pA, double *pB, DWORD nElems, BYTE *pRes){ // ECX pA, EDX pB, [esp+4] = nElems, [esp+8] = pRes
__asm {
mov eax, [esp+4]
mov [esp-4], edi
test eax, eax
je short dblEXIT
mov edi, [esp+8]
movsd xmm2, qword ptr BN32ABS
movsd xmm3, qword ptr CINQPZ
tabsCMP:
movsd xmm0, qword ptr[ecx]
movsd xmm1, qword ptr[edx]
mov byte ptr[edi], 0
ucomisd xmm0, xmm1
je short tabsNEXT
jb short aINFb
subsd xmm0, xmm1
andpd xmm0, xmm2
ucomisd xmm0, xmm3
jb short tabsNEXT
jmp short diffSUPEQU
aINFb:
subsd xmm1, xmm0
andpd xmm1, xmm2
ucomisd xmm1, xmm3
jb short tabsNEXT
diffSUPEQU:
mov byte ptr[edi], 1
tabsNEXT:
add ecx, 8
add edx, 8
add edi, 1
sub eax, 1
jne short tabsCMP
mov edi, [esp-4]
dblEXIT:
ret 8
}
}
void tstEcartCinq(VOID)
{
BYTE btres[4];
char buf[4];
int i;
EcartDbl5PZ(tabA, tabB, 4, btres);
for(i = 0; i < 4; i++) {
*((DWORD*) buf) = btres[i] ? 0x49554F : 0x4E4F4E;
MessageBox(0, buf, szappname, 0);
}
}
ciao...
BruNews, MVP VC++