<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[stop printf from using mmx and sse registers]]></title><description><![CDATA[<p>Hello,</p>
<p>I encounter the following problem:</p>
<p>my code contains the following printf statement:</p>
<pre><code class="language-cpp">long long a,b,c,d;
printf(&quot;\n a: (%016llx) b: %d c: %ld d: %lld&quot;,a,b,c,d);
</code></pre>
<p>Always printf changes sse-registers (xmm0-xmm3)</p>
<p>How can I disable printf to use mmx, sse, sse2 ?</p>
<p>I also tried compiling like this:<br />
g++ -mno-mmx -mno-sse2 -mno-sse -m64 -mcmodel=medium -ggdb in.cpp -o out.o</p>
<p>but to no avail <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /><br />
the sse registers are still changed.</p>
<p>Could anyone please help?</p>
<p>Many thanks<br />
Bj</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/259483/stop-printf-from-using-mmx-and-sse-registers</link><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 19:42:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/259483.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 23 Jan 2010 18:08:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to stop printf from using mmx and sse registers on Sat, 23 Jan 2010 18:08:45 GMT]]></title><description><![CDATA[<p>Hello,</p>
<p>I encounter the following problem:</p>
<p>my code contains the following printf statement:</p>
<pre><code class="language-cpp">long long a,b,c,d;
printf(&quot;\n a: (%016llx) b: %d c: %ld d: %lld&quot;,a,b,c,d);
</code></pre>
<p>Always printf changes sse-registers (xmm0-xmm3)</p>
<p>How can I disable printf to use mmx, sse, sse2 ?</p>
<p>I also tried compiling like this:<br />
g++ -mno-mmx -mno-sse2 -mno-sse -m64 -mcmodel=medium -ggdb in.cpp -o out.o</p>
<p>but to no avail <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /><br />
the sse registers are still changed.</p>
<p>Could anyone please help?</p>
<p>Many thanks<br />
Bj</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843826</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843826</guid><dc:creator><![CDATA[printf-grrr]]></dc:creator><pubDate>Sat, 23 Jan 2010 18:08:45 GMT</pubDate></item><item><title><![CDATA[Reply to stop printf from using mmx and sse registers on Sat, 23 Jan 2010 19:22:59 GMT]]></title><description><![CDATA[<p>Ok, I found one workaround:</p>
<p>Printing hex and dec values with</p>
<pre><code class="language-cpp">cout &lt;&lt; hex &lt;&lt; a &lt;&lt; dec &lt;&lt; b;
</code></pre>
<p>However, I don't want to change all printf statements in my code....</p>
<p>Any better solutions ?</p>
<p>Thanks.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843840</guid><dc:creator><![CDATA[printf-grrr]]></dc:creator><pubDate>Sat, 23 Jan 2010 19:22:59 GMT</pubDate></item><item><title><![CDATA[Reply to stop printf from using mmx and sse registers on Sat, 23 Jan 2010 19:35:17 GMT]]></title><description><![CDATA[<p>printf-grrr schrieb:</p>
<blockquote>
<p>Ok, I found one workaround:</p>
<p>Printing hex and dec values with</p>
<pre><code class="language-cpp">cout &lt;&lt; hex &lt;&lt; a &lt;&lt; dec &lt;&lt; b;
</code></pre>
<p>However, I don't want to change all printf statements in my code....</p>
<p>Any better solutions ?</p>
<p>Thanks.</p>
</blockquote>
<p>You could implement your own Version of printf that uses cout. That would be a lot of work to do but depending on the number of printfs in your code it might be worth the effort.</p>
<p>Regarding your problem with the registers: This is quite odd. I wonder if it is a compiler error. Can you test your code with a different compiler? Or post a minimal example so that other readers can try other compilers?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843843</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 23 Jan 2010 19:35:17 GMT</pubDate></item><item><title><![CDATA[Reply to stop printf from using mmx and sse registers on Sat, 23 Jan 2010 19:55:07 GMT]]></title><description><![CDATA[<p>Compiled with:<br />
g++ -mno-mmx -mno-sse2 -mno-sse -m64 -mcmodel=medium -ggdb printf.cpp -o out.o</p>
<p>Version:<br />
g++ (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839]</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
using namespace std;

main()
{
 long long a,b,c,d;
  a=1;b=0xfffffff;c=4;d=5;

  printf(&quot;a: %lld, b: %lld, c: %lld&quot;,a,b,c);

// decomment line below for comparison purposes...
//   cout &lt;&lt; hex &lt;&lt; b &lt;&lt; endl;

};
</code></pre>
<p>An &quot;dedicated&quot; version of printf's too much work; alternatively I could<br />
implement a routine that save's the registers before calling printf.</p>
<p>I am not such a C/C++ fan and not very happy with this buggy behaviour.<br />
If the compile option is to stop using mmx, sse and sse2 the final<br />
program should not do otherwise.</p>
<p>Originally my programs are in assembly language and for speeding up<br />
development returned to a high level language in between.</p>
<p>This does not seem to be rewarding till now <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>But a solution for this printf-bug should already be available, no ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843849</guid><dc:creator><![CDATA[printf-grrr]]></dc:creator><pubDate>Sat, 23 Jan 2010 19:55:07 GMT</pubDate></item><item><title><![CDATA[Reply to stop printf from using mmx and sse registers on Sun, 24 Jan 2010 08:51:02 GMT]]></title><description><![CDATA[<p>Apparently your glibc uses sse. Rebuild that library accordingly.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843946</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843946</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sun, 24 Jan 2010 08:51:02 GMT</pubDate></item><item><title><![CDATA[Reply to stop printf from using mmx and sse registers on Sun, 24 Jan 2010 15:26:28 GMT]]></title><description><![CDATA[<p>That's not a solution.</p>
<p>Compiling with -nommx -nosse options was just trying to workaround the<br />
issue.</p>
<p>1. I don't know how to rebuild that lib (and actually I do not want to know,<br />
there are more important issues pressing on time).<br />
It should work on other platforms too, without having to rebuild<br />
every lib from scratch. There should be an easier solution wo<br />
having to dive into all compiler details.</p>
<p>2a. I just do not want printf to use sse, etc.<br />
2b. or stop it from changing sse, mmx registers.</p>
<p>3. My current fix is to save sse before calling printf and restore<br />
afterwards. But it's wearisome to change all line's in the code and cost's cpu-speed.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1844081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1844081</guid><dc:creator><![CDATA[printf-grrr]]></dc:creator><pubDate>Sun, 24 Jan 2010 15:26:28 GMT</pubDate></item></channel></rss>