title: How are __addgs* used, and what is GS?
body: <p>On Microsoft's site can be found <a href="https://docs.microsoft.com/en-us/cpp/intrinsics/addgsbyte-addgsword-addgsdword-addgsqword?view=msvc-160" rel="nofollow noreferrer">some details</a> of the</p>
  <pre><code>__addgsbyte  ( offset, data )
  __addgsword  ( offset, data )
  __addgsdword ( offset, data )
  __addgsqword ( offset, data )
  </code></pre>
  <p>intrinsic functions. It is stated that <code>offset</code> is</p>
  <blockquote>
  <p><em>the offset from the beginning of GS</em>. I presume that <em>GS</em> refers to the processor register.</p>
  </blockquote>
  <p>How does <em>GS</em> relate to the stack, if at all? Alternatively, how can I calculate an offset with respect to <em>GS</em>?</p>
  <p>(And, are there any 'gotchas' relating to this and particular calling conventions, such as <code>__fastcall</code>?)</p>