title: String Reverse in Assembly language x86
body: <p>I'm new to assembly language and I have this code that is suppose to reverse the string length, now I know I'm close but the program keeps crashing on me for whatever reason that is. The problem is in the STRREV PROC. What am I doing wrong in this code? </p>
  
  <pre><code>INCLUDE Irvine32.inc
  .data
      prompt BYTE "Enter String: ", 0
      response BYTE 50 DUP(0)
      message BYTE " Message entered. ",0
  .code   
  
  swap MACRO a,b 
  
      xor a,b
      xor b,a
      xor a,b
  
  endM
  
  STRQRY PROC
     push ebp
     mov  ebp, esp
     push edx
     push ecx
  
     mov edx, [ebp+8]
     call writestring
  
     mov ecx, SIZEOF response
     mov edx, OFFSET response
     call readstring
  
  
     pop ecx
     pop edx
     pop ebp  
     ret 4
  
  STRQRY ENDP
  
  STRLEN PROC 
             push ebp 
             mov  ebp, esp
             push ebx
             push ecx
  
             mov edx,[ebp+16]
  
             mov eax, 0
  
  
  counter:
             mov cl,[edx+eax]
  
             cmp cl, 0       
  
             JE  done
  
             inc eax 
  
             jmp counter
  
  done:
             pop ecx
             pop ebx
             pop ebp
             ret 4
  
  STRLEN ENDP
  
  STRREV proc
      push ebp
      mov  ebp, esp
  
      push OFFSET response   
      call STRLEN
  
      mov edx, [ebp+8]
      mov esi, 0
      dec eax
  
  reverseloop:   
  
      mov ah, [edx+esi]
      mov al, [edx+eax]
  
      swap ah, al
  
      mov [edx+esi],ah
      mov [edx+eax],al
  
      inc esi
      dec eax
  
      cmp esi, eax
      jb reverseloop
      ja finish
  
  finish:
      pop ebp
      ret 4
  
  STRREV endp
  
  main PROC
  
      push OFFSET prompt
      call STRQRY
  
      call writedec 
  
      mov edx,OFFSET message
      call WriteString
  
      push eax 
      call STRREV
  
      mov edx, OFFSET response
      call WriteString
  
       exit
  main ENDP
  END main
  </code></pre>