title: x86 How to add all the positive integers in an array
body: <p>I have this code below, and this seems to be adding up ALL the integers in an array, instead of taking ONLY the positive. I'm kind of confused how to fix this problem as I am new to x86 Assembly Programming. Thank you for your help!</p>
  
  <pre><code>int addpos(int* X, int length){
      __asm{
          PUSH ebx
          PUSH ecx
          PUSH edx
          PUSH esi
          PUSH edi
          MOV ebx, X
          MOV ecx, length
  
          xor eax, eax
       L1:
          cmp ecx, 0
          add eax, [ebx]
          add ebx, 4
          loop L1
  
          POP edi
          POP esi
          POP edx
          POP ecx
          POP ebx
      }
  }
  </code></pre>