title: Does the Push operation in Assembly (MASM) leave the new value of the register the same as the pushed value?
body: <p>I'm currently working on nested loops in Assembly for my class.  What I'm wondering is if I push ecx will I need to move another value into ecx or does the current one have the same info that the pushed ecx had?</p>
  
  <p>Example:</p>
  
  <pre><code>ArraySum PROC
  
    push esi             ; save esi, ecx
    push ecx      
    mov eax, 0           ; set the sum to zero
  
  L1:
    add eax, [esi]       ; add each integer to sum
    add esi, TYPE DWORD  ; point to next integer
  loop L1                ; repeat for array size
  
    pop ecx              ; restore ecx and esi to original values
    pop esi
    ret                  ; sum is eax
  
  ArraySum ENDP
  </code></pre>
  
  <p>When I reference ecx again does it contain the original value of 5 even though that value was pushed onto the stack?  Lets say, using the same code as above, that I add a loop.  Will the counter start at 5 or will I need to re-intialize ecx?</p>
  
  <p>I guess maybe this isn't worded exactly as what is in my head.  I'm using this out of my textbook, and it does work.  My question I guess is why does it use the original value of ecx if we pushed it and didn't move another value into ecx after the push?</p>
  
  <p>P.S.  I know the code example I used isn't a nested loop, but this function is inside another loop.  Not that it really has any bearing on my question anyway :)</p>