title: C/C++ returning struct by value under the hood
body: <p>(This question is specific to my machine's architecture and calling conventions, Windows x86_64)</p>
  
  <p>I don't exactly remember where I had read this, or if I had recalled it correctly, but I had heard that, when a function should return some struct or object by value, it will either stuff it in <code>rax</code> (if the object can fit in the register width of 64 bits) or be passed a pointer to where the resulting object would be (I'm guessing allocated in the calling function's stack frame) in <code>rcx</code>, where it would do all the usual initialization, and then a <code>mov rax, rcx</code> for the return trip. That is, something like</p>
  
  <pre><code>extern some_struct create_it(); // implemented in assembly
  </code></pre>
  
  <p>would really have a secret parameter like</p>
  
  <pre><code>extern some_struct create_it(some_struct* secret_param_pointing_to_where_i_will_be);
  </code></pre>
  
  <p><br>Did my memory serve me right, or am I incorrect? How are large objects (i.e. wider than the register width) returned by value from functions?</p>