title: Sum even elements of an array in MSVC inline asm
body: <p>I'm trying to write a function in Assembly that will return the sum of the even elements in an array. This is my code</p>
  
  <pre><code>       int sum(int *a, int n)
         {
            int S = 0;
            _asm {
  
            mov eax, [ebp + 8]
            mov edx, 0
            mov ebx, [ebp + 12]
            mov ecx, 0
            for1: cmp ecx, ebx
            jge endfor
            and [eax + ecx * 4], 1
            jz even
            inc ecx
            jmp for1
  
            even: add edx, [eax + ecx * 4]            
            inc ecx
            jmp for1
            endfor: mov S, edx
            }
        return S;
        }
  </code></pre>
  
  <p>But it's not working. Does anybody know what it's wrong and how can I fix it? Thanks.</p>