title: Understanding assembly generated from simple Rust struct
body: <pre><code>pub struct CIpv6Address {
      pub address: [u16; 8],
  }
  
  pub fn h() {
      let x = CIpv6Address {
          address: [1,2,3,4,5,6,7,8]
      };
  }
  </code></pre>
  
  <p>generates</p>
  
  <pre><code>    sub     rsp, 32
      mov     word ptr [rsp + 16], 1
      mov     word ptr [rsp + 18], 2
      mov     word ptr [rsp + 20], 3
      mov     word ptr [rsp + 22], 4
      mov     word ptr [rsp + 24], 5
      mov     word ptr [rsp + 26], 6
      mov     word ptr [rsp + 28], 7
      mov     word ptr [rsp + 30], 8
      mov     rax, qword ptr [rsp + 16]
      mov     qword ptr [rsp], rax
      mov     rax, qword ptr [rsp + 24]
      mov     qword ptr [rsp + 8], rax
      add     rsp, 32
      ret
  </code></pre>
  
  <p>as can be seen here: <a href="https://godbolt.org/z/P4UHa_" rel="nofollow noreferrer">https://godbolt.org/z/P4UHa_</a></p>
  
  <p>I understood that it makes room in the stack pointer and fills with values. Why it starts at rsp + 16 though? </p>
  
  <p>I can see then that if fills jumping by 4 bits. Why? My values are of 16 bits.</p>
  
  <p>Finally, why it transfers the values from <code>rsp +16</code> and <code>rsp+24</code> to both <code>rsp</code> and <code>rsp+8</code>?</p>