What's the purpose of "AND AL,0xFF"?

Viewed 1543

I'm reading through a disassembled win32 c++ program and I see quite a few:

AND AL,0xFF

Is this completely pointless or why would the compiler generate these?

Here is a longer example:

movsx   eax, byte ptr [ebx]
shl     eax, 18h
movsx   edx, byte ptr [ebx+1]
shl     edx, 10h
add     eax, edx
movsx   ecx, byte ptr [ebx+2]
shl     ecx, 8
add     eax, ecx
movsx   edx, byte ptr [ebx+3]
add     eax, edx
xor     edx, edx
call    sub_43B55C
mov     ecx, eax
mov     edx, eax
sar     ecx, 10h
and     al, 0FFh      # <----
sar     edx, 8
and     cl, 0FFh      # <----
mov     [esi], cl
and     dl, 0FFh      # <----
mov     [esi+1], dl
mov     [esi+2], al
add     ebx, 4
add     esi, 3
inc     ebp
cmp     ebp, 6
jl      short loc_43B5E4

The flags aren't being checked after these operations so that can't be the purpose. After the AND, the values in AL, CL, and DL are being moved to [ESI + n].

1 Answers
Related