title: String Reversal LC3 Assembly Language
body: <p>I'm in the process of writing a .asm program based on LC-3 Assembly Language which will loop through a list of strings, reverse each one, and store it back into it's place in the list. </p>
  
  <p>For Example:</p>
  
  <pre><code>     STRINGS .STRINGZ "aabbb"
                        "bbcva"
                        "abcde"
  </code></pre>
  
  <p>The program would flip that list to "<code>bbbaa</code>", "<code>avcbb</code>", and "<code>edcba</code>" - thus, reversing the strings but maintaining the list ordering.</p>
  
  <p>I'm currently working on a nested-loop idea, where the outer loop will go from string to string and the inner loop will flip them and it's kicking my butt! I wrote the code in Java to do the same and it took me 5 minutes, but for some reason, assembly is just pooping on my brain. Any pointers on how to go about doing this?</p>
  
  <p>Here's what I have thus far, in  a mix of psuedo and assembly:</p>
  
  <pre><code>    .ORIG x3000
      LEA R0, STRINGS            ; Load the address of the first char of the list of strings
      Loop until NOP is found, signaling end of the string.
      LEA R1, the address above  ; stores the address of the last char
      LDR R2, #0 Offset +1       ; load the first char to be flipped
      LDR R3, #0 Offset +2       ; load the last char to be flipped
      STR R3, #0 Offset +1       ; store the last char in the mem addr of the first
      STR R2, #0 Offset +2       ; store the first char in the addr of the last
      ADD R1, R1 + 1             ; increment the addr of the first char to move to the second
      ADD R2, R2 - 1             ; decrement the addr of the last char the move the second-to-last
      loop back to beginning somehow
  </code></pre>
  
  <p>And I've not the slightest idea how to do the outer loop between strings.</p>
  
  <p>TL;DR - Assembly Program to reverse a string in memory, please help.</p>