title: Trouble reversing a string in assembly
body: <p>I am trying to reverse a string in assembly.
  However my code does not seem to work correctly.
  I added a newline string for better readability.</p>
  
  <p>I am using linux and nasm as compiler.</p>
  
  <p>I thought that if I took the values of the adresspointers and switched them at the correct place, the string would eventually be reversed and then get back to normal.</p>
  
  <p>This is my code:</p>
  
  <pre><code>section .data
      hello     db 'Hello world!'
      helloLen  equ $-hello
      derp db '=========',10
      derplen equ $-derp
  
  section .text
      global main
  
  main:
      mov eax,0
      mov ecx,helloLen
  
      reverse:
          ;move pointer
          mov ebx,hello
          add ebx,eax
          push eax
  
          ;move pointer
          mov eax,hello
          add eax,ecx
          push ecx
  
          ;switch bytes
          push ebx
          mov ebx,[ebx]
          mov [eax],ebx
          pop ebx
          mov eax,[eax]
          mov [ebx],eax
  
          ;print text
          mov eax,4
          mov ebx,1
          mov ecx,hello
          mov edx,helloLen
          int 80h
  
          ;Print newline
          mov eax,4
          mov ebx,1
          mov ecx,derp
          mov edx,derplen
          int 80h
  
          ;increment and decrement
          pop ecx
          dec ecx
          pop eax
          inc eax
  
          cmp eax,helloLen
      jne reverse
  
      end:
          mov eax,1
          mov ebx,0
          int 80h
  </code></pre>
  
  <p>This is the output I get:</p>
  
  <pre><code>Hello world!Hell=====
  Hello worldellol=====
  Hello worlllo ol=====
  Hello worlo w ol=====
  Hello woo wow ol=====
  Hello wooooow ol=====
  Hello wooooow ol=====
  Helloooooooow ol=====
  Helloooooooow ol=====
  Helooowooooow ol=====
  Heoow wooooow ol=====
  How o wooooow ol=====
  </code></pre>