Assembly How should I increment the array if I want to switch values?
<p>This is being compiled on Visual Studios 2015 with Kip Irvine.</p>

<p>The code is supposed to switch the 1st element with the 2nd element and the 3rd element with the 4th element and so on. It switches the values forward instead of just switching the two values. I added the index register with 2 to skip the 2nd element since it should not be switched. Is there something I am missing? Am I supposed to increment the array index differently or am I putting the wrong values in the wrong registers? Thanks in advance! Please don't just give me the answer.</p>

<p>The output is</p>

<blockquote>
  <p>Dump of offset 00AD6880</p>
  
  <hr>
  
  <p>00020000 00050000 00090000 0000000A 0000000C</p>
</blockquote>

<pre><code>INCLUDE Irvine32.inc
.data
dwarray dword  0,2,5,9,10,12


.code
main proc
mov ebx, OFFSET dwarray
mov ecx, LENGTHOF dwarray
L1: cmp ebx, ecx
mov eax, [ebx]
mov edx, [ebx+1]
mov [ebx+1], eax 
mov [ebx], edx
add ebx, 2
loop L1

; The four instructions below are fixed, the only variable is the name of the array  
mov    esi,OFFSET dwarray
mov    ecx,LENGTHOF dwarray
mov    ebx,TYPE dwarray
call   DumpMem
call WaitMsg
exit
main ENDP
END main
</code></pre>