title: Assembly bubble sort swap
body: <p>I'm trying to do a bubble sort in x86 assembly (yes it has to be bubble, as I'm not concerned about speed optimization regarding different types of sorts) and for some reason, my code will not swap the necessary values. Here is my code</p>
  
  <pre><code>mov eax, list                   ;store list in eax
  mov edx,[eax+4*edi-4]           ;temp = var1
  cmp edx,[eax+edi*4]             ;compare
  JLE SECOND_LOOP                 ;jump if var1 &lt; var2
  mov [eax+4*edi-4],[eax+edi*4]   ;var1 = var2
  mov [eax+edi*4], edx            ;var2 = temp
  jmp SECOND_LOOP
  </code></pre>
  
  <p>At the last mov instruction where it's supposed to load the temp back into the address, it..doesn't. The EAX register has the starting address of the array which contains my list of values</p>
  
  <pre><code>0x*starting address* 0a 00 00 00 ec ff ff ff 05 00 00 00 0c 00 00 00 1e 00 00 00 fb ff ff ff ea
  0x*address after   * ff ff ff 37 00 00 00 34 00 00 00 00 00 00 00
  </code></pre>
  
  <p>and the next address contains a few more numbers. In decimal, the numbers are <code>10 -20 5 12 30 -5 -22 55 52 0</code>. Essentially right now I'm trying to move <code>FFFFFFEC</code> to <code>0000000A</code> and then move <code>0000000A</code> to <code>FFFFFFEC</code>. I can store it into my temp register EDX, but cannot store the value of EDX into the specific address. Any help?</p>