Hi. What I want to do is to find out if there are any zero bytes in a DWORD. For example, FF00FFAAh has a zero byte, but CCAABBFFh does not. I'm looking for a very fast way, so that excludes checking every part of the DWORD. Thanks =)
i'm not really sure, but if you would XOR the dword with 00FFFFFFh the dword becomes kind of inverted (?)........no, forget it. perhaps it's a hint to do something with XOR,AND,OR
this code appears in my mind reading your post...
ebx gives the number of zero bytes not short, but label free :D even not tested, just written in my IExplorer.
xor ebx, ebx xor ecx, ecx mov eax, testvalue test al, al sete cl add ebx ,ecx test ah, ah sete cl add ebx ,ecx shr eax, 16 test al, al sete cl add ebx ,ecx test ah, ah sete cl add ebx ,ecx
Agner Fog does this operation in his StrLen algorithm, you can find it in the MASM32 library directory m32lib. Regards, firstname.lastname@example.org
Thank you very much. =)
How about this: push eax ;or whatever dword mov edi,esp mov ecx,4 mov al,0 repne scasb pop eax and now ZF is set iff there was a zero byte. That assumes ES=SS, which seems to be true in Windows, normally. If not, use memory for the dword. There are various other occasions for making small temporary strings on the stack.