??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久亚洲裙底偷窥综合,久久精品国产99国产精品,久久不见久久见免费影院www日本http://www.shnenglu.com/Panda/zh-cnThu, 08 May 2025 17:54:33 GMTThu, 08 May 2025 17:54:33 GMT60Linux ?x86 的内联汇~?/title><link>http://www.shnenglu.com/Panda/archive/2010/10/25/131173.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Mon, 25 Oct 2010 03:28:00 GMT</pubDate><guid>http://www.shnenglu.com/Panda/archive/2010/10/25/131173.html</guid><wfw:comment>http://www.shnenglu.com/Panda/comments/131173.html</wfw:comment><comments>http://www.shnenglu.com/Panda/archive/2010/10/25/131173.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Panda/comments/commentRss/131173.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Panda/services/trackbacks/131173.html</trackback:ping><description><![CDATA[<p>如果您是 Linux 内核的开发h员,您会发现自己l常要对与体pȝ构高度相关的功能q行~码或优化代码\径。您很可能是通过汇~语a指o插入? C 语句的中_又称为内联汇~的一U方法)来执行这些Q务的。让我们看一? Linux 中内联汇~的特定用法。(我们讨论限制在 IA32 汇编。)</p> <p><a name="1"><span id="qmagw0w" class="atitle">GNU 汇编E序q?/span></a></p> <p>让我们首先看一?Linux 中用的基本汇编E序语法。GCCQ用?Linux ? GNU C ~译器)使用 AT&T 汇编语法。下面列Zq种语法的一些基本规则。(该列表肯定不完整Q只包括了与内联汇编相关的那些规则。)</p> <p><strong>寄存器命?/strong><br> 寄存器名U有 % 前缀。即Q如果必M?eaxQ它应该用作 %eax? </p> <p><strong>源操作数和目的操作数的顺?/strong><br> 在所有指令中Q先是源操作敎ͼ然后才是目的操作数。这与将源操作数攑֜目的操作C后的 Intel 语法不同? </p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">mov %eax, %ebx, transfers the contents of eax to ebx.<br></pre> </td> </tr> </tbody> </table> <br> <p><strong>操作数大?/strong><br> Ҏ操作数是字节 (byte)、字 (word) q是长型 (long)Q指令的后缀可以?b、w ?l。这q不是强制性的QGCC 会尝试通过d操作数来提供相应的后~。但手工指定后缀可以改善代码的可L,q可以消除编译器猜测不正的可能性? </p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">movb %al, %bl -- Byte move<br> movw %ax, %bx -- Word move<br> movl %eax, %ebx -- Longword move<br></pre> </td> </tr> </tbody> </table> <br> <p><strong>立即操作?/strong><br> 通过使用 $ 指定直接操作数? </p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">movl $0xffff, %eax -- will move the value of 0xffff into eax register.<br></pre> </td> </tr> </tbody> </table> <br> <p><strong>间接内存引用</strong><br> M对内存的间接引用都是通过使用 ( ) 来完成的? </p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">movb (%esi), %al -- will transfer the byte in the memory <br> pointed by esi into al<br>register<br></pre> </td> </tr> </tbody> </table> <br> <div id="esyw8uo" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="2"><span id="kqu08kw" class="atitle">内联汇编</span></a></p> <p>GCC 为内联汇~提供特D结构,它具有以下格式:</p> <p><strong>GCG ?"asm" l构</strong></p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode"> asm ( assembler template<br> <br>: output operands (optional)<br> <br>: input operands (optional)<br> <br>: list of clobbered registers <br> (optional)<br> <br>); <br></pre> </td> </tr> </tbody> </table> <br> <p> 本例中,汇编E序模板由汇~指令组成。输入操作数是充当指令输入操作数使用? C 表达式。输出操作数是将对其执行汇编指o输出?C 表达式?/p> <p>内联汇编的重要性体现在它能够灵zL作,而且可以使其输出通过 C 变量昄出来。因为它hq种能力Q所?"asm" 可以用作汇编指o和包含它?C E序之间的接口?/p> <p> 一个非常基本但很重要的区别在于 <em>单内联汇~?/em>只包括指令,? <em>扩展内联汇编</em>包括操作数。要说明q一点,考虑以下CZQ? </p> <p><strong>内联汇编的基本要?/strong></p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">{<br> int a=10, b;<br> asm ("movl %1, %%eax;<br> <br>movl %%eax, %0;"<br> :"=r"(b) /* output */ <br> :"r"(a) /* input */<br> :"%eax"); /* clobbered register */<br>}<br></pre> </td> </tr> </tbody> </table> <br> <p>在上例中Q我们用汇~指令 "b" 的值等? "a"。请注意以下几点Q?/p> <ul> <li>"b" 是输出操作数Q由 %0 引用Q?a" 是输入操作数Q由 %1 引用?/li> <li>"r" 是操作数的约束,它指定将变量 "a" ?"b" 存储在寄存器中。请注意Q输出操作数U束应该带有一个约束修饰符 "="Q指定它是输出操作数?/li> <li>要在 "asm" 内用寄存器 %eaxQ?eax 的前面应该再加一? %Q换句话说就?%%eaxQ因?"asm" 使用 %0?1 {来标识变量。Q何带有一?% 的数都看作是输入Q输出操作数Q而不认ؓ是寄存器?/li> <li>W三个冒号后的修饰寄存器 %eax 告诉在 "asm" 中修?GCC %eax 的|q样 GCC ׃使用该寄存器存储M其它的倹{?/li> <li><code>movl %1, %%eax</code> ?"a" 的值移?%eax 中, <code>movl %%eax, %0</code> ?%eax 的内容移? "b" 中? </li> <li>因ؓ "b" 被指定成输出操作敎ͼ因此?"asm" 的执行完成后Q它反映出更新的倹{换句话_?"asm" ?"b" 所做的更改在 "asm" 外反映出来?/li> </ul> <p>现在让我们更详细的了解每一的含义?/p> <div id="q6ey080" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="3"><span id="sakw0eu" class="atitle">汇编E序模板</span></a></p> <p>汇编E序模板是一l插入到 C E序中的汇编指oQ可以是单个指oQ也可以是一l指令)。每条指令都应该由双引号括vQ或者整l指令应该由双引h赗每条指令还应该用一个定界符l尾。有效的定界Wؓ新行 (\n) 和分?(;)?'\n' 后可以跟一?tab(\t) 作ؓ格式化符P增加 GCC 在汇~文件中生成的指令的可读性?指o通过?%0?1 {来引用 C 表达式(指定为操作数Q?/p> <p>如果希望保~译器不会在 "asm" 内部优化指oQ可以在 "asm" 后用关键字 "volatile"。如果程序必M ANSI C 兼容Q则应该使用 __asm__ ?__volatile__Q而不?asm ?volatile?/p> <div id="y8wqoa8" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="4"><span id="8wcy6e0" class="atitle">操作?/span></a></p> <p>C 表达式用?"asm" 内的汇编指o操作数。在汇编指o通过?C E序?C 表达式进行操作来执行有意义的作业的情况下Q操作数是内联汇~的主要Ҏ?/p> <p>每个操作数都由操作数U束字符串指定,后面跟用括弧括v?C 表达式,例如Q?constraint" (C expression)。操作数U束的主要功能是定操作数的d方式?/p> <p> 可以在输入和输出部分中同时用多个操作数。每个操作数由逗号分隔开?/p> <p>在汇~程序模板内部,操作数由数字引用。如果d? <em>n</em> 个操作数Q包括输入和输出Q,那么W一个输出操作数的编号ؓ 0Q逐项递增Q最后那个输入操作数的编号ؓ <em>n</em> -1。L作数的数目限制在 10Q如果机器描qCM指o模式中的最大操作数数目大于 10Q则使用后者作为限制? </p> <div id="ieaci0q" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="5"><span id="skmq8e8" class="atitle">修饰寄存器列?/span></a></p> <p>如果 "asm" 中的指o指的是硬件寄存器Q可以告?GCC 我们自׃用和修改它们。这PGCC ׃会假讑֮装入到这些寄存器中的值是有效倹{通常不需要将输入和输出寄存器列ؓ clobberedQ因?GCC 知道 "asm" 使用它们Q因为它们被明确指定为约束)。不q,如果指o使用M其它的寄存器Q无论是明确的还是隐含的Q寄存器不在输入U束列表中出玎ͼ也不在输出约束列表中出现Q,寄存器都必须被指定ؓ修饰列表。修饰寄存器列在W三个冒号之后,其名U被指定为字W串?/p> <p> 至于关键字,如果指o以某些不可预知且不明的方式修改了内存,则可能将 "memory" 关键字添加到修饰寄存器列表中。这样就告诉 GCC 不要在不同指令之间将内存值高速缓存在寄存器中?/p> <div id="o880o00" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="6"><span id="qigs808" class="atitle">操作数约?/span></a></p> <p>前面提到q,"asm" 中的每个操作数都应该由操作数U束字符串描qͼ后面跟用括弧括v?C 表达式。操作数U束主要是确定指令中操作数的d方式。约束也可以指定Q?/p> <ul> <li> 是否允许操作C于寄存器中,以及它可以包括在哪些U类的寄存器?/li> <li> 操作数是否可以是内存引用Q以及在q种情况下用哪些种cȝ地址</li> <li>操作数是否可以是立即?/li> </ul> <p>U束q要求两个操作数匚w?/p> <div id="88w0600" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="7"><span id="yi8u68q" class="atitle">常用U束</span></a></p> <p>在可用的操作数约束中Q只有一部分是常用的;下面列出了这些约束以及简要描q。有x作数U束的完整列表,请参? GCC ?GAS 手册?/p> <p><strong>寄存器操作数U束 (r)</strong><br> 使用q种U束指定操作数时Q它们存储在通用寄存器中。请看下例: </p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">asm ("movl %%cr3, %0\n" :"=r"(cr3val));<br></pre> </td> </tr> </tbody> </table> <br> <p>q里Q变?cr3val 保存在寄存器中,%cr3 的值复制到寄存器上Qcr3val 的g该寄存器更新到内存中。指?"r" U束ӞGCC 可以变?cr3val 保存在Q何可用的 GPR 中。要指定寄存器,必须通过使用特定的寄存器U束直接指定寄存器名?/p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">a %eax<br>b %ebx<br>c %ecx<br>d %edx<br>S %esi<br>D %edi<br></pre> </td> </tr> </tbody> </table> <br> <p><strong>内存操作数约?(m)</strong><br> 当操作数位于内存中时QQ何对它们执行的操作都在内存位置中直接发生,q与寄存器约束正好相反,后者先值存储在要修改的寄存器中Q然后将它写回内存位|中。但寄存器约束通常只在对于指o来说它们是绝对必需的,或者它们可以大大提高进E速度时用。当需要在 "asm" 内部更新 C 变量Q而您又确实不希望使用寄存器来保存其值时Q用内存约束最为有效。例如,idtr 的值存储在内存位置 loc 中: </p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode"> ("sidt %0\n" : :"m"(loc));<br></pre> </td> </tr> </tbody> </table> <br> <p><strong>匚wQ数字)U束</strong><br> 在某些情况下Q一个变量既要充当输入操作数Q也要充当输出操作数。可以通过使用匚wU束? "asm" 中指定这U情c? </p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">asm ("incl %0" :"=a"(var):"0"(var));<br></pre> </td> </tr> </tbody> </table> <br> <p>在匹配约束的CZ中,寄存?%eax 既用作输入变量,也用作输出变量。将 var 输入d? %eaxQ增加后更新的 %eax 再次存储?var 中。这里的 "0" 指定W?0 个输出变量相同的U束。即Q它指定 var 的输出实例只应该存储?%eax 中。该U束可以用于以下情况Q?/p> <ul> <li>输入从变量中dQ或者变量被修改后,修改写回到同一变量?/li> <li>不需要将输入操作数和输出操作数的实例分开</li> </ul> <p> 使用匚wU束最重要的意义在于它们可以导致有效地使用可用寄存器?/p> <div id="gi0ig6o" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="8"><span id="0qgk0ys" class="atitle">一般内联汇~用法示?/span></a></p> <p>以下CZ通过各种不同的操作数U束说明了用法。有如此多的U束以至于无法将它们一一列出Q这里只列出了最l常使用的那些约束类型?/p> <p><strong>"asm" 和寄存器U束 "r"</strong> 让我们先看一下用寄存器U束 r ?"asm"。我们的CZ昄?GCC 如何分配寄存器,以及它如何更新输出变量的倹{? </p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">int main(void)<br>{<br> int x = 10, y;<br> <br> asm ("movl %1, %%eax;<br> <br> "movl %%eax, %0;"<br> :"=r"(y) /* y is output operand */<br> :"r"(x) /* x is input operand */<br> :"%eax"); /* %eax is clobbered register */<br>}<br></pre> </td> </tr> </tbody> </table> <br> <p>在该例中Qx 的值复制ؓ "asm" 中的 y。x ?y 都通过存储在寄存器中传递给 "asm"。ؓ该例生成的汇~代码如下:</p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">main:<br>pushl %ebp<br>movl %esp,%ebp<br>subl $8,%esp<br>movl $10,-4(%ebp) <br>movl -4(%ebp),%edx /* x=10 is stored in %edx */<br>#APP /* asm starts here */ <br>movl %edx, %eax /* x is moved to %eax */<br>movl %eax, %edx /* y is allocated in edx and updated */<br>#NO_APP /* asm ends here */<br>movl %edx,-8(%ebp) /* value of y in stack is updated with <br> <br> the value in %edx */ <br></pre> </td> </tr> </tbody> </table> <br> <p>当?"r" U束ӞGCC 在这里可以自由分配Q何寄存器。在我们的示例中Q它选择 %edx 来存? x。在d?%edx ?x 的值后Q它?y 也分配了相同的寄存器?/p> <p>因ؓ y 是在输出操作数部分中指定的,所?%edx 中更新的值存储在 -8(%ebp)Q堆栈上 y 的位|中。如?y 是在输入部分中指定的Q那么即使它?y 的时寄存器存储?(%edx) 中被更新Q堆栈上 y 的g不会更新?/p> <p>因ؓ %eax 是在修饰列表中指定的QGCC 不在M其它地方使用它来存储数据?/p> <p>输入 x 和输?y 都分配在同一?%edx 寄存器中Q假设输入在输出产生之前被消耗。请注意Q如果您有许多指令,׃是这U情况了。要保输入和输出分配到不同的寄存器中,可以指定 & U束修饰W。下面是d了约束修饰符的示例?/p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">int main(void)<br>{<br> int x = 10, y;<br> <br> asm ("movl %1, %%eax;<br> <br> "movl %%eax, %0;"<br> :"=&r"(y) /* y is output operand, note the <br> <br> & constraint modifier. */<br> :"r"(x) /* x is input operand */<br> :"%eax"); /* %eax is clobbered register */<br>}<br></pre> </td> </tr> </tbody> </table> <br> <p>以下是ؓ该示例生成的汇编代码Q从中可以明昑֜看出 x ?y 存储? "asm" 中不同的寄存器中?/p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">main:<br>pushl %ebp<br>movl %esp,%ebp<br>subl $8,%esp<br>movl $10,-4(%ebp)<br>movl -4(%ebp),%ecx /* x, the input is in %ecx */<br>#APP<br> movl %ecx, %eax<br> movl %eax, %edx /* y, the output is in %edx */<br>#NO_APP<br>movl %edx,-8(%ebp)<br></pre> </td> </tr> </tbody> </table> <br> <div id="oqw8yya" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="9"><span id="issguom" class="atitle">特定寄存器约束的使用</span></a></p> <p>现在让我们看一下如何将个别寄存器作为操作数的约束指定。在下面的示例中Qcpuid 指o采用 %eax 寄存器中的输入,然后在四个寄存器中给出:%eax?ebx?ecx?edx。对 cpuid 的输入(变量 "op"Q传递到 "asm" ?eax 寄存器中Q因?cpuid 希望它这样做。在输出中?a、b、c ?d U束Q分别收集四个寄存器中的倹{?/p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">asm ("cpuid"<br>: "=a" (_eax),<br>"=b" (_ebx),<br>"=c" (_ecx),<br>"=d" (_edx)<br>: "a" (op));<br></pre> </td> </tr> </tbody> </table> <br> <p>在下面可以看Cؓ它生成的汇编代码Q假?_eax、_ebx {?.. 变量都存储在堆栈上)Q?/p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">movl -20(%ebp),%eax /* store 'op' in %eax -- input */<br>#APP<br>cpuid<br>#NO_APP<br>movl %eax,-4(%ebp) /* store %eax in _eax -- output */<br>movl %ebx,-8(%ebp) /* store other registers in<br>movl %ecx,-12(%ebp) <br> respective output variables */<br>movl %edx,-16(%ebp)<br></pre> </td> </tr> </tbody> </table> <br> <p>strcpy 函数可以通过以下方式使用 "S" ?"D" U束来实玎ͼ</p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">asm ("cld\n<br> <br>rep\n<br> <br>movsb"<br> <br>: /* no input */<br> <br>:"S"(src), "D"(dst), "c"(count));<br></pre> </td> </tr> </tbody> </table> <br> <p>通过使用 "S" U束源指针 src 攑օ %esi 中,使用 "D" U束目的指?dst 攑օ %edi 中。因?rep 前缀需?count |所以将它放?%ecx 中?/p> <p>在下面可以看到另一个约束,它用两个寄存器 %eax ?%edx 两? 32 位的值合q在一P然后生成一?4 位的|</p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">#define rdtscll(val) \<br> __asm__ __volatile__ ("rdtsc" : "=A" (val))<br>The generated assembly looks like this (if val has a 64 bit memory space).<br>#APP<br>rdtsc<br>#NO_APP<br>movl %eax,-8(%ebp) /* As a result of A constraint <br>movl %edx,-4(%ebp) <br> %eax and %edx serve as outputs */<br>Note here that the values in %edx:%eax serve as 64 bit output.<br></pre> </td> </tr> </tbody> </table> <br> <div id="88io000" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="10"><span id="cug0weu" class="atitle">使用匚wU束</span></a></p> <p>在下面将看到pȝ调用的代码,它有四个参数Q?/p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \<br>type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \<br>{ \<br>long __res; \<br>__asm__ volatile ("int $0x80" \<br>: "=a" (__res) \<br>: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \<br>"d" ((long)(arg3)),"S" ((long)(arg4))); \<br>__syscall_return(type,__res); \<br>}<br></pre> </td> </tr> </tbody> </table> <br> <p>在上例中Q通过使用 b、c、d ?S U束系l调用的四个自变量放? %ebx?ecx?edx ?%esi 中。请注意Q在输出中用了 "=a" U束Q这P位于 %eax 中的pȝ调用的返回值就被放入变?__res 中。通过匹配约?"0" 用作输入部分中第一个操作数U束Qsyscall ? __NR_##name 被放?%eax 中,q用作对pȝ调用的输入。这Pq里? %eax 既可以用作输入寄存器Q又可以用作输出寄存器。没有其它寄存器用于q个目的。另h意,输入Qsyscall P在生输出(syscall 的返回|之前被消耗(使用Q?/p> <div id="06uou6c" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link"> </a></p> <p><a name="11"><span id="8wqeseu" class="atitle">内存操作数约束的使用</span></a></p> <p>误虑下面的原子递减操作Q?/p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">__asm__ __volatile__(<br>"lock; decl %0"<br>:"=m" (counter)<br>:"m" (counter));<br></pre> </td> </tr> </tbody> </table> <br> <p>为它生成的汇~类gQ?/p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode">#APP<br> lock<br> decl -24(%ebp) /* counter is modified on its memory location */<br>#NO_APP.<br></pre> </td> </tr> </tbody> </table> <br> <p>您可能考虑在这里ؓ counter 使用寄存器约束。如果这样做Qcounter 的值必d复制到寄存器Q递减Q然后对其内存更新。但q样您会无法理解锁定和原子性的全部意图Q这些明显CZ使用内存U束的必要性?/p> <div id="8cmkoi0" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link"> </a></p> <p><a name="12"><span id="6myc8sq" class="atitle">使用修饰寄存?/span></a></p> <p>误虑内存拯的基本实现?/p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code-outline"> <pre class="displaycode"> asm ("movl $count, %%ecx;<br> <br>up: lodsl; <br> <br>stosl;<br> <br>loop up;"<br> : /* no output */<br> :"S"(src), "D"(dst) /* input */<br> :"%ecx", "%eax" ); /* clobbered list */ <br></pre> </td> </tr> </tbody> </table> <br> <p>?lodsl 修改 %eax Ӟlodsl ?stosl 指o隐含C用它?ecx 寄存器明装?count。但 GCC 在我们通知它以前是不知道这些的Q我们是通过?%eax ?%ecx 包括在修饰寄存器集中来通知 GCC 的。在完成q一步之前,GCC 假设 %eax ?%ecx 是自qQ它可能军_它们用作存储其它的数据。请注意Q?esi ?%edi ?"asm" 使用Q它们不在修饰列表中。这是因为已l声?"asm" 在输入操作数列表中使用它们。这里最低限度是Q如果在 "asm" 内部使用寄存器(无论是明还是隐含地Q,既不出现在输入操作数列表中,也不出现在输出操作数列表中,必须它列ؓ修饰寄存器?/p> <div id="skm0sg8" class="ibm-alternate-rule"><hr></div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link">回页?/a></p> <p><a name="13"><span id="s8s0u0o" class="atitle">l束?/span></a></p> <p>ȝ来说Q内联汇~非常巨大,它提供的许多Ҏ我们甚臛_q里Ҏ没有涉及到。但如果掌握了本文描q的基本材料Q您应该可以开始对自己的内联汇~进行编码了?/p> <br> <p><a name="resources"><span id="su000ii" class="atitle">参考资?</span></a></p> <ul> <li>您可以参阅本文在 developerWorks 全球站点上的 <a >英文原文</a>. <br><br></li> <li>请参? <a >Using and Porting the GNU Compiler Collection (GCC)</a>手册? <br><br></li> <li>请参? <a >GNU Assembler (GAS)</a>手册? <br><br></li> <li>仔细阅读 <a s Guide to Inline Assembly</a>? </li> </ul><img src ="http://www.shnenglu.com/Panda/aggbug/131173.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Panda/" target="_blank">ChinaPanda</a> 2010-10-25 11:28 <a href="http://www.shnenglu.com/Panda/archive/2010/10/25/131173.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>飞鸽协议以及其用的UDP数据包格式和文g传输逻辑http://www.shnenglu.com/Panda/archive/2010/01/11/105406.htmlChinaPandaChinaPandaMon, 11 Jan 2010 07:23:00 GMThttp://www.shnenglu.com/Panda/archive/2010/01/11/105406.htmlhttp://www.shnenglu.com/Panda/comments/105406.htmlhttp://www.shnenglu.com/Panda/archive/2010/01/11/105406.html#Feedback0http://www.shnenglu.com/Panda/comments/commentRss/105406.htmlhttp://www.shnenglu.com/Panda/services/trackbacks/105406.html阅读全文

ChinaPanda 2010-01-11 15:23 发表评论
]]>
?部分飞鸽协议http://www.shnenglu.com/Panda/archive/2010/01/07/105068.htmlChinaPandaChinaPandaThu, 07 Jan 2010 03:15:00 GMThttp://www.shnenglu.com/Panda/archive/2010/01/07/105068.htmlhttp://www.shnenglu.com/Panda/comments/105068.htmlhttp://www.shnenglu.com/Panda/archive/2010/01/07/105068.html#Feedback0http://www.shnenglu.com/Panda/comments/commentRss/105068.htmlhttp://www.shnenglu.com/Panda/services/trackbacks/105068.html最q看C些朋友在~写|络E序是遇C些问题,故把以前做IPMSG时翻译的文档贴过来,希望对网l编E新手有所帮助Q在L~程目的同学们也可参照此文档写qIPMSG?br>
本文只包含其中几个比较重要的命o以及q行机制的中文翻译,更详l的内容请参照文后的IPMSG 协议英文文档

声明Q下q协议内容略M一些在~写E序q程中没有用到协议内容,最初的Ipmsg协议是用日文写的Q下面协议内容由本h(cugb_cat)译自Mr.Kanazawa的英文文档。本译文档可Q意传播和使用?br>
        IP信传输协议(W?版草?         1996/02/21
                2003/01/14 修订

                H.Shirouzu
            shirouzu@h.email.ne.jp


关于IP信Q?br>   IP信使用TCP/UDP协议提供收发消息及文?目录)?br> Ҏ:
IP信能够安装在Q何一个安装了TCP/IP协议栈的操作pȝ上,使用在线用户的动态识别机Ӟ可以和在U所有用戯行信息交换?br> q行机制介绍Q?br> 使用TCP/UDP端口(默认端口?425)Q消息的收发使用UDP协议Q文?文g?的收发用TCP协议?br> 1?nbsp;  命o字:
1)   基本命o?32位命令字的低8?
    IPMSG_NOOPERATION     不进行Q何操?br>     IPMSG_BR_ENTRY     用户上线
    IPMSG_BR_EXIT         用户退?br>     IPMSG_ANSENTRY     通报在线
    IPMSG_SENDMSG         发送消?br>     IPMSG_RECVMSG         通报收到消息
    IPMSG_GETFILEDATA     h通过TCP传输文g
    IPMSG_RELEASEFILES   停止接收文g
    IPMSG_GETDIRFILES     h传输文g?br> 2)   选项?32位命令字的高24?
IPMSG_SENDCHECKOPT   传送检?需要对方返回确认信?
IPMSG_FILEATTACHOPT   传送文仉项
3)   附gcd命o(文gcd命o字的??
IPMSG_FILE_REGULAR   普通文?br> IPMSG_FILE_DIR     目录文g
IPMSG_FILE_RETPARENT   q回上一U目?br> 2?nbsp;  数据包格?使用字符?Q?br> 1)   数据包格?版本1的格?
版本?1):包编?发送者姓?发送者主机名:命o?附加信息
2)   举例如下
“1:100:shirouzu:Jupiter:32:Hello”
3?nbsp;  数据包处理总述Q?br> 1)   用户识别
当IPMSG 启动Ӟ命oIPMSG_BR_ENTRY被广播到|络中,向所有在U的用户提示一个新用户的到?卌C?#8220;我来?#8221;)Q所有在U用户将把该CU用h 加到自己的用户列表中Qƈ向该CU用户发送IPMSG_ANSENTRY命o(卌C?#8220;我在U?#8221;)Q该CU用h收到IPMSG_ANSENTRY? 令后卛_在线用户d到自q用户列表中?br> 2)   收发消息
使用IPMSG_SENDMSG命o发送消息,消息内容d在附加信息中Q在接收消息Ӟ如果Ҏ要求回信认(IPMSG_SENDCHECKOPT位打开)Q则需发送IPMSG_RECVMSG命oq将Ҏ发送的数据包的~号攑֜附加信息中一同发送至发送消息方
3)   附加文g的扩?d于第9?
带有IPMSG_FILEATTACHOPT位的IPMSG_SENDMSG命o可用来传输文Ӟ文g属性及内容d在附加信息中Q文件内Ҏ加在消息? 容后q以’\0’与之分隔开。传输文件时以下信息被d到消息内容之?包括格式)Q文件序?文g?大小(单位:字节):最后修Ҏ?文g属? [: 附加属?val1[,val2…][:附加信息=…]]:\a:文g序号…
(文g大小、最后修Ҏ间和文g属性ؓ十六q制敎ͼ如果文g名中包含’:’则?#8220;::”代替)?br> 接收端开始接收文件时Q请求传输文件命令IPMSG_GETFILEDATA发送到发送端的TCP端口(和UDP的发送端口相?Qƈ发送端发送的? ~号:文g序号:偏移?全ؓ十六q制格式)写到附加信息Z同发送,文g发送端接收到该h信息q进行校验正后卛_始发送文?不用Q何格式,亦不 q行加密)?br> 当接收端接收到目录文件时Q将发送附加信息区为发送端发送的包编?文g序号:偏移?全ؓ十六q制格式)? IPMSG_GETDIRFILES命oQ以用来h传输目录文gQ发送端则将头信息长?文g?文g大小:文g属?文g内容d到附加信息区(除了 文g名和文g内容外,其余皆ؓ十六q制)Q头信息长度是从头信息长度开始到文g内容前的‘:’分割Wؓ止的字符个数?br> 当文件属性ؓIPMSG_FILE_DIRӞIPMsg能够自动识别其ؓ目录Q下一个文件的数据在该目录之后?br> 当文件属性ؓIPMSG_FILE_RETPARENTӞIPMsg识别其动作ؓq回上一U目录,在这U情况下Q文件名?#8216;.’其属性ؓ当前目录的倹{?br>
附IPMSG协议英文?



Original ipmsg protocol specification is written in Japanese.
This document was translated by Mr.Kanazawa.
This document is not verified yet.

----------------------------------------------------------------------
    IP Messenger communication protocol (Draft-9) 1996/02/21
                                Modified 2003/01/14

                                    H.Shirouzu
                              shirouzu@h.email.ne.jp
----------------------------------------------------------------------

About IP Messenger
    This is a Send/Receive message service using the TCP/UDP Port.

Characteristics
    IP Messenger can be installed in any OS if TCP/IP is used on your machine.
    Dynamic member recognition can be done within your network or specified network.
    You can exchange messages between all IPMsg members.

Function description
    Use TCP/UDP port(default:2425). See the following descriptions
    (Message Send/Receive: UDP, File Send/Receive: TCP)

1. Command

  1) Command functions (Low 8 bits from command number 32 bits)

    IPMSG_NOOPERATION No Operation
    IPMSG_BR_ENTRY Entry to service (Start-up with a Broadcast command)
    IPMSG_BR_EXIT Exit from service (End with a Broadcast command)
    IPMSG_ANSENTRY Notify a new entry
    IPMSG_BR_ABSENCE Change absence mode

    IPMSG_BR_ISGETLIST Search valid sending host members
    IPMSG_OKGETLIST Host list sending notice
    IPMSG_GETLIST Host list sending request
    IPMSG_ANSLIST Host list sending

    IPMSG_SENDMSG Message transmission
    IPMSG_RECVMSG Message receiving check

    IPMSG_READMSG Message open notice
    IPMSG_DELMSG Message discarded notice
    IPMSG_ANSREADMSG Message open confirmation notice(added from version-8 )

    IPMSG_GETFILEDATA File Transfer request by TCP
    IPMSG_RELEASEFILES Discard attachment file
    IPMSG_GETDIRFILES Attachment hierarchical file request

    IPMSG_GETINFO Get IPMSG version info.
    IPMSG_SENDINFO Send IPMSG version info.

    IPMSG_GETABSENCEINFO Get absence sentence
    IPMSG_SENDABSENCEINFO Send absence sentence

    IPMSG_GETPUBKEY RSA Public Key Acquisition
    IPMSG_ANSPUBKEY RSA Public Key Response

  2) Option flag (High 24 bits from command number 32 bits)

    IPMSG_ABSENCEOPT Absence mode(Member recognition command)
    IPMSG_SERVEROPT Server(Reserved)
    IPMSG_DIALUPOPT Send individual member recognition command

    IPMSG_SENDCHECKOPT Transmission check
    IPMSG_SECRETOPT Sealed message
    IPMSG_READCHECKOPT Sealed message check(added from ver8 )
    IPMSG_PASSWORDOPT Lock
    IPMSG_BROADCASTOPT Broadcast message
    IPMSG_MULTICASTOPT Multi-cast(Multiple casts selection)
    IPMSG_NEWMUTIOPT New version multi-cast(reserved)
    IPMSG_AUTORETOPT Automatic response(Ping-pong protection)
    IPMSG_NOLOGOPT No log files
    IPMSG_NOADDLISTOPT Notice to the members outside of BR_ENTRY

    IPMSG_FILEATTACHOPT File attachment
    IPMSG_ENCRYPTOPT Code

    IPMSG_NOPOPUPOPT (No longer valid)
    IPMSG_RETRYOPT Re-send flag(Use when acquiring HOSTLIST)

  3) Extended code flag (hex format combination)

    IPMSG_RSA_512
    IPMSG_RSA_1024
    IPMSG_RSA_2048
    IPMSG_RC2_40
    IPMSG_RC2_128
    IPMSG_RC2_256
    IPMSG_BLOWFISH_128
    IPMSG_BLOWFISH_256
    IPMSG_SIGN_MD5

  4) Extended files for attachment (fileattr low 8 bits)

    IPMSG_FILE_REGULAR
    IPMSG_FILE_DIR
    IPMSG_FILE_RETPARENT
    IPMSG_FILE_SYMLINK
    IPMSG_FILE_CDEV
    IPMSG_FILE_BDEV
    IPMSG_FILE_FIFO
    IPMSG_FILE_RESFORK

  5) Attachment file extended attribute(fileattr high 24 bits)

    IPMSG_FILE_RONLYOPT
    IPMSG_FILE_HIDDENOPT
    IPMSG_FILE_EXHIDDENOPT
    IPMSG_FILE_ARCHIVEOPT
    IPMSG_FILE_SYSTEMOPT

  6) Extended file attribute for attachment file

    IPMSG_FILE_UID
    IPMSG_FILE_USERNAME
    IPMSG_FILE_GID
    IPMSG_FILE_GROUPNAME
    IPMSG_FILE_PERM
    IPMSG_FILE_MAJORNO
    IPMSG_FILE_MINORNO
    IPMSG_FILE_CTIME
    IPMSG_FILE_MTIME
    IPMSG_FILE_ATIME
    IPMSG_FILE_CREATETIME

    IPMSG_FILE_CREATOR
    IPMSG_FILE_FILETYPE
    IPMSG_FILE_FINDERINFO

    IPMSG_FILE_ACL
    IPMSG_FILE_ALIASFNAME
    IPMSG_FILE_UNICODEFNAME


2.Command format(Use all character strings)

  1) Command(Format version-1)

    Ver(1) : PacketNo : SenderName : SenderHost : CommandNo : AdditionalSection

  2) An example for Message Send/Receive by using the current command format

    "1:100:shirouzu:jupiter:32:Hello"


3.Command process overview

  1) Member recognition

    An IPMSG_BR_ENTRY command notifies a new entry to the current
    members at start-up.

    All members add the new member to their list after getting a notification message.
    An IPMSG_ANSENTRY command sends a message back to the new member.

    The new member gets the current member data by a
    IPMSG_ANSENTRY command. All members can communicate as long as an
    IP packet exists.

    An IPMSG_BR_ABSENCE command broadcasts absence mode cancel or
    nickname change to all members. However, an IPMSG_ANSENTRY command
    does not send a message back, which is different from an IPMSG_BR_ENTRY
    command.

    IPMSG_BR_ENTRY, IPMSG_ANSENTRY, and IPMSG_BR_ABSENCE commands
    use an IPMSG_ABSENCEOPT flag for absence mode. Input a nickname to
    additional command.
    Add an IPMSG_DIALUPOPT flag for dial-up users who can't be reached by
    a broadcast command. A member recognition command needs to be
    sent individually to the members with this optional flag.

    (Extended group)IPMSG_BR_ENTRY and IPMSG_BR_ABSENCE commands
    sends a group name by adding the new group name after the current
    command format character strings (Input '
\0' between the current
    command and extended name).

  2) Send/Receive Message
    Send Message uses an IPMSG_SENDMSG command that can input a message
    in the extended area.
    Receive Message sends back an IPMSG_RECVMSG command only
    if an IPMSG_SENDCHECKOPT flag is ON. Input the original packet number
    to the extended area.

    Broadcast Message Send uses an IPMSG_BOADCASTOPT command
    and an IPMSG_SENDMSG flag should be ON.
    Auto-Send packet(absence notice) needs to be added to IPMSG_AUTORETOPT
    for ping-pong protection. If either one or another packet is ON, then
    confirmation/auto-send packet is not sent back.

    Send Message Sealing needs to be an IPMSG_SECRETOPT packet ON.
    In this case, Receive Message sends an IPMSG_READMSG command.
    Input the original packet number to the extended area.

    (Additional IPMSG_NOADDLISTOPT)
    When receiving an IPMSG_SENDMSG packet from a host that is
    not on your Send/Receive list, IPMsg will either confirm a host by
    sending an IPMSG_BR_ENTRY command or add a host name to
    the Send/Receive list.
    However, single-shot Message Send/Receive action needs to be avoided.
    Add an IPMSG_NOADDLISTOPT flag to an IPMSG_SENDMSG command.

    (Additional IPMSG_READCHECKOPT from version-8 )
    When an IPMSG_READMSG command contains an IPMSG_READCHECKOPT flag,
    IPMsg process is the same as IPMSG_SENDMSG with an
    IPMSG_SENDCHECKOPT flag.
    However, Send Message uses an IPMSG_ANSREADMSG command,
    not IPMSG_RECVMSG.

  3) Message Send/Receive 亅encrypted extension (Added in the version-9 )

    Use the combination of Public-key(RSA) and common key(RC2/Blowfish).
    (Encrypted extension area is used in hex format.)

    (Public key acquisition)Send an IPMSG_GETPUBKEY command to Receive
    Message. Receive Message gets an IPMSG_ANSPUBKEY that
    means receiving RSA public key from Send Message.

    IPMSG_GETPUBKEY/IPMSG_ANSPUBKEY both require the value which is
    encryption capability (Exp. IPMSG_RSA_1024) flag uses "OR" at first
    part of extension

    In addition, In IPMSG_ANSPUBKEY, public key written as EE-NNNNNN
    E=Exponent丄N=method)devide by '
:'. and Input the Fdelimiter '-'
    between E and N.

    This sequence can be skipped after the 2nd Send/Receive process by
    memorizing public key and encrypted data.
   
    (Encrypted message)After a sender creates a common key that is
    supported both sender and receiver, a common key can encrypt a message.
    In addition, a receiver'
s public key encrypts the common key.


    (Encrypted message transmission) IPMSG_ENCRYPTOPT is used in
    IPMSG_SENDMSG. At the first part of extension, input the value which
    is 'or' resoult from Convination of public key and common key type .
    Then use common key which encrypt with public key devide by ':'.
    Then input message which is eccrypted by public key devide by ':'.
    If both supports IPMSG_SIGN_XXX, then add ':' and signeture.

    Also, In the method of encode padding, PKCS#1ECB key is used for RSA,
    PKCS#5 CBC common key is used for RC2/blowfish.

    Also, The Packet related to Entry manifestation the capability of
    ecryption support using IPMSG_ENCRYPTOPT

  4) Extension with file attachment(Available from version-9 )

    An IPMSG_SENDMSG command with an IPMSG_FILEATTACHOPT flag for
    File transfer (download permission)notification sends a message
    with attachment.
    Input '\0' after the message and attachment file data.
   

    fileID:filename:size:mtime:fileattr[:extend-attr=val1
    [,val2...][:extend-attr2=...]]:\a:fileID...
    (size, mtime, and fileattr describe hex format.
      If a filename contains ':', please replace with "::".)

    When Receive Message downloads an attachment file, an IPMSG_GETFILEDATA
    command requests a data transmission packet to the TCP port that is the same number
    as the UDP sending port number. Input packetID:fileID: offset to the extended area.
    (Use all hex format.)
    File Transfer side receives the request. After recognizing that it's a correct request,
    then send the specified data (no format)

    When the data receiving side downloads a hierarchical attachment file,
    use an IPMSG_GETDIRFILES command and input a packetID:fileID
    to the extended area and send a data transmission request packet.
    (all hex format)

    Data sending side sends the following hierarchical data format.
    header-size:filename:file-size:fileattr[:extend-attr=val1
    [,val2...][:extend-attr2=...]]:contents-data
    Next headersize: Next filename...
    (All hex format except for filename and contetns-data)

    header-size is from the beginning of header-size to the delimiter '
:'
    that is before contents-data. extend-attr can be omitted and used multiple
    extended attributes. Use '
=' for data input.

    When fileattr is IPMSG_FILE_DIR, IPMsg recognizes that it is automatically
    in the directory, the next file data is after the directory.

    When fileattr is IPMSG_FILE_RETPARENT, IMPsg recognizes that it returns
    to the parent directory. In this case, File name is always "." and the attribute
    value is the current directory data.

    Sending process starts from the attachment directly and returns the
    IPMSG_FILE_RETPARENT command to the attachment directory.

    Add an IPMSG_FILEATTACHOPT flag for an Entry packet to support the
    attachment file.

  5) Other commands

    When acquiring different versions, send an IPMSG_GETINFO command.
    Receiving side sends the version information character string to
    extended area.

    Send an IPMSG_GETABSENCEINFO command for acquiring an absence message.
    Receiving side sends an IPMSG_SENDABSENCEINFO back if the status is absence mode.
    If the status is not absence mode, a character string "Not absence mode" will be sent back.

  6) Confirmation/Retry

    If a confirmation packet for IPMSG_SENDMSG or IPMSG_RECVMSG is not delivered
    within a specified time, then it will be sent again.
    A number of retry actions or interval period is depended on the current condition.


4. Other

  1) Linefeed

    Linefeed characters in Send Message is standardized with UNIX type ('
0x0a').
    Please change if needed.

  2) Delimiter '
:'

    '
:' is used as a delimiter. You can't use this delimiter for user name
    and host name.
    If the use/host names contain a ':', please replace with another sign,
    for an example ';'.
    Although using this delimiter isn



ChinaPanda 2010-01-07 11:15 发表评论
]]>
ACE about serverhttp://www.shnenglu.com/Panda/archive/2009/12/23/103803.htmlChinaPandaChinaPandaWed, 23 Dec 2009 07:59:00 GMThttp://www.shnenglu.com/Panda/archive/2009/12/23/103803.htmlhttp://www.shnenglu.com/Panda/comments/103803.htmlhttp://www.shnenglu.com/Panda/archive/2009/12/23/103803.html#Feedback1http://www.shnenglu.com/Panda/comments/commentRss/103803.htmlhttp://www.shnenglu.com/Panda/services/trackbacks/103803.html阅读全文

ChinaPanda 2009-12-23 15:59 发表评论
]]>
AT&T指o?/title><link>http://www.shnenglu.com/Panda/archive/2009/12/08/102799.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Tue, 08 Dec 2009 07:48:00 GMT</pubDate><guid>http://www.shnenglu.com/Panda/archive/2009/12/08/102799.html</guid><wfw:comment>http://www.shnenglu.com/Panda/comments/102799.html</wfw:comment><comments>http://www.shnenglu.com/Panda/archive/2009/12/08/102799.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/Panda/comments/commentRss/102799.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Panda/services/trackbacks/102799.html</trackback:ping><description><![CDATA[     摘要: GAS中每个操作都是有一个字W的后缀Q表明操作数的大? C声明 GAS后缀 大小(字节) ...  <a href='http://www.shnenglu.com/Panda/archive/2009/12/08/102799.html'>阅读全文</a><img src ="http://www.shnenglu.com/Panda/aggbug/102799.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Panda/" target="_blank">ChinaPanda</a> 2009-12-08 15:48 <a href="http://www.shnenglu.com/Panda/archive/2009/12/08/102799.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一致与非一致性代码段http://www.shnenglu.com/Panda/archive/2009/10/18/98858.htmlChinaPandaChinaPandaSat, 17 Oct 2009 18:08:00 GMThttp://www.shnenglu.com/Panda/archive/2009/10/18/98858.htmlhttp://www.shnenglu.com/Panda/comments/98858.htmlhttp://www.shnenglu.com/Panda/archive/2009/10/18/98858.html#Feedback0http://www.shnenglu.com/Panda/comments/commentRss/98858.htmlhttp://www.shnenglu.com/Panda/services/trackbacks/98858.html阅读全文

ChinaPanda 2009-10-18 02:08 发表评论
]]>
W二?pȝ架构览2.5http://www.shnenglu.com/Panda/archive/2009/09/27/97411.htmlChinaPandaChinaPandaSun, 27 Sep 2009 15:13:00 GMThttp://www.shnenglu.com/Panda/archive/2009/09/27/97411.htmlhttp://www.shnenglu.com/Panda/comments/97411.htmlhttp://www.shnenglu.com/Panda/archive/2009/09/27/97411.html#Feedback0http://www.shnenglu.com/Panda/comments/commentRss/97411.htmlhttp://www.shnenglu.com/Panda/services/trackbacks/97411.html阅读全文

ChinaPanda 2009-09-27 23:13 发表评论
]]>
copy on writehttp://www.shnenglu.com/Panda/archive/2009/09/27/97390.htmlChinaPandaChinaPandaSun, 27 Sep 2009 11:41:00 GMThttp://www.shnenglu.com/Panda/archive/2009/09/27/97390.htmlhttp://www.shnenglu.com/Panda/comments/97390.htmlhttp://www.shnenglu.com/Panda/archive/2009/09/27/97390.html#Feedback0http://www.shnenglu.com/Panda/comments/commentRss/97390.htmlhttp://www.shnenglu.com/Panda/services/trackbacks/97390.html    
  对象之间的复制只通过引用计数来表C,内部其实只有一份对象实例。一旦对象发生变化,才创建对象,然后复制原对象? 
  q可以大大提高效率?img src ="http://www.shnenglu.com/Panda/aggbug/97390.html" width = "1" height = "1" />

ChinaPanda 2009-09-27 19:41 发表评论
]]>
CPUl构介绍http://www.shnenglu.com/Panda/archive/2009/09/23/96988.htmlChinaPandaChinaPandaTue, 22 Sep 2009 16:10:00 GMThttp://www.shnenglu.com/Panda/archive/2009/09/23/96988.htmlhttp://www.shnenglu.com/Panda/comments/96988.htmlhttp://www.shnenglu.com/Panda/archive/2009/09/23/96988.html#Feedback0http://www.shnenglu.com/Panda/comments/commentRss/96988.htmlhttp://www.shnenglu.com/Panda/services/trackbacks/96988.html64位处理器 q里?4位技术是相对?2位而言的,q个位数指的是CPU GPRsQGeneral-Purpose RegistersQ通用寄存器)的数据宽度ؓ64位,64位指令集是q行64位数据的指oQ也是说处理器一ơ可以运?4bit数据?4bit? 理器q现在才有的,在高端的RISCQReduced Instruction Set ComputingQ精指o集计机Q很早就?4bit处理器了Q比如SUN公司的UltraSparc Ⅲ、IBM公司的POWER5、HP公司的Alpha{?br> 64bit计算主要有两大优点:可以q行更大范围的整数运;可以支持更大的内存。不能因为数 字上的变化,而简单的认ؓ64bit处理器的性能?2bit处理器性能的两倍。实际上?2bit应用下,32bit处理器的性能甚至会更强,即? 64bit处理器,目前情况下也是在32bit应用下性能更强。所以要认清64bit处理器的优势Q但不可q信64bit?br> 要实现真正意义上?4位计,光有64位的处理器是不行的,q必d?4位的操作pȝ以及 64位的应用软g才行Q三者缺一不可Q缺其中Q何一U要素都是无法实?4位计的。目前,?4位处理器斚wQIntel和AMD两大处理器厂商都? 布了多个pd多种规格?4位处理器Q而在操作pȝ和应用Y件方面,目前的情况不容乐观。因为真正适合于个Z用的64位操作系l现在就只有 Windows XP X64Q而Windows XP X64本n也只是一个过渡性质?4位操作系l,在Windows Vista发布以后将被淘汎ͼ而且Windows XP X64本n也不太完善,易用性不高,一个明昄例子是各种g讑֤的驱动程序很不完善,而且现在64位的应用软gq基本上没有Q确实硬件厂商和软g厂商 也不愿意Mؓ一个过渡性质的操作系l编写驱动程序和应用软g。所以要惛_现真正的64位计,恐怕还得等到Windows Vista普及一D|间之后才行?br> 目前LCPU使用?4位技术主要有AMD公司的AMD64位技术、Intel公司? EM64T技术、和Intel公司的IA-64技术。其中IA-64是Intel独立开发,不兼容现在的传统?2位计机Q仅用于ItaniumQ安 腾)以及后箋产品Itanium 2Q一般用户不会涉及到Q因此这里仅对AMD64位技术和Intel的EM64T技术做一下简单介l?br> AMD64位技?br> AMD64的位技术是在原?2位X86指o集的基础上加入了X86-64扩展64位X86? 令集Qɘq款芯片在硬件上兼容原来?2位X86软gQƈ同时支持X86-64的扩?4位计,使得q款芯片成ؓ真正?4位X86芯片。这是一个真? ?4位的标准QX86-64h64位的d能力?br> X86-64新增的几lCPU寄存器将提供更快的执行效率。寄存器是CPU内部用来创徏和储? CPUq算l果和其它运结果的地方。标准的32-bit x86架构包括8个通用寄存器(GPRQ,AMD在X86-64中又增加?l(R8-R9Q,寄存器的数目提高到?6l。X86-64寄存器默认位 64-bit。还增加?l?28-bit XMM寄存器(也叫SSE寄存器,XMM8-XMM15Q,能l单指o多数据流技术(SIMDQ运提供更多的I间Q这?28位的寄存器将提供在矢? 和标量计模式下q行128位双_ֺ处理Qؓ3D建模、矢量分析和虚拟现实的实现提供了g基础。通过提供了更多的寄存器,按照X86-64标准生? CPU可以更有效的处理数据Q可以在一个时钟周期中传输更多的信息?
EM64T技?br> Intel官方是给EM64Tq样定义的:EM64T全称Extended Memory 64 TechnologyQ即扩展64bit内存技术。EM64T是Intel IA-32架构的扩展,即IA-32eQIntel Architectur-32 extensionQ。IA-32处理器通过附加EM64T技术,便可在兼容IA-32软g的情况下Q允许Y件利用更多的内存地址I间Qƈ且允许Y件进? 32 bitU性地址写入。EM64T特别的是?2 bit?4 bit的兼Ҏ。Intel为新核心增加??4 bit GPRsQR8-R15Q,q且把原有GRPs全部扩展?4 bitQ如前文所q这样可以提高整数运能力。增??28bit SSE寄存器(XMM8-XMM15Q,是ؓ了增强多媒体性能Q包括对SSE、SSE2和SSE3的支持?br> Intel为支持EM64T技术的处理器设计了两大模式Q传lIA-32模式Qlegacy IA-32 modeQ和IA-32e扩展模式QIA-32e modeQ。在支持EM64T技术的处理器内有一个称之ؓ扩展功能Ȁzd存器Qextended feature enable registerQIA32_EFERQ的部gQ其中的Bit10控制着EM64T是否ȀzRBit10被称作IA-32e模式有效QIA-32e mode activeQ或长模式有效(long mode activeQLMA)。当LMAQ?Ӟ处理器便作ؓ一颗标准的32 bitQIA32Q处理器q行在传lIA-32模式Q当LMAQ?ӞEM64T便被Ȁz,处理器会q行在IA-32e扩展模式下?br> 目前AMD斚w支持64位技术的CPU有Athlon 64pd、Athlon FXpd和Opteronpd。Intel斚w支持64位技术的CPU有用Nocona核心的Xeonpd、用Prescott 2M核心的Pentium 4 6pd和用Prescott 2M核心的P4 EEpd?br>

IA-32QIntel Architecture-32Q称特尔32位结构,表示指o集结构ISAQInstruction Set ArchitectureQ?br>
IA-32处理器(或称32?0x86处理器)是指具有该指o集结构的处理器,例如q公司的80386?0486以及Pentium各代处理器。AMD?2位处理器兼容q个l构?br>


ChinaPanda 2009-09-23 00:10 发表评论
]]>
W二?pȝ架构览2.2-2.4节http://www.shnenglu.com/Panda/archive/2009/09/22/96986.htmlChinaPandaChinaPandaTue, 22 Sep 2009 15:59:00 GMThttp://www.shnenglu.com/Panda/archive/2009/09/22/96986.htmlhttp://www.shnenglu.com/Panda/comments/96986.htmlhttp://www.shnenglu.com/Panda/archive/2009/09/22/96986.html#Feedback0http://www.shnenglu.com/Panda/comments/commentRss/96986.htmlhttp://www.shnenglu.com/Panda/services/trackbacks/96986.html阅读全文

ChinaPanda 2009-09-22 23:59 发表评论
]]>
ҹƷþþþþ99| VۺVŷþ| þþƷվ| þҹɫƷ鶹| 㽶þӰԺ| þˬˬƬAV| þӰԺþ㽶߿ۿ| þseֻоƷ| þþþƷþþþþ| þۺav| þþƷѲ| þۺϳDž| Ʒþþþþ˳| þþƷվ| 99þùۺϾƷ| ޹Ʒþ98| 볬鱬Ļþ| ŷƷþþ| þþƷƷ޾Ʒ | þֻƷ99| ɫۺɫþû| ëƬþþþþùëƬ| ŷҹAŴƬþ| ޾þˬ˾Ʒ| þþþAVרJN| ɫۺϾþĻ| þþƷƵ| ݺɫþۺ_ | 99Ʒþþþþþó| ž99Ʒþþþþ| ŷպ˾Ʒþþѿ| ޹㽶ˬAVƬþ| þþһƷ99þþƷ66 | www.þ99| ŷҹƷþþþþ˳| ۺϾþþþ| ŷԴսþþþþ| ˬˬƬaþ| ŷ˾þô߽ۺ| þþƷۺɫ| þþþAVվ|