﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Panda</title><link>http://www.cppblog.com/Panda/</link><description /><language>zh-cn</language><lastBuildDate>Mon, 13 Apr 2026 18:10:25 GMT</lastBuildDate><pubDate>Mon, 13 Apr 2026 18:10:25 GMT</pubDate><ttl>60</ttl><item><title>Linux 中 x86 的内联汇编</title><link>http://www.cppblog.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.cppblog.com/Panda/archive/2010/10/25/131173.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/131173.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2010/10/25/131173.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/131173.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/131173.html</trackback:ping><description><![CDATA[<p>如果您是 Linux
内核的开发人员，您会发现自己经常要对与体系结构高度相关的功能进行编码或优化代码路径。您很可能是通过将汇编语言指令插入到
C
语句的中间（又称为内联汇编的一种方法）来执行这些任务的。让我们看一下
Linux 中内联汇编的特定用法。（我们将讨论限制在 IA32 汇编。）</p>
<p><a name="1"><span class="atitle">GNU
汇编程序简述</span></a></p>
<p>让我们首先看一下 Linux 中使用的基本汇编程序语法。GCC（用于 Linux 的
GNU C 编译器）使用 AT&amp;T
汇编语法。下面列出了这种语法的一些基本规则。（该列表肯定不完整；只包括了与内联汇编相关的那些规则。）</p>
<p><strong>寄存器命名</strong><br>
寄存器名称有 % 前缀。即，如果必须使用 eax，它应该用作 %eax。
</p>
<p><strong>源操作数和目的操作数的顺序</strong><br>
在所有指令中，先是源操作数，然后才是目的操作数。这与将源操作数放在目的操作数之后的
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) 还是长型
(long)，指令的后缀可以是 b、w 或 l。这并不是强制性的；GCC
会尝试通过读取操作数来提供相应的后缀。但手工指定后缀可以改善代码的可读性，并可以消除编译器猜测不正确的可能性。
</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>
任何对内存的间接引用都是通过使用 ( ) 来完成的。
</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 class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="2"><span class="atitle">内联汇编</span></a></p>
<p>GCC 为内联汇编提供特殊结构，它具有以下格式：</p>
<p><strong>GCG 的 "asm" 结构</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>
本例中，汇编程序模板由汇编指令组成。输入操作数是充当指令输入操作数使用的
C 表达式。输出操作数是将对其执行汇编指令输出的 C 表达式。</p>
<p>内联汇编的重要性体现在它能够灵活操作，而且可以使其输出通过 C
变量显示出来。因为它具有这种能力，所以 "asm"
可以用作汇编指令和包含它的 C 程序之间的接口。</p>
<p>
一个非常基本但很重要的区别在于
<em>简单内联汇编</em>只包括指令，而
<em>扩展内联汇编</em>包括操作数。要说明这一点，考虑以下示例：
</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>在上例中，我们使用汇编指令使 "b" 的值等于
"a"。请注意以下几点：</p>
<ul>
    <li>"b" 是输出操作数，由 %0 引用，"a" 是输入操作数，由 %1
    引用。</li>
    <li>"r" 是操作数的约束，它指定将变量 "a" 和 "b"
    存储在寄存器中。请注意，输出操作数约束应该带有一个约束修饰符
    "="，指定它是输出操作数。</li>
    <li>要在 "asm" 内使用寄存器 %eax，%eax 的前面应该再加一个
    %，换句话说就是 %%eax，因为 "asm" 使用 %0、%1
    等来标识变量。任何带有一个 %
    的数都看作是输入／输出操作数，而不认为是寄存器。</li>
    <li>第三个冒号后的修饰寄存器 %eax 告诉将在 "asm" 中修改 GCC %eax
    的值，这样 GCC 就不使用该寄存器存储任何其它的值。</li>
    <li><code>movl %1, %%eax</code> 将 "a" 的值移到 %eax
    中，
    <code>movl %%eax, %0</code> 将 %eax 的内容移到
    "b" 中。
    </li>
    <li>因为 "b" 被指定成输出操作数，因此当 "asm"
    的执行完成后，它将反映出更新的值。换句话说，对 "asm" 内 "b"
    所做的更改将在 "asm" 外反映出来。</li>
</ul>
<p>现在让我们更详细的了解每一项的含义。</p>
<div class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="3"><span class="atitle">汇编程序模板</span></a></p>
<p>汇编程序模板是一组插入到 C
程序中的汇编指令（可以是单个指令，也可以是一组指令）。每条指令都应该由双引号括起，或者整组指令应该由双引号括起。每条指令还应该用一个定界符结尾。有效的定界符为新行
(\n) 和分号 (;)。 '\n' 后可以跟一个 tab(\t) 作为格式化符号，增加
GCC 在汇编文件中生成的指令的可读性。 指令通过数 %0、%1 等来引用 C
表达式（指定为操作数）。</p>
<p>如果希望确保编译器不会在 "asm" 内部优化指令，可以在 "asm"
后使用关键字 "volatile"。如果程序必须与 ANSI C 兼容，则应该使用
__asm__ 和 __volatile__，而不是 asm 和 volatile。</p>
<div class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="4"><span class="atitle">操作数</span></a></p>
<p>C 表达式用作 "asm" 内的汇编指令操作数。在汇编指令通过对 C 程序的 C
表达式进行操作来执行有意义的作业的情况下，操作数是内联汇编的主要特性。</p>
<p>每个操作数都由操作数约束字符串指定，后面跟用括弧括起的 C
表达式，例如："constraint" (C
expression)。操作数约束的主要功能是确定操作数的寻址方式。</p>
<p>
可以在输入和输出部分中同时使用多个操作数。每个操作数由逗号分隔开。</p>
<p>在汇编程序模板内部，操作数由数字引用。如果总共有
<em>n</em>
个操作数（包括输入和输出），那么第一个输出操作数的编号为
0，逐项递增，最后那个输入操作数的编号为
<em>n</em> -1。总操作数的数目限制在
10，如果机器描述中任何指令模式中的最大操作数数目大于
10，则使用后者作为限制。
</p>
<div class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="5"><span class="atitle">修饰寄存器列表</span></a></p>
<p>如果 "asm" 中的指令指的是硬件寄存器，可以告诉 GCC
我们将自己使用和修改它们。这样，GCC
就不会假设它装入到这些寄存器中的值是有效值。通常不需要将输入和输出寄存器列为
clobbered，因为 GCC 知道 "asm"
使用它们（因为它们被明确指定为约束）。不过，如果指令使用任何其它的寄存器，无论是明确的还是隐含的（寄存器不在输入约束列表中出现，也不在输出约束列表中出现），寄存器都必须被指定为修饰列表。修饰寄存器列在第三个冒号之后，其名称被指定为字符串。</p>
<p>
至于关键字，如果指令以某些不可预知且不明确的方式修改了内存，则可能将
"memory" 关键字添加到修饰寄存器列表中。这样就告诉 GCC
不要在不同指令之间将内存值高速缓存在寄存器中。</p>
<div class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="6"><span class="atitle">操作数约束</span></a></p>
<p>前面提到过，"asm"
中的每个操作数都应该由操作数约束字符串描述，后面跟用括弧括起的 C
表达式。操作数约束主要是确定指令中操作数的寻址方式。约束也可以指定：</p>
<ul>
    <li>
    是否允许操作数位于寄存器中，以及它可以包括在哪些种类的寄存器中</li>
    <li>
    操作数是否可以是内存引用，以及在这种情况下使用哪些种类的地址</li>
    <li>操作数是否可以是立即数</li>
</ul>
<p>约束还要求两个操作数匹配。</p>
<div class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="7"><span class="atitle">常用约束</span></a></p>
<p>在可用的操作数约束中，只有一小部分是常用的；下面列出了这些约束以及简要描述。有关操作数约束的完整列表，请参考
GCC 和 GAS 手册。</p>
<p><strong>寄存器操作数约束 (r)</strong><br>
使用这种约束指定操作数时，它们存储在通用寄存器中。请看下例：
</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>这里，变量 cr3val 保存在寄存器中，%cr3
的值复制到寄存器上，cr3val 的值从该寄存器更新到内存中。指定 "r"
约束时，GCC 可以将变量 cr3val 保存在任何可用的 GPR
中。要指定寄存器，必须通过使用特定的寄存器约束直接指定寄存器名。</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>
当操作数位于内存中时，任何对它们执行的操作都将在内存位置中直接发生，这与寄存器约束正好相反，后者先将值存储在要修改的寄存器中，然后将它写回内存位置中。但寄存器约束通常只在对于指令来说它们是绝对必需的，或者它们可以大大提高进程速度时使用。当需要在
"asm" 内部更新 C
变量，而您又确实不希望使用寄存器来保存其值时，使用内存约束最为有效。例如，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>匹配（数字）约束</strong><br>
在某些情况下，一个变量既要充当输入操作数，也要充当输出操作数。可以通过使用匹配约束在
"asm" 中指定这种情况。
</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>在匹配约束的示例中，寄存器 %eax
既用作输入变量，也用作输出变量。将 var 输入读取到
%eax，增加后将更新的 %eax 再次存储在 var 中。这里的 "0" 指定第 0
个输出变量相同的约束。即，它指定 var 的输出实例只应该存储在 %eax
中。该约束可以用于以下情况：</p>
<ul>
    <li>输入从变量中读取，或者变量被修改后，修改写回到同一变量中</li>
    <li>不需要将输入操作数和输出操作数的实例分开</li>
</ul>
<p>
使用匹配约束最重要的意义在于它们可以导致有效地使用可用寄存器。</p>
<div class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="8"><span class="atitle">一般内联汇编用法示例</span></a></p>
<p>以下示例通过各种不同的操作数约束说明了用法。有如此多的约束以至于无法将它们一一列出，这里只列出了最经常使用的那些约束类型。</p>
<p><strong>"asm" 和寄存器约束 "r"</strong>
让我们先看一下使用寄存器约束 r 的 "asm"。我们的示例显示了 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>在该例中，x 的值复制为 "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" 约束时，GCC
在这里可以自由分配任何寄存器。在我们的示例中，它选择 %edx 来存储
x。在读取了 %edx 中 x 的值后，它为 y 也分配了相同的寄存器。</p>
<p>因为 y 是在输出操作数部分中指定的，所以 %edx 中更新的值存储在
-8(%ebp)，堆栈上 y 的位置中。如果 y
是在输入部分中指定的，那么即使它在 y 的临时寄存器存储值 (%edx)
中被更新，堆栈上 y 的值也不会更新。</p>
<p>因为 %eax 是在修饰列表中指定的，GCC
不在任何其它地方使用它来存储数据。</p>
<p>输入 x 和输出 y 都分配在同一个 %edx
寄存器中，假设输入在输出产生之前被消耗。请注意，如果您有许多指令，就不是这种情况了。要确保输入和输出分配到不同的寄存器中，可以指定
&amp; 约束修饰符。下面是添加了约束修饰符的示例。</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>        :"=&amp;r"(y) /* y is output operand, note the    <br>                <br> &amp; constraint modifier. */<br>        :"r"(x)       /* x is input operand */<br>        :"%eax"); /* %eax is clobbered register */<br>}<br></pre>
            </td>
        </tr>
    </tbody>
</table>
<br>
<p>以下是为该示例生成的汇编代码，从中可以明显地看出 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 class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="9"><span class="atitle">特定寄存器约束的使用</span></a></p>
<p>现在让我们看一下如何将个别寄存器作为操作数的约束指定。在下面的示例中，cpuid
指令采用 %eax
寄存器中的输入，然后在四个寄存器中给出输出：%eax、%ebx、%ecx、%edx。对
cpuid 的输入（变量 "op"）传递到 "asm" 的 eax 寄存器中，因为 cpuid
希望它这样做。在输出中使用 a、b、c 和 d
约束，分别收集四个寄存器中的值。</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>在下面可以看到为它生成的汇编代码（假设 _eax、_ebx 等...
变量都存储在堆栈上）：</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" 约束来实现：</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" 约束将源指针 src 放入 %esi 中，使用 "D"
约束将目的指针 dst 放入 %edi 中。因为 rep 前缀需要 count
值，所以将它放入 %ecx 中。</p>
<p>在下面可以看到另一个约束，它使用两个寄存器 %eax 和 %edx 将两个
32 位的值合并在一起，然后生成一个64 位的值：</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 class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="10"><span 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">#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>在上例中，通过使用 b、c、d 和 S 约束将系统调用的四个自变量放入
%ebx、%ecx、%edx 和 %esi 中。请注意，在输出中使用了 "=a"
约束，这样，位于 %eax 中的系统调用的返回值就被放入变量 __res
中。通过将匹配约束 "0" 用作输入部分中第一个操作数约束，syscall 号
__NR_##name 被放入 %eax 中，并用作对系统调用的输入。这样，这里的
%eax
既可以用作输入寄存器，又可以用作输出寄存器。没有其它寄存器用于这个目的。另请注意，输入（syscall
号）在产生输出（syscall 的返回值）之前被消耗（使用）。</p>
<div class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">&nbsp;</a></p>
<p><a name="11"><span 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__ __volatile__(<br>"lock; decl %0"<br>:"=m" (counter)<br>:"m" (counter));<br></pre>
            </td>
        </tr>
    </tbody>
</table>
<br>
<p>为它生成的汇编类似于：</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 使用寄存器约束。如果这样做，counter
的值必须先复制到寄存器，递减，然后对其内存更新。但这样您会无法理解锁定和原子性的全部意图，这些明确显示了使用内存约束的必要性。</p>
<div class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">&nbsp;</a></p>
<p><a name="12"><span 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 指令隐含地使用它。%ecx
寄存器明确装入 count。但 GCC
在我们通知它以前是不知道这些的，我们是通过将 %eax 和 %ecx
包括在修饰寄存器集中来通知 GCC 的。在完成这一步之前，GCC 假设 %eax
和 %ecx 是自由的，它可能决定将它们用作存储其它的数据。请注意，%esi
和 %edi 由 "asm" 使用，它们不在修饰列表中。这是因为已经声明 "asm"
将在输入操作数列表中使用它们。这里最低限度是，如果在 "asm"
内部使用寄存器（无论是明确还是隐含地），既不出现在输入操作数列表中，也不出现在输出操作数列表中，必须将它列为修饰寄存器。</p>
<div class="ibm-alternate-rule"><hr></div>
<p class="ibm-ind-link ibm-back-to-top"><a  href="http://www.ibm.com/developerworks/cn/linux/sdk/assemble/inline/index.html#ibm-pcon" class="ibm-anchor-up-link">回页首</a></p>
<p><a name="13"><span class="atitle">结束语</span></a></p>
<p>总的来说，内联汇编非常巨大，它提供的许多特性我们甚至在这里根本没有涉及到。但如果掌握了本文描述的基本材料，您应该可以开始对自己的内联汇编进行编码了。</p>
<br>
<p><a name="resources"><span class="atitle">参考资料 </span></a></p>
<ul>
    <li>您可以参阅本文在 developerWorks 全球站点上的
    <a  href="http://www.ibm.com/developerworks/library/l-ia.html?S_TACT=105AGX52&amp;S_CMP=cn-a-l">英文原文</a>.
    <br><br></li>
    <li>请参考
    <a  href="http://gcc.gnu.org/onlinedocs/gcc_toc.html">Using and Porting
    the GNU Compiler Collection (GCC)</a>手册。
    <br><br></li>
    <li>请参考
    <a  href="http://www.gnu.org/manual/gas-2.9.1/as.html">GNU Assembler
    (GAS)</a>手册。
    <br><br></li>
    <li>仔细阅读
    <a  href="http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html">Brennan's Guide to Inline Assembly</a>。
    </li>
</ul><img src ="http://www.cppblog.com/Panda/aggbug/131173.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2010-10-25 11:28 <a href="http://www.cppblog.com/Panda/archive/2010/10/25/131173.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>飞鸽协议以及其使用的UDP数据包格式和文件传输逻辑</title><link>http://www.cppblog.com/Panda/archive/2010/01/11/105406.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Mon, 11 Jan 2010 07:23:00 GMT</pubDate><guid>http://www.cppblog.com/Panda/archive/2010/01/11/105406.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/105406.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2010/01/11/105406.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/105406.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/105406.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Normal07.8 磅02falsefalsefalseEN-USZH-CNX-NONEMicrosoftInternetExplorer4...&nbsp;&nbsp;<a href='http://www.cppblog.com/Panda/archive/2010/01/11/105406.html'>阅读全文</a><img src ="http://www.cppblog.com/Panda/aggbug/105406.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2010-01-11 15:23 <a href="http://www.cppblog.com/Panda/archive/2010/01/11/105406.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转 部分飞鸽协议</title><link>http://www.cppblog.com/Panda/archive/2010/01/07/105068.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Thu, 07 Jan 2010 03:15:00 GMT</pubDate><guid>http://www.cppblog.com/Panda/archive/2010/01/07/105068.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/105068.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2010/01/07/105068.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/105068.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/105068.html</trackback:ping><description><![CDATA[<br>最近看到一些朋友在编写网络程序是遇到一些问题，故把以前做IPMSG时翻译的文档贴过来，希望对网络编程新手有所帮助，在寻找编程项目的同学们也可参照此文档写出自己的IPMSG。<br>
<br>
本文只包含其中几个比较重要的命令以及运行机制的中文翻译，更详细的内容请参照文后的IPMSG 协议英文文档<br>
<br>
声明：下述协议内容略去了一些在编写程序过程中没有用到协议内容，最初的Ipmsg协议是用日文写的，下面协议内容由本人(cugb_cat)翻译自Mr.Kanazawa的英文文档。本翻译文档可任意传播和使用。<br>
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IP信使传输协议(第9版草案)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;1996/02/21<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 2003/01/14 修订<br>
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; H.Shirouzu<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<a  href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#115;&#104;&#105;&#114;&#111;&#117;&#122;&#117;&#64;&#104;&#46;&#101;&#109;&#97;&#105;&#108;&#46;&#110;&#101;&#46;&#106;&#112;">shirouzu@h.email.ne.jp</a><br>
<br>
<br>
关于IP信使：<br>
&nbsp;&nbsp;IP信使使用TCP/UDP协议提供收发消息及文件(目录)。<br>
特性：<br>
IP信使能够安装在任何一个安装了TCP/IP协议栈的操作系统上，使用在线用户的动态识别机制，可以和在线所有用户进行信息交换。<br>
运行机制介绍：<br>
使用TCP/UDP端口(默认端口为2425)，消息的收发使用UDP协议，文件(文件夹)的收发使用TCP协议。<br>
1、&nbsp; &nbsp;命令字：<br>
1)&nbsp; &nbsp;基本命令字(32位命令字的低8位)<br>
&nbsp; &nbsp; IPMSG_NOOPERATION&nbsp; &nbsp;&nbsp;&nbsp;不进行任何操作<br>
&nbsp; &nbsp; IPMSG_BR_ENTRY&nbsp; &nbsp;&nbsp;&nbsp;用户上线<br>
&nbsp; &nbsp; IPMSG_BR_EXIT&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;用户退出<br>
&nbsp; &nbsp; IPMSG_ANSENTRY&nbsp; &nbsp;&nbsp;&nbsp;通报在线<br>
&nbsp; &nbsp; IPMSG_SENDMSG&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;发送消息<br>
&nbsp; &nbsp; IPMSG_RECVMSG&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;通报收到消息<br>
&nbsp; &nbsp; IPMSG_GETFILEDATA&nbsp; &nbsp;&nbsp;&nbsp;请求通过TCP传输文件<br>
&nbsp; &nbsp; IPMSG_RELEASEFILES&nbsp; &nbsp;停止接收文件<br>
&nbsp; &nbsp; IPMSG_GETDIRFILES&nbsp; &nbsp;&nbsp;&nbsp;请求传输文件夹<br>
2)&nbsp; &nbsp;选项位(32位命令字的高24位)<br>
IPMSG_SENDCHECKOPT&nbsp; &nbsp;传送检查(需要对方返回确认信息)<br>
IPMSG_FILEATTACHOPT&nbsp; &nbsp;传送文件选项<br>
3)&nbsp; &nbsp;附件类型命令(文件类型命令字的低8位)<br>
IPMSG_FILE_REGULAR&nbsp; &nbsp;普通文件<br>
IPMSG_FILE_DIR&nbsp; &nbsp;&nbsp;&nbsp;目录文件<br>
IPMSG_FILE_RETPARENT&nbsp; &nbsp;返回上一级目录<br>
2、&nbsp; &nbsp;数据包格式(使用字符串)：<br>
1)&nbsp; &nbsp;数据包格式(版本1的格式)<br>
版本号(1):包编号:发送者姓名:发送者主机名:命令字:附加信息<br>
2)&nbsp; &nbsp;举例如下<br>
&#8220;1:100:shirouzu:Jupiter:32:Hello&#8221;<br>
3、&nbsp; &nbsp;数据包处理总述：<br>
1)&nbsp; &nbsp;用户识别<br>
当IPMSG
启动时，命令IPMSG_BR_ENTRY被广播到网络中，向所有在线的用户提示一个新用户的到达(即表示&#8220;我来了&#8221;)；所有在线用户将把该新上线用户添
加到自己的用户列表中，并向该新上线用户发送IPMSG_ANSENTRY命令(即表示&#8220;我在线&#8221;)；该新上线用户接收到IPMSG_ANSENTRY命
令后即将在线用户添加到自己的用户列表中。<br>
2)&nbsp; &nbsp;收发消息<br>
使用IPMSG_SENDMSG命令发送消息，消息内容添加在附加信息中；在接收消息时，如果对方要求回信确认(IPMSG_SENDCHECKOPT位打开)，则需发送IPMSG_RECVMSG命令并将对方发送的数据包的编号放在附加信息中一同发送至发送消息方<br>
3)&nbsp; &nbsp;附加文件的扩充(添加于第9版)<br>
带有IPMSG_FILEATTACHOPT位的IPMSG_SENDMSG命令可用来传输文件，文件属性及内容添加在附加信息中，文件内容添加在消息内
容后并以&#8217;\0&#8217;与之分隔开。传输文件时以下信息将被添加到消息内容之后(包括格式)：文件序号:文件名:大小(单位:字节):最后修改时间:文件属性
[: 附加属性=val1[,val2&#8230;][:附加信息=&#8230;]]:\a:文件序号&#8230;<br>
(文件大小、最后修改时间和文件属性为十六进制数，如果文件名中包含&#8217;:&#8217;则使用&#8220;::&#8221;代替)。<br>
接收端开始接收文件时，请求传输文件命令IPMSG_GETFILEDATA将发送到发送端的TCP端口(和UDP的发送端口相同)，并将发送端发送的包
编号:文件序号:偏移量(全为十六进制格式)写到附加信息区一同发送，文件发送端接收到该请求信息并进行校验正确后即开始发送文件(不使用任何格式，亦不
进行加密)。<br>
当接收端接收到目录文件时，将发送附加信息区为发送端发送的包编号:文件序号:偏移量(全为十六进制格式)的
IPMSG_GETDIRFILES命令，以用来请求传输目录文件；发送端则将头信息长度:文件名:文件大小:文件属性:文件内容添加到附加信息区(除了
文件名和文件内容外，其余皆为十六进制)，头信息长度是从头信息长度开始到文件内容前的&#8216;:&#8217;分割符为止的字符个数。<br>
当文件属性为IPMSG_FILE_DIR时，IPMsg能够自动识别其为目录，下一个文件的数据在该目录之后。<br>
当文件属性为IPMSG_FILE_RETPARENT时，IPMsg识别其动作为返回上一级目录，在这种情况下，文件名为&#8216;.&#8217;其属性为当前目录的值。<br><br>
附IPMSG协议英文版:<br><br><br><br>
<p style="margin: 5px; line-height: 150%;"><code><span style="color: #000000;">Original ipmsg protocol specification is written in Japanese<span style="color: #0000cc;">.</span><br>
<span style="color: #0000ff;">This</span> document was translated by Mr<span style="color: #0000cc;">.</span>Kanazawa<span style="color: #0000cc;">.</span><br>
<span style="color: #0000ff;">This</span> document is <span style="color: #0000ff;">not</span> verified yet<span style="color: #0000cc;">.</span><br>
<br>
<span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IP Messenger communication protocol <span style="color: #0000cc;">(</span>Draft<span style="color: #0000cc;">-</span>9<span style="color: #0000cc;">)</span>   1996<span style="color: #0000cc;">/</span>02<span style="color: #0000cc;">/</span>21<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Modified 2003<span style="color: #0000cc;">/</span>01<span style="color: #0000cc;">/</span>14<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H<span style="color: #0000cc;">.</span>Shirouzu<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shirouzu@h<span style="color: #0000cc;">.</span>email<span style="color: #0000cc;">.</span>ne<span style="color: #0000cc;">.</span>jp<br>
<span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><br>
<br>
About IP Messenger<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">This</span> is a <span style="color: #ff0000;">Send</span><span style="color: #0000cc;">/</span>Receive message service <span style="color: #0000ff;">using</span> the TCP<span style="color: #0000cc;">/</span>UDP Port<span style="color: #0000cc;">.</span><br>
<br>
Characteristics<br>
&nbsp;&nbsp;&nbsp;&nbsp;IP Messenger can be installed in <span style="color: #ff0000;">any</span> OS <span style="color: #0000ff;">if</span> TCP<span style="color: #0000cc;">/</span>IP is used on your machine<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;Dynamic member recognition can be done within your network <span style="color: #0000ff;">or</span> specified network<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;You can exchange <span style="color: #ff0000;">messages</span> between all IPMsg members<span style="color: #0000cc;">.</span><br>
<br>
Function description<br>
&nbsp;&nbsp;&nbsp;&nbsp;Use TCP<span style="color: #0000cc;">/</span>UDP port<span style="color: #0000cc;">(</span><span style="color: #0000ff;">default</span><span style="color: #0000cc;">:</span>2425<span style="color: #0000cc;">)</span><span style="color: #0000cc;">.</span> See the following descriptions<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">(</span>Message <span style="color: #ff0000;">Send</span><span style="color: #0000cc;">/</span>Receive<span style="color: #0000cc;">:</span> UDP<span style="color: #0000cc;">,</span> <span style="color: #ff0000;">File</span> <span style="color: #ff0000;">Send</span><span style="color: #0000cc;">/</span>Receive<span style="color: #0000cc;">:</span> TCP<span style="color: #0000cc;">)</span><br>
<br>
1<span style="color: #0000cc;">.</span> Command<br>
<br>
&nbsp;&nbsp;1<span style="color: #0000cc;">)</span> Command functions <span style="color: #0000cc;">(</span>Low 8 bits from command number 32 bits<span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_NOOPERATION     No Operation<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_BR_ENTRY           Entry to service <span style="color: #0000cc;">(</span>Start<span style="color: #0000cc;">-</span>up with a Broadcast command<span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_BR_EXIT           <span style="color: #ff0000;">Exit</span> from service <span style="color: #0000cc;">(</span>End with a Broadcast command<span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_ANSENTRY           Notify a <span style="color: #0000ff;">new</span> entry<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_BR_ABSENCE     Change absence mode<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_BR_ISGETLIST     <span style="color: #ff0000;">Search</span> valid sending host members<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_OKGETLIST           Host <span style="color: #ff0000;">list</span> sending notice<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_GETLIST           Host <span style="color: #ff0000;">list</span> sending request<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_ANSLIST           Host <span style="color: #ff0000;">list</span> sending<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_SENDMSG           Message transmission<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_RECVMSG           Message receiving check<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_READMSG           Message <span style="color: #ff0000;">open</span> notice<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_DELMSG           Message discarded notice<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_ANSREADMSG     Message <span style="color: #ff0000;">open</span> confirmation notice<span style="color: #0000cc;">(</span>added from version<span style="color: #0000cc;">-</span>8 <span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_GETFILEDATA     <span style="color: #ff0000;">File</span> Transfer request by TCP<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_RELEASEFILES     Discard attachment <span style="color: #ff0000;">file</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_GETDIRFILES     Attachment hierarchical <span style="color: #ff0000;">file</span> request<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_GETINFO           Get IPMSG version info<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_SENDINFO           <span style="color: #ff0000;">Send</span> IPMSG version info<span style="color: #0000cc;">.</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_GETABSENCEINFO     Get absence sentence<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_SENDABSENCEINFO     <span style="color: #ff0000;">Send</span> absence sentence<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_GETPUBKEY           RSA <span style="color: #0000ff;">Public</span> Key Acquisition<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_ANSPUBKEY           RSA <span style="color: #0000ff;">Public</span> Key Response<br>
<br>
&nbsp;&nbsp;2<span style="color: #0000cc;">)</span> Option flag <span style="color: #0000cc;">(</span>High 24 bits from command number 32 bits<span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_ABSENCEOPT     Absence mode<span style="color: #0000cc;">(</span>Member recognition command<span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_SERVEROPT           Server<span style="color: #0000cc;">(</span>Reserved<span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_DIALUPOPT           <span style="color: #ff0000;">Send</span> individual member recognition command<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_SENDCHECKOPT     Transmission check<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_SECRETOPT           Sealed message<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_READCHECKOPT     Sealed message check<span style="color: #0000cc;">(</span>added from ver8 <span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_PASSWORDOPT     Lock<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_BROADCASTOPT     Broadcast message<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_MULTICASTOPT     Multi<span style="color: #0000cc;">-</span>cast<span style="color: #0000cc;">(</span>Multiple casts selection<span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_NEWMUTIOPT     <span style="color: #0000ff;">New</span> version multi<span style="color: #0000cc;">-</span>cast<span style="color: #0000cc;">(</span>reserved<span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_AUTORETOPT     Automatic response<span style="color: #0000cc;">(</span>Ping<span style="color: #0000cc;">-</span>pong protection<span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_NOLOGOPT           No <span style="color: #ff0000;">log</span> files<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_NOADDLISTOPT     Notice to the members outside of BR_ENTRY<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILEATTACHOPT     <span style="color: #ff0000;">File</span> attachment<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_ENCRYPTOPT     Code<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_NOPOPUPOPT     <span style="color: #0000cc;">(</span>No longer valid<span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_RETRYOPT           Re<span style="color: #0000cc;">-</span><span style="color: #ff0000;">send</span> flag<span style="color: #0000cc;">(</span>Use when acquiring HOSTLIST<span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;3<span style="color: #0000cc;">)</span> Extended code flag <span style="color: #0000cc;">(</span><span style="color: #ff0000;">hex</span> format combination<span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_RSA_512<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_RSA_1024<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_RSA_2048<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_RC2_40<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_RC2_128<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_RC2_256<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_BLOWFISH_128<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_BLOWFISH_256<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_SIGN_MD5<br>
<br>
&nbsp;&nbsp;4<span style="color: #0000cc;">)</span> Extended files <span style="color: #0000ff;">for</span> attachment <span style="color: #0000cc;">(</span>fileattr low 8 bits<span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_REGULAR<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_DIR<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_RETPARENT<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_SYMLINK<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_CDEV<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_BDEV<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_FIFO<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_RESFORK<br>
<br>
&nbsp;&nbsp;5<span style="color: #0000cc;">)</span> Attachment <span style="color: #ff0000;">file</span> extended attribute<span style="color: #0000cc;">(</span>fileattr high 24 bits<span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_RONLYOPT<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_HIDDENOPT<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_EXHIDDENOPT<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_ARCHIVEOPT<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_SYSTEMOPT<br>
<br>
&nbsp;&nbsp;6<span style="color: #0000cc;">)</span> Extended <span style="color: #ff0000;">file</span> attribute <span style="color: #0000ff;">for</span> attachment <span style="color: #ff0000;">file</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_UID<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_USERNAME<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_GID<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_GROUPNAME<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_PERM<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_MAJORNO<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_MINORNO<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_CTIME<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_MTIME<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_ATIME<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_CREATETIME<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_CREATOR<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_FILETYPE<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_FINDERINFO<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_ACL<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_ALIASFNAME<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_UNICODEFNAME<br>
<br>
<br>
2<span style="color: #0000cc;">.</span>Command format<span style="color: #0000cc;">(</span>Use all character strings<span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;1<span style="color: #0000cc;">)</span> Command<span style="color: #0000cc;">(</span>Format version<span style="color: #0000cc;">-</span>1<span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Ver<span style="color: #0000cc;">(</span>1<span style="color: #0000cc;">)</span> <span style="color: #0000cc;">:</span> PacketNo <span style="color: #0000cc;">:</span> SenderName <span style="color: #0000cc;">:</span> SenderHost <span style="color: #0000cc;">:</span> CommandNo <span style="color: #0000cc;">:</span> AdditionalSection<br>
<br>
&nbsp;&nbsp;2<span style="color: #0000cc;">)</span> An example <span style="color: #0000ff;">for</span> Message <span style="color: #ff0000;">Send</span><span style="color: #0000cc;">/</span>Receive by <span style="color: #0000ff;">using</span> the current command format<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff00ff;">"1:100:shirouzu:jupiter:32:Hello"</span><br>
<br>
<br>
3<span style="color: #0000cc;">.</span>Command process overview<br>
<br>
&nbsp;&nbsp;1<span style="color: #0000cc;">)</span> Member recognition<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;An IPMSG_BR_ENTRY command notifies a <span style="color: #0000ff;">new</span> entry to the current<br>
&nbsp;&nbsp;&nbsp;&nbsp;members at start<span style="color: #0000cc;">-</span>up<span style="color: #0000cc;">.</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;All members add the <span style="color: #0000ff;">new</span> member to their <span style="color: #ff0000;">list</span> after getting a notification message<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;An IPMSG_ANSENTRY command sends a message back to the <span style="color: #0000ff;">new</span> member<span style="color: #0000cc;">.</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;The <span style="color: #0000ff;">new</span> member <span style="color: #ff0000;">gets</span> the current member data by a<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_ANSENTRY command<span style="color: #0000cc;">.</span> All members can communicate as <span style="color: #0000ff;">long</span> as an<br>
&nbsp;&nbsp;&nbsp;&nbsp;IP packet exists<span style="color: #0000cc;">.</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;An IPMSG_BR_ABSENCE command broadcasts absence mode cancel <span style="color: #0000ff;">or</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;nickname change to all members<span style="color: #0000cc;">.</span> However<span style="color: #0000cc;">,</span> an IPMSG_ANSENTRY command<br>
&nbsp;&nbsp;&nbsp;&nbsp;does <span style="color: #0000ff;">not</span> <span style="color: #ff0000;">send</span> a message back<span style="color: #0000cc;">,</span> which is different from an IPMSG_BR_ENTRY<br>
&nbsp;&nbsp;&nbsp;&nbsp;command<span style="color: #0000cc;">.</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_BR_ENTRY<span style="color: #0000cc;">,</span> IPMSG_ANSENTRY<span style="color: #0000cc;">,</span> <span style="color: #0000ff;">and</span> IPMSG_BR_ABSENCE commands<br>
&nbsp;&nbsp;&nbsp;&nbsp;use an IPMSG_ABSENCEOPT flag <span style="color: #0000ff;">for</span> absence mode<span style="color: #0000cc;">.</span> Input a nickname to<br>
&nbsp;&nbsp;&nbsp;&nbsp;additional command<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;Add an IPMSG_DIALUPOPT flag <span style="color: #0000ff;">for</span> dial<span style="color: #0000cc;">-</span>up users who can<span style="color: #ff00ff;">'t be reached by<br>
&nbsp;&nbsp;&nbsp;&nbsp;a broadcast command. A member recognition command needs to be<br>
&nbsp;&nbsp;&nbsp;&nbsp;sent individually to the members with this optional flag.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;(Extended group)IPMSG_BR_ENTRY and IPMSG_BR_ABSENCE commands<br>
&nbsp;&nbsp;&nbsp;&nbsp;sends a group name by adding the new group name after the current<br>
&nbsp;&nbsp;&nbsp;&nbsp;command format character strings (Input '</span><span style="color: #ff00ff;">\</span>0<span style="color: #ff00ff;">' between the current<br>
&nbsp;&nbsp;&nbsp;&nbsp;command and extended name).<br>
<br>
&nbsp;&nbsp;2) Send/Receive Message<br>
&nbsp;&nbsp;&nbsp;&nbsp;Send Message uses an IPMSG_SENDMSG command that can input a message<br>
&nbsp;&nbsp;&nbsp;&nbsp;in the extended area.<br>
&nbsp;&nbsp;&nbsp;&nbsp;Receive Message sends back an IPMSG_RECVMSG command only<br>
&nbsp;&nbsp;&nbsp;&nbsp;if an IPMSG_SENDCHECKOPT flag is ON. Input the original packet number<br>
&nbsp;&nbsp;&nbsp;&nbsp;to the extended area.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Broadcast Message Send uses an IPMSG_BOADCASTOPT command<br>
&nbsp;&nbsp;&nbsp;&nbsp;and an IPMSG_SENDMSG flag should be ON.<br>
&nbsp;&nbsp;&nbsp;&nbsp;Auto-Send packet(absence notice) needs to be added to IPMSG_AUTORETOPT<br>
&nbsp;&nbsp;&nbsp;&nbsp;for ping-pong protection. If either one or another packet is ON, then<br>
&nbsp;&nbsp;&nbsp;&nbsp;confirmation/auto-send packet is not sent back.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Send Message Sealing needs to be an IPMSG_SECRETOPT packet ON.<br>
&nbsp;&nbsp;&nbsp;&nbsp;In this case, Receive Message sends an IPMSG_READMSG command.<br>
&nbsp;&nbsp;&nbsp;&nbsp;Input the original packet number to the extended area.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;(Additional IPMSG_NOADDLISTOPT)<br>
&nbsp;&nbsp;&nbsp;&nbsp;When receiving an IPMSG_SENDMSG packet from a host that is<br>
&nbsp;&nbsp;&nbsp;&nbsp;not on your Send/Receive list, IPMsg will either confirm a host by<br>
&nbsp;&nbsp;&nbsp;&nbsp;sending an IPMSG_BR_ENTRY command or add a host name to<br>
&nbsp;&nbsp;&nbsp;&nbsp;the Send/Receive list.<br>
&nbsp;&nbsp;&nbsp;&nbsp;However, single-shot Message Send/Receive action needs to be avoided.<br>
&nbsp;&nbsp;&nbsp;&nbsp;Add an IPMSG_NOADDLISTOPT flag to an IPMSG_SENDMSG command.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;(Additional IPMSG_READCHECKOPT from version-8 )<br>
&nbsp;&nbsp;&nbsp;&nbsp;When an IPMSG_READMSG command contains an IPMSG_READCHECKOPT flag,<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMsg process is the same as IPMSG_SENDMSG with an<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_SENDCHECKOPT flag.<br>
&nbsp;&nbsp;&nbsp;&nbsp;However, Send Message uses an IPMSG_ANSREADMSG command,<br>
&nbsp;&nbsp;&nbsp;&nbsp;not IPMSG_RECVMSG.<br>
<br>
&nbsp;&nbsp;3) Message Send/Receive 亅encrypted extension (Added in the version-9 )<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Use the combination of Public-key(RSA) and common key(RC2/Blowfish).<br>
&nbsp;&nbsp;&nbsp;&nbsp;(Encrypted extension area is used in hex format.)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;(Public key acquisition)Send an IPMSG_GETPUBKEY command to Receive<br>
&nbsp;&nbsp;&nbsp;&nbsp;Message. Receive Message gets an IPMSG_ANSPUBKEY that<br>
&nbsp;&nbsp;&nbsp;&nbsp;means receiving RSA public key from Send Message.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_GETPUBKEY/IPMSG_ANSPUBKEY both require the value which is<br>
&nbsp;&nbsp;&nbsp;&nbsp;encryption capability (Exp. IPMSG_RSA_1024) flag uses "OR" at first<br>
&nbsp;&nbsp;&nbsp;&nbsp;part of extension<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;In addition, In IPMSG_ANSPUBKEY, public key written as EE-NNNNNN<br>
&nbsp;&nbsp;&nbsp;&nbsp;E=Exponent丄N=method)devide by '</span><span style="color: #0000cc;">:</span><span style="color: #ff00ff;">'. and Input the Fdelimiter '</span><span style="color: #0000cc;">-</span><span style="color: #ff00ff;">'<br>
&nbsp;&nbsp;&nbsp;&nbsp;between E and N.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;This sequence can be skipped after the 2nd Send/Receive process by<br>
&nbsp;&nbsp;&nbsp;&nbsp;memorizing public key and encrypted data.<br>
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;(Encrypted message)After a sender creates a common key that is<br>
&nbsp;&nbsp;&nbsp;&nbsp;supported both sender and receiver, a common key can encrypt a message.<br>
&nbsp;&nbsp;&nbsp;&nbsp;In addition, a receiver'</span>s <span style="color: #0000ff;">public</span> key encrypts the common key<span style="color: #0000cc;">.</span><br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">(</span>Encrypted message transmission<span style="color: #0000cc;">)</span> IPMSG_ENCRYPTOPT is used in<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_SENDMSG<span style="color: #0000cc;">.</span> At the first part of extension<span style="color: #0000cc;">,</span> input the value which<br>
&nbsp;&nbsp;&nbsp;&nbsp;is <span style="color: #ff00ff;">'or'</span> resoult from Convination of <span style="color: #0000ff;">public</span> key <span style="color: #0000ff;">and</span> common key type <span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;Then use common key which encrypt with <span style="color: #0000ff;">public</span> key devide by <span style="color: #ff00ff;">':'</span><span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;Then input message which is eccrypted by <span style="color: #0000ff;">public</span> key devide by <span style="color: #ff00ff;">':'</span><span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">If</span> both supports IPMSG_SIGN_XXX<span style="color: #0000cc;">,</span> then add <span style="color: #ff00ff;">':'</span> <span style="color: #0000ff;">and</span> signeture<span style="color: #0000cc;">.</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Also<span style="color: #0000cc;">,</span> In the method of encode padding<span style="color: #0000cc;">,</span> PKCS<span style="color: #0000cc;">#</span>1ECB key is used <span style="color: #0000ff;">for</span> RSA<span style="color: #0000cc;">,</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;PKCS<span style="color: #0000cc;">#</span>5 CBC common key is used <span style="color: #0000ff;">for</span> RC2<span style="color: #0000cc;">/</span>blowfish<span style="color: #0000cc;">.</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Also<span style="color: #0000cc;">,</span> The Packet related to Entry manifestation the capability of<br>
&nbsp;&nbsp;&nbsp;&nbsp;ecryption support <span style="color: #0000ff;">using</span> IPMSG_ENCRYPTOPT<br>
<br>
&nbsp;&nbsp;4<span style="color: #0000cc;">)</span> Extension with <span style="color: #ff0000;">file</span> attachment<span style="color: #0000cc;">(</span>Available from version<span style="color: #0000cc;">-</span>9 <span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;An IPMSG_SENDMSG command with an IPMSG_FILEATTACHOPT flag <span style="color: #0000ff;">for</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000;">File</span> transfer <span style="color: #0000cc;">(</span>download permission<span style="color: #0000cc;">)</span>notification sends a message<br>
&nbsp;&nbsp;&nbsp;&nbsp;with attachment<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;Input <span style="color: #ff00ff;">'\0'</span> after the message <span style="color: #0000ff;">and</span> attachment <span style="color: #ff0000;">file</span> data<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;fileID<span style="color: #0000cc;">:</span>filename<span style="color: #0000cc;">:</span>size<span style="color: #0000cc;">:</span>mtime<span style="color: #0000cc;">:</span>fileattr<span style="color: #0000cc;">[</span><span style="color: #0000cc;">:</span>extend<span style="color: #0000cc;">-</span>attr<span style="color: #0000cc;">=</span>val1<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">[</span><span style="color: #0000cc;">,</span>val2<span style="color: #0000cc;">.</span><span style="color: #0000cc;">.</span><span style="color: #0000cc;">.</span><span style="color: #0000cc;">]</span><span style="color: #0000cc;">[</span><span style="color: #0000cc;">:</span>extend<span style="color: #0000cc;">-</span>attr2<span style="color: #0000cc;">=</span><span style="color: #0000cc;">.</span><span style="color: #0000cc;">.</span><span style="color: #0000cc;">.</span><span style="color: #0000cc;">]</span><span style="color: #0000cc;">]</span><span style="color: #0000cc;">:</span><span style="color: #0000cc;">\</span>a<span style="color: #0000cc;">:</span>fileID<span style="color: #0000cc;">.</span><span style="color: #0000cc;">.</span><span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">(</span>size<span style="color: #0000cc;">,</span> mtime<span style="color: #0000cc;">,</span> <span style="color: #0000ff;">and</span> fileattr describe <span style="color: #ff0000;">hex</span> format<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">If</span> a filename contains <span style="color: #ff00ff;">':'</span><span style="color: #0000cc;">,</span> please <span style="color: #ff0000;">replace</span> with <span style="color: #ff00ff;">"::"</span><span style="color: #0000cc;">.</span><span style="color: #0000cc;">)</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;When Receive Message downloads an attachment <span style="color: #ff0000;">file</span><span style="color: #0000cc;">,</span> an IPMSG_GETFILEDATA<br>
&nbsp;&nbsp;&nbsp;&nbsp;command requests a data transmission packet to the TCP port that is the same number<br>
&nbsp;&nbsp;&nbsp;&nbsp;as the UDP sending port number<span style="color: #0000cc;">.</span> Input packetID<span style="color: #0000cc;">:</span>fileID<span style="color: #0000cc;">:</span> offset to the extended area<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">(</span>Use all <span style="color: #ff0000;">hex</span> format<span style="color: #0000cc;">.</span><span style="color: #0000cc;">)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000;">File</span> Transfer side receives the request<span style="color: #0000cc;">.</span> After recognizing that it<span style="color: #ff00ff;">'s a correct request,<br>
&nbsp;&nbsp;&nbsp;&nbsp;then send the specified data (no format)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;When the data receiving side downloads a hierarchical attachment file,<br>
&nbsp;&nbsp;&nbsp;&nbsp;use an IPMSG_GETDIRFILES command and input a packetID:fileID<br>
&nbsp;&nbsp;&nbsp;&nbsp;to the extended area and send a data transmission request packet.<br>
&nbsp;&nbsp;&nbsp;&nbsp;(all hex format)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Data sending side sends the following hierarchical data format.<br>
&nbsp;&nbsp;&nbsp;&nbsp;header-size:filename:file-size:fileattr[:extend-attr=val1<br>
&nbsp;&nbsp;&nbsp;&nbsp;[,val2...][:extend-attr2=...]]:contents-data<br>
&nbsp;&nbsp;&nbsp;&nbsp;Next headersize: Next filename...<br>
&nbsp;&nbsp;&nbsp;&nbsp;(All hex format except for filename and contetns-data)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;header-size is from the beginning of header-size to the delimiter '</span><span style="color: #0000cc;">:</span><span style="color: #ff00ff;">'<br>
&nbsp;&nbsp;&nbsp;&nbsp;that is before contents-data. extend-attr can be omitted and used multiple<br>
&nbsp;&nbsp;&nbsp;&nbsp;extended attributes. Use '</span><span style="color: #0000cc;">=</span><span style="color: #ff00ff;">' for data input.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;When fileattr is IPMSG_FILE_DIR, IPMsg recognizes that it is automatically<br>
&nbsp;&nbsp;&nbsp;&nbsp;in the directory, the next file data is after the directory.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;When fileattr is IPMSG_FILE_RETPARENT, IMPsg recognizes that it returns<br>
&nbsp;&nbsp;&nbsp;&nbsp;to the parent directory. In this case, File name is always "." and the attribute<br>
&nbsp;&nbsp;&nbsp;&nbsp;value is the current directory data.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Sending process starts from the attachment directly and returns the<br>
&nbsp;&nbsp;&nbsp;&nbsp;IPMSG_FILE_RETPARENT command to the attachment directory.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Add an IPMSG_FILEATTACHOPT flag for an Entry packet to support the<br>
&nbsp;&nbsp;&nbsp;&nbsp;attachment file.<br>
<br>
&nbsp;&nbsp;5) Other commands<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;When acquiring different versions, send an IPMSG_GETINFO command.<br>
&nbsp;&nbsp;&nbsp;&nbsp;Receiving side sends the version information character string to<br>
&nbsp;&nbsp;&nbsp;&nbsp;extended area.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Send an IPMSG_GETABSENCEINFO command for acquiring an absence message.<br>
&nbsp;&nbsp;&nbsp;&nbsp;Receiving side sends an IPMSG_SENDABSENCEINFO back if the status is absence mode.<br>
&nbsp;&nbsp;&nbsp;&nbsp;If the status is not absence mode, a character string "Not absence mode" will be sent back.<br>
<br>
&nbsp;&nbsp;6) Confirmation/Retry<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;If a confirmation packet for IPMSG_SENDMSG or IPMSG_RECVMSG is not delivered<br>
&nbsp;&nbsp;&nbsp;&nbsp;within a specified time, then it will be sent again.<br>
&nbsp;&nbsp;&nbsp;&nbsp;A number of retry actions or interval period is depended on the current condition.<br>
<br>
<br>
4. Other<br>
<br>
&nbsp;&nbsp;1) Linefeed<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Linefeed characters in Send Message is standardized with UNIX type ('</span>0x0a<span style="color: #ff00ff;">').<br>
&nbsp;&nbsp;&nbsp;&nbsp;Please change if needed.<br>
<br>
&nbsp;&nbsp;2) Delimiter '</span><span style="color: #0000cc;">:</span><span style="color: #ff00ff;">'<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;'</span><span style="color: #0000cc;">:</span><span style="color: #ff00ff;">' is used as a delimiter. You can'</span>t use <span style="color: #0000ff;">this</span> delimiter <span style="color: #0000ff;">for</span> user name<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">and</span> host name<span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">If</span> the use<span style="color: #0000cc;">/</span>host names contain a <span style="color: #ff00ff;">':'</span><span style="color: #0000cc;">,</span> please <span style="color: #ff0000;">replace</span> with another sign<span style="color: #0000cc;">,</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">for</span> an example <span style="color: #ff00ff;">';'</span><span style="color: #0000cc;">.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;Although <span style="color: #0000ff;">using</span> <span style="color: #0000ff;">this</span> delimiter isn</span></code></p><img src ="http://www.cppblog.com/Panda/aggbug/105068.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2010-01-07 11:15 <a href="http://www.cppblog.com/Panda/archive/2010/01/07/105068.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ACE about server</title><link>http://www.cppblog.com/Panda/archive/2009/12/23/103803.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Wed, 23 Dec 2009 07:59:00 GMT</pubDate><guid>http://www.cppblog.com/Panda/archive/2009/12/23/103803.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/103803.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2009/12/23/103803.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/103803.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/103803.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/Panda/archive/2009/12/23/103803.html'>阅读全文</a><img src ="http://www.cppblog.com/Panda/aggbug/103803.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2009-12-23 15:59 <a href="http://www.cppblog.com/Panda/archive/2009/12/23/103803.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AT&amp;T指令集</title><link>http://www.cppblog.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.cppblog.com/Panda/archive/2009/12/08/102799.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/102799.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2009/12/08/102799.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/102799.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/102799.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: GAS中每个操作都是有一个字符的后缀，表明操作数的大小。                                    C声明                                    GAS后缀                                    大小(字节)                      ...&nbsp;&nbsp;<a href='http://www.cppblog.com/Panda/archive/2009/12/08/102799.html'>阅读全文</a><img src ="http://www.cppblog.com/Panda/aggbug/102799.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2009-12-08 15:48 <a href="http://www.cppblog.com/Panda/archive/2009/12/08/102799.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一致与非一致性代码段</title><link>http://www.cppblog.com/Panda/archive/2009/10/18/98858.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Sat, 17 Oct 2009 18:08:00 GMT</pubDate><guid>http://www.cppblog.com/Panda/archive/2009/10/18/98858.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/98858.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2009/10/18/98858.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/98858.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/98858.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/Panda/archive/2009/10/18/98858.html'>阅读全文</a><img src ="http://www.cppblog.com/Panda/aggbug/98858.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2009-10-18 02:08 <a href="http://www.cppblog.com/Panda/archive/2009/10/18/98858.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>第二章 系统架构浏览2.5</title><link>http://www.cppblog.com/Panda/archive/2009/09/27/97411.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Sun, 27 Sep 2009 15:13:00 GMT</pubDate><guid>http://www.cppblog.com/Panda/archive/2009/09/27/97411.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/97411.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2009/09/27/97411.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/97411.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/97411.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/Panda/archive/2009/09/27/97411.html'>阅读全文</a><img src ="http://www.cppblog.com/Panda/aggbug/97411.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2009-09-27 23:13 <a href="http://www.cppblog.com/Panda/archive/2009/09/27/97411.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>copy on write</title><link>http://www.cppblog.com/Panda/archive/2009/09/27/97390.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Sun, 27 Sep 2009 11:41:00 GMT</pubDate><guid>http://www.cppblog.com/Panda/archive/2009/09/27/97390.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/97390.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2009/09/27/97390.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/97390.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/97390.html</trackback:ping><description><![CDATA[copy on write是引用计数的概念中的一种重要的实现技术。 &nbsp; <br> &nbsp;  &nbsp; <br> &nbsp; 对象之间的复制只通过引用计数来表示，内部其实只有一份对象实例。一旦对象发生变化，才创建对象，然后复制原对象。 &nbsp; <br> &nbsp; 这可以大大提高效率。<img src ="http://www.cppblog.com/Panda/aggbug/97390.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2009-09-27 19:41 <a href="http://www.cppblog.com/Panda/archive/2009/09/27/97390.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CPU结构介绍</title><link>http://www.cppblog.com/Panda/archive/2009/09/23/96988.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Tue, 22 Sep 2009 16:10:00 GMT</pubDate><guid>http://www.cppblog.com/Panda/archive/2009/09/23/96988.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/96988.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2009/09/23/96988.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/96988.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/96988.html</trackback:ping><description><![CDATA[<h1>64位处理器</h1>
这里的64位技术是相对于32位而言的，这个位数指的是CPU GPRs（General-Purpose
Registers，通用寄存器）的数据宽度为64位，64位指令集就是运行64位数据的指令，也就是说处理器一次可以运行64bit数据。64bit处
理器并非现在才有的，在高端的RISC（Reduced Instruction Set
Computing，精简指令集计算机）很早就有64bit处理器了，比如SUN公司的UltraSparc
Ⅲ、IBM公司的POWER5、HP公司的Alpha等。<br>
64bit计算主要有两大优点：可以进行更大范围的整数运算；可以支持更大的内存。不能因为数
字上的变化，而简单的认为64bit处理器的性能是32bit处理器性能的两倍。实际上在32bit应用下，32bit处理器的性能甚至会更强，即使是
64bit处理器，目前情况下也是在32bit应用下性能更强。所以要认清64bit处理器的优势，但不可迷信64bit。<br>
要实现真正意义上的64位计算，光有64位的处理器是不行的，还必须得有64位的操作系统以及
64位的应用软件才行，三者缺一不可，缺少其中任何一种要素都是无法实现64位计算的。目前，在64位处理器方面，Intel和AMD两大处理器厂商都发
布了多个系列多种规格的64位处理器；而在操作系统和应用软件方面，目前的情况不容乐观。因为真正适合于个人使用的64位操作系统现在就只有
Windows XP X64，而Windows XP X64本身也只是一个过渡性质的64位操作系统，在Windows
Vista发布以后就将被淘汰，而且Windows XP
X64本身也不太完善，易用性不高，一个明显的例子就是各种硬件设备的驱动程序很不完善，而且现在64位的应用软件还基本上没有，确实硬件厂商和软件厂商
也不愿意去为一个过渡性质的操作系统编写驱动程序和应用软件。所以要想实现真正的64位计算，恐怕还得等到Windows
Vista普及一段时间之后才行。<br>
目前主流CPU使用的64位技术主要有AMD公司的AMD64位技术、Intel公司的
EM64T技术、和Intel公司的IA-64技术。其中IA-64是Intel独立开发，不兼容现在的传统的32位计算机，仅用于Itanium（安
腾）以及后续产品Itanium 2，一般用户不会涉及到，因此这里仅对AMD64位技术和Intel的EM64T技术做一下简单介绍。<br>
AMD64位技术<br>
AMD64的位技术是在原始32位X86指令集的基础上加入了X86-64扩展64位X86指
令集，使这款芯片在硬件上兼容原来的32位X86软件，并同时支持X86-64的扩展64位计算，使得这款芯片成为真正的64位X86芯片。这是一个真正
的64位的标准，X86-64具有64位的寻址能力。<br>
X86-64新增的几组CPU寄存器将提供更快的执行效率。寄存器是CPU内部用来创建和储存
CPU运算结果和其它运算结果的地方。标准的32-bit
x86架构包括8个通用寄存器（GPR），AMD在X86-64中又增加了8组（R8-R9），将寄存器的数目提高到了16组。X86-64寄存器默认位
64-bit。还增加了8组128-bit
XMM寄存器（也叫SSE寄存器，XMM8-XMM15），将能给单指令多数据流技术（SIMD）运算提供更多的空间，这些128位的寄存器将提供在矢量
和标量计算模式下进行128位双精度处理，为3D建模、矢量分析和虚拟现实的实现提供了硬件基础。通过提供了更多的寄存器，按照X86-64标准生产的
CPU可以更有效的处理数据，可以在一个时钟周期中传输更多的信息。 <br>
EM64T技术<br>
Intel官方是给EM64T这样定义的：EM64T全称Extended Memory
64 Technology，即扩展64bit内存技术。EM64T是Intel IA-32架构的扩展，即IA-32e（Intel
Architectur-32
extension）。IA-32处理器通过附加EM64T技术，便可在兼容IA-32软件的情况下，允许软件利用更多的内存地址空间，并且允许软件进行
32 bit线性地址写入。EM64T特别强调的是对32 bit和64 bit的兼容性。Intel为新核心增加了8个64 bit
GPRs（R8-R15），并且把原有GRPs全部扩展为64 bit，如前文所述这样可以提高整数运算能力。增加8个128bit
SSE寄存器（XMM8-XMM15），是为了增强多媒体性能，包括对SSE、SSE2和SSE3的支持。<br>
Intel为支持EM64T技术的处理器设计了两大模式：传统IA-32模式（legacy
IA-32 mode）和IA-32e扩展模式（IA-32e
mode）。在支持EM64T技术的处理器内有一个称之为扩展功能激活寄存器（extended feature enable
register，IA32_EFER）的部件，其中的Bit10控制着EM64T是否激活。Bit10被称作IA-32e模式有效（IA-32e
mode active）或长模式有效（long mode active，LMA)。当LMA＝0时，处理器便作为一颗标准的32
bit（IA32）处理器运行在传统IA-32模式；当LMA＝1时，EM64T便被激活，处理器会运行在IA-32e扩展模式下。<br>
目前AMD方面支持64位技术的CPU有Athlon 64系列、Athlon
FX系列和Opteron系列。Intel方面支持64位技术的CPU有使用Nocona核心的Xeon系列、使用Prescott
2M核心的Pentium 4 6系列和使用Prescott 2M核心的P4 EE系列。<br><br><br>IA-32（Intel Architecture-32）称为英特尔32位结构，表示指令集结构ISA（Instruction Set Architecture）。<br><br>IA-32处理器（或称32位80x86处理器）就是指具有该指令集结构的处理器，例如英特尔公司的80386、80486以及Pentium各代处理器。AMD的32位处理器兼容这个结构。<br><br><img src ="http://www.cppblog.com/Panda/aggbug/96988.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2009-09-23 00:10 <a href="http://www.cppblog.com/Panda/archive/2009/09/23/96988.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>第二章 系统架构浏览2.2-2.4小节</title><link>http://www.cppblog.com/Panda/archive/2009/09/22/96986.html</link><dc:creator>ChinaPanda</dc:creator><author>ChinaPanda</author><pubDate>Tue, 22 Sep 2009 15:59:00 GMT</pubDate><guid>http://www.cppblog.com/Panda/archive/2009/09/22/96986.html</guid><wfw:comment>http://www.cppblog.com/Panda/comments/96986.html</wfw:comment><comments>http://www.cppblog.com/Panda/archive/2009/09/22/96986.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Panda/comments/commentRss/96986.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Panda/services/trackbacks/96986.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: v\:* {behavior:url(#default#VML);}o\:* {behavior:url(#default#VML);}w\:* {behavior:url(#default#VML);}.shape {behavior:url(#default#VML);}Normal07.8 磅02falsefalsefalse...&nbsp;&nbsp;<a href='http://www.cppblog.com/Panda/archive/2009/09/22/96986.html'>阅读全文</a><img src ="http://www.cppblog.com/Panda/aggbug/96986.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Panda/" target="_blank">ChinaPanda</a> 2009-09-22 23:59 <a href="http://www.cppblog.com/Panda/archive/2009/09/22/96986.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>