En nettement + rapide, aucun appel de fonction et donc pas empilage des 3 params de ultoa.
char szappname[] = "Teste";
#ifndef BNINLINE
#ifdef __cplusplus
#define BNINLINE inline
#else
#define BNINLINE __inline
#endif /* __cplusplus */
#endif /* BNINLINE */
BNINLINE char* bnByteToHex(BYTE b, char *dst) // return ptr sur NULL final
{
__asm {
mov ecx, dst
mov al, b
add ecx, 2
mov dl, al
mov byte ptr[ecx], 0
and al, 15
shr dl, 4
add al, 48
cmp al, 57
jbe short btohx1
add al, 7
btohx1:
add dl, 48
mov [ecx-1], al
cmp dl, 57
jbe short btohx2
add dl, 7
btohx2:
mov [ecx-2], dl
mov eax, ecx
}
}
void __stdcall Tester()
{
char buf[24], *c;
buf[0] = '0';
buf[1] = 'x';
c = bnByteToHex(32, buf + 2);
*c++ = 32; // UN ESPACE
strcpy(c, "YOUPI");
// SORTIRA: "0x20 YOUPI"
MessageBox(0, buf, szappname, 0);
}
ciao...
[ Lien ]
BruNews, MVP VC++