title: How to reverse and print a string in assembly language
body: <p>So my assignment was to write a program in assembly code that could make a statement, recieve a user inputted string. Print that string then reverse it using the cpu stack and print it again. this is what I have thus far.</p>
  
  <pre><code>INCLUDE Irvine32.inc
  
  .data
  buffer byte 20 DUP(0)
  byteCount DWORD ?
  
  Question  byte  "Please enter your name."  ,0
  Greeting byte   "Hello " ,0
  Statement byte " Here is your name backwards"
  
  .code
  main proc
  
  
  mov edx , OFFSET Question
  call WriteString
  call CRLF
  Call CRLF
  
  mov edx, OFFSET buffer
  mov Ecx, SIZEOF buffer
  call ReadString
  
  push edx
  mov EDX ,OFFSET greeting
  Call WriteString
  pop edx
  call WriteString
  Call CRLF
  Call CRLF
  </code></pre>
  
  <p>As you can see this successfully accepts a user entered input and displays it but Im really struggling trying to reverse it.</p>
  
  <p>I tried these here that I copied from the book from a chapter about reversing strings.</p>
  
  <pre><code>; Push the name on the stack.
  
  mov ecx,nameSize
  mov  esi,0
  
  L1: movzx eax,aName[esi]    ; get character
  push eax                ; push on stack
  inc  esi
  loop L1
  
  ; Pop the name from the stack in reverse
  ; and store it in the aName array.
  
  mov  ecx,nameSize
  mov  esi,0
  
  L2: pop  eax                ; get character
  mov  aName[esi],al      ; store in string
  inc  esi
  loop L2
  
  Invoke ExitProcess,0
  main endp
  end main
  </code></pre>
  
  <p>but I get as output nothing.</p>
  
  <p>it says "hello, (yourname here)"</p>
  
  <p>it says "this is your name backwards                   "</p>
  
  <p>ive tried just about every different incarnation of this I can think of and no avail. im at the end of my "string" here</p>