<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>mikeash.com pyblog/friday-qa-2011-12-23-disassembling-the-assembly-part-2.html comments</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-12-23-disassembling-the-assembly-part-2.html#comments</link><description>mikeash.com Recent Comments</description><lastBuildDate>Mon, 17 Aug 2026 11:10:50 GMT</lastBuildDate><generator>PyRSS2Gen-1.0.0</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Owen Shepherd - 2012-01-01 13:30:20</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-12-23-disassembling-the-assembly-part-2.html#comments</link><description>That is most certainly not a far jump/call. In AT&amp;amp;T syntax, a far jump/call is encoded using the "ljmp" or "lcall" mnemonic, and is used for cross-segment calls and jumps. Now, since cross-segment calls and jumps are nigh-on obsolete, you'll only very rarely see them..</description><guid isPermaLink="true">9e1e04b12aa0a8121a8601f81bb24bea</guid><pubDate>Sun, 01 Jan 2012 13:30:20 GMT</pubDate></item><item><title>Chris Suter - 2011-12-31 02:04:57</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-12-23-disassembling-the-assembly-part-2.html#comments</link><description>&amp;gt; If you peek at the generated machine code with a disassembler, it turns out to not be a mov instruction at all, but rather a lea!
&lt;br /&gt;
&lt;br /&gt;Are you sure? I don’t see this.
&lt;br /&gt;
&lt;br /&gt;&amp;gt; GOTPCREL is a directive which allows the rip-relative address of a function to be inserted at link time so a direct call can be made
&lt;br /&gt;
&lt;br /&gt;I don’t think that’s quite right. See below.
&lt;br /&gt;
&lt;br /&gt;&amp;gt; "far jump" (a branch over a long distance of code, which, by necessity, is much slower).
&lt;br /&gt;
&lt;br /&gt;Again, I don’t think a “far jump” is necessarily much slower because it is over a long distance of code. It might be marginally slower because you might have to use more bytes to encode the instruction (but that won’t be *much* slower), and it will obviously be slower if the address you’re jumping to causes a page fault or a bit slower if it isn’t in the cache, but it’s not slower simply because it’s a branch over a long distance of code. Things might be a bit slower in your example because an indirect jump is being used (but you’d need to check the processor documentation to see by how much and I wouldn’t be surprised to find that if it’s cached, it’s nil).
&lt;br /&gt;
&lt;br /&gt;&amp;gt; Note: I'm not 100% sure of my facts on this one; I'd appreciate any insight anyone has on the specifics of @GOTPCREL
&lt;br /&gt;
&lt;br /&gt;@GOTPCREL allows you to load an address in a global offset table in a single instruction (using instruction relative addressing). The Global Offset Table (GOT) stores the address of objc_msgSend and any other global addresses that might be required. It is fixed up by dyld at runtime. The GOT is always at a fixed offset relative to code so you can use instruction relative addressing to load an address from it.
&lt;br /&gt;
&lt;br /&gt;All of the above said, I’m no expert on this, so please don’t take my word on the above; I might be wrong.
&lt;br /&gt;</description><guid isPermaLink="true">c08869631502d2d759e6320c98ed6660</guid><pubDate>Sat, 31 Dec 2011 02:04:57 GMT</pubDate></item><item><title>Gwynne Raskind - 2011-12-23 23:10:20</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-12-23-disassembling-the-assembly-part-2.html#comments</link><description>&lt;b&gt;Jens:&lt;/b&gt;  I spent something like an hour trying to Goggle and otherwise look up that particular function attribute! I guess my Google-fu needs some work :). Thanks for the code listing!</description><guid isPermaLink="true">e0ae0e58515fa2fedcacce730290b16d</guid><pubDate>Fri, 23 Dec 2011 23:10:20 GMT</pubDate></item><item><title>Jens Ayton - 2011-12-23 22:55:08</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-12-23-disassembling-the-assembly-part-2.html#comments</link><description>&lt;div class="blogcommentquote"&gt;&lt;div class="blogcommentquoteinner"&gt;it turns out to be extremely difficult to get Clang to actually emit such assembly under optimizing compilation without just inlining the function, and the unoptimized version is different.&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;code&gt;__attribute__((noinline)) float MyFPFunction(float parameter)&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;The call and print sequence is:
&lt;br /&gt;&lt;code&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;movss&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LCPI1_0(%rip), %xmm0  # Load argument
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;callq&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_MyFPFunction
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cvtss2sd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%xmm0, %xmm0  # Promote to double
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;leaq&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;L__unnamed_cfstring_(%rip), %rdi
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;movb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$1, %al
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;callq&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_NSLog
&lt;br /&gt;&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;</description><guid isPermaLink="true">a8c598948fcc45d6bc84563648f2b0b7</guid><pubDate>Fri, 23 Dec 2011 22:55:08 GMT</pubDate></item></channel></rss>
