Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The easiest is to use the <a href="http://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html#Simple-Constraints" rel="nofollow">constraint "m"</a>, to load from/save to a memory location:</p> <pre><code>#include &lt;stdio.h&gt; int main (void) { double a = 0.78539816339744; asm ("fldl %0;" "fsin;" "fstpl %0" : "+m"(a)); printf("sin(45°) = %f\n", a); return 0; } </code></pre> <p>The <a href="http://gcc.gnu.org/onlinedocs/gcc/Modifiers.html#Modifiers" rel="nofollow">modifier "+"</a> tells the compiler that you want your input in that memory location and to output to the same location.</p> <p>GCC is allowed to reorder your lines, but it will know the semantics of that line, and it will optimize accordingly.</p> <p>A more difficult example, employing loading from other variables than that are to be written to:</p> <pre><code>#include &lt;stdio.h&gt; int main (void) { double sin_a, cos_a, a = 0.5; asm ("fldl %2;" "fsincos;" "fstpl %1;" "fstpl %0;" : "=m"(sin_a), "=m"(cos_a) : "m"(a)); printf("sin(29°) = %f, cos(29°) = %f\n", sin_a, cos_a); return 0; } </code></pre> <p>Live demo: <a href="http://ideone.com/SuvpM" rel="nofollow">http://ideone.com/SuvpM</a>.</p> <p><s>PS: I could not get GCC to load a <strong>double</strong> value, though, so I don't know if my answer is any use to you. :-(</s></p> <h3>Update:</h3> <p>Got it: you need to append <code>s</code> (for single [32 bits], as in <code>flds</code>, floating-point load single), <code>l</code> (for double [64 bits]), or <code>t</code> (for long double [80 bits]) explicitely. My GCC 4.6.3 assumes a single value for every memory operand …</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload