title: Two way address translation or what?
body: <p>I am looking at the ARM assembly code for a C++ native code. Target platform is Windows Phone 8, and build environment is Visual Studio 2012.</p>
  
  <p>I am inspecting the ARM assembly code to look for possibilities of code optimisation to the maximum.</p>
  
  <p>I am confused regarding the requirement for one of the instruction in the ARM code, as under.</p>
  
  <p><strong>C++ Code:</strong></p>
  
  <pre><code>double lmean= kseedsl[n];
  </code></pre>
  
  <p><strong>ARM Code:</strong></p>
  
  <pre><code>1: ldr r3,[sp,#0x4C]
  2: ldr r3,[r3]                     // r3= kseedsl
  3: add r2,r3,r6,lsl #3             // r2 = &amp;kseedsl[n] (r6 has value of "n")
  4: vldr d13,[r2]                   // d13 = *(r2)
  </code></pre>
  
  <p>I understand that the addresses for variables such as <code>kseedsl</code>(which is an input arguement in the function) is stored in the stack. But I am clueless why we require two <code>ldr</code> (line1, 2) to load the address of <code>kseedsl</code> into r3. As per my knowledge, I would have expected <code>[sp,#0x4C]</code> to directly store the address for kseedsl which is passed as a function arguement.</p>
  
  <p>Kindly point out what I am missing over here.
  I expect it to be a standard concept which I am unaware of.</p>
  
  <p><strong>EDIT:</strong> The skeleton of the function is as under:</p>
  
  <pre><code>void function_xyz(
      vector&lt;double&gt;&amp;             kseedsl,
      vector&lt;double&gt;&amp;             kseedsa,
      vector&lt;double&gt;&amp;             kseedsb,
      vector&lt;int&gt;&amp;                kseedsx,
      vector&lt;int&gt;&amp;                kseedsy,
      unsigned short*             klabels,
      const int&amp;                  STEP,
      const double&amp;               M,
      int                         Iter,
      int                         *oMaxSegsize);
  </code></pre>