;Fastest DWORD to ASCII HEX code by The Svin//Russia ;fastadw ;in = eax == number ;out = eax:edx == ASCII HEX ready to be sent into some string ;fastadwz ;in eax == number ;dest == addr to dest to put ASCII HEX of the number in. ;fastadwszsp is the same as fastadwz but insert 20h between low and high words ;if eax == ffffffff then string in dest will be 'FFFF FFFF',0 ; Test the speed ;) fastadw ~ 18 clocks. ;use: fastadwz proto :DWORD ; mov eax,number ;if it's not already in eax ; invoke fastadwz,addr dest ;or invoke fastadwszsp,addr dest .586 .model flat,stdcall option casemap:none .code fastadw proc mov edx,eax shl eax,4 and edx,0FFFF0000h mov ebx,eax shr edx,12 and eax,0ff0h shr bh,4 shr al,4 and ebx,0f0f00h mov ecx,edx shl ebx,8 add eax,06060606h and edx,0ff0h add ebx,eax shr ch,4 mov eax,ebx shr dl,4 and ebx,10101010h and ecx,0f0f00h shr ebx,4 shl ecx,8 sub eax,ebx add edx,06060606h shl ebx,3 add eax,2a2a2a2ah add ecx,edx add eax,ebx mov edx,ecx bswap eax ;################################################ and ecx,10101010h shr ecx,4 sub edx,ecx shl ecx,3 add edx,2a2a2a2ah add edx,ecx bswap edx ret fastadw endp fastadwsz proc dest:DWORD call fastadw mov ebx,dest mov dword ptr ,edx mov dword ptr ,eax mov byte ptr ,0 ret fastadwsz endp fastadws proc dest:DWORD call fastadw mov ebx,dest mov dword ptr ,edx mov dword ptr ,eax ret fastadws endp fastadwszsp proc dest :DWORD call fastadw mov ebx,dest mov dword ptr ,edx mov byte ptr ,' ' mov dword ptr ,eax mov byte ptr ,0 ret fastadwszsp endp end
Posted on 2001-01-15 00:22:00 by The Svin