title: ARM Assembly - Converting Endianness
body: <p>This is currently a homework project that me and my teammate are stuck on. We haven't been given much of an introduction into Assembly, and this is supposed to be our first homework exercise. The task is to create a program that converts 0xAABBCCDD into 0xDDCCBBAA.</p>
  
  <p>I'm not looking for an answer, as that would defeat the purpose, but we are getting severely frustrated over the difficulty of this stupid thing. We think we have a good start in creating a viable solution, but we just cannot come up with the rest of the program. </p>
  
  <p>First, we mask every single tupel (aa), (bb), (cc), (dd) into a different register:</p>
  
  <pre><code>LDR R0, LittleEndian    // 0xAABBCCDD
  AND R1, R0, #0xFF000000 // 0xAA
  AND R2, R0, #0x00FF0000 // 0xBB
  AND R3, R0, #0x0000FF00 // 0xCC
  AND R4, R0, #0x000000FF // 0xDD
  </code></pre>
  
  <p>Then we try to re-align them into the R0 register, but hell if we could come up with a good solution... </p>
  
  <p>Our best effort came from:</p>
  
  <pre><code>ORR R0, R1, LSL #24 
  ORR R0, R2, LSL #8
  ORR R0, R3, LSR #8
  ORR R0, R4, LSR #24
  </code></pre>
  
  <p>which produced 0xBBBBCCDD for some odd reason; we really don't know. </p>
  
  <p>Any hints would be greatly appreciated. Again, we are asking for help, but not for a solution. </p>
  
  <p>Cheers!</p>