title: ARM assembly memcpy equivalent
body: <p>I am viewing the assembly output of this function:</p>
  <pre><code>extern void write(char * buff);
  
  void test(int x)
  {
      // copy &quot;EXAMPLE\0\0\0\0\0...&quot;
      char buff[16] = &quot;EXAMPLE&quot;;
  
      // set byte 10 to '0'+x
      buff[10] = '0' + x;
  
      // write
      write(buff);
  }
  </code></pre>
  <p>And it looks <a href="https://godbolt.org/z/AVo_nK" rel="nofollow noreferrer">like this</a>:</p>
  <pre><code>test:
          push    {r4, lr}
          ldr     r2, .L4
          mov     r3, r0
          ldm     r2, {r0, r1}
          sub     sp, sp, #16
          mov     r2, sp
          adds    r3, r3, #48
          stm     r2, {r0, r1}
          movs    r4, #0
          mov     r0, r2
          strd    r4, r4, [sp, #8]
          strb    r3, [sp, #10]
          bl      write
          add     sp, sp, #16
          pop     {r4, pc}
  .L4:
          .word   .LANCHOR0
          .cfi_endproc
  .LFE0:
          .size   test, .-test
          .section        .rodata
          .align  2
          .set    .LANCHOR0,. + 0
          .ascii  &quot;EXAMPLE\000&quot;
          .space  8
          .text
  </code></pre>
  <p>I am completely puzzled on where the copying from <code>.L4</code> to the stack happens?</p>
  <p>I see the stack pointer getting moved by 16B, and I see the <code>adds</code> instruction for <code>'0'+x</code>, but which instruction copies the data?</p>
  <p>Sorry for the newbie question, thanks!</p>