When to Sign Extension and when to Zero Extension ?

From: sugaray (ruicui_at_sohu.com)
Date: 02/27/04


Date: Fri, 27 Feb 2004 22:58:52 +0000 (UTC)

Can someone tell me when to use MOVSX and when to use MOVZX ?
for example, the following disassembled code use MOVSX, why ?

                      mov [ebp+var_4], 0
 loc_0_4010DB:
                      mov eax, [ebp+arg_0]
                      movsx ecx, byte ptr [eax]
                      test ecx, ecx
                      jz short loc_0_401159
                      mov edx, [ebp+arg_0]
                      movsx eax, byte ptr [edx]
                      cmp eax, 41h
                      jl short loc_0_401113