title: How do I move a buffer into the data segment using gcc inline assembly?
body: <p>I want to try to use the <code>ide_read_sectors</code> and <code>ide_write_sectors</code> from OsDev's PCI IDE driver implementation here, <a href="https://wiki.osdev.org/PCI_IDE_Controller#Read.2FWrite_From_ATA_Drive" rel="nofollow noreferrer">https://wiki.osdev.org/PCI_IDE_Controller#Read.2FWrite_From_ATA_Drive</a>.</p>
  <p>To move the buffer (a <code>u8* buffer</code>) into the data segment using</p>
  <pre><code>asm volatile(&quot;mov %0, %%CS&quot;
              : :&quot;r&quot;(buffer));
  </code></pre>
  <p>It crashed the program.</p>
  <p>My overall code is based on this tutorial, <a href="https://github.com/cfenollosa/os-tutorial" rel="nofollow noreferrer">https://github.com/cfenollosa/os-tutorial</a>. To clarify, I want to move something like a string to <code>cs</code>.</p>