<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>fleurer &#187; gas</title>
	<atom:link href="http://www.fleurer-lee.com/tag/gas/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fleurer-lee.com</link>
	<description>rage and love, story of my life.</description>
	<lastBuildDate>Thu, 02 Sep 2010 11:07:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>简介AT&amp;T风格汇编</title>
		<link>http://www.fleurer-lee.com/2010/02/17/%e7%ae%80%e4%bb%8batt%e9%a3%8e%e6%a0%bc%e6%b1%87%e7%bc%96/</link>
		<comments>http://www.fleurer-lee.com/2010/02/17/%e7%ae%80%e4%bb%8batt%e9%a3%8e%e6%a0%bc%e6%b1%87%e7%bc%96/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 04:43:52 +0000</pubDate>
		<dc:creator>fleurer</dc:creator>
				<category><![CDATA[翻译]]></category>
		<category><![CDATA[ASM]]></category>
		<category><![CDATA[gas]]></category>

		<guid isPermaLink="false">http://www.fleurer-lee.com/?p=645734</guid>
		<description><![CDATA[作者：vivek
翻译：ssword
原文：http://sig9.com/articles/att-syntax
本文粗谈一下gas(1)的汇编语法，即AT&#038;T风格汇编。初次接触很可能会觉得它别扭，不过若有其他汇编语言的基础，稍事了解即可快速上手。我假设你熟悉INTEL风格汇编——也就是INTEL手册中的那种风格。方便起见，我就用NASM（Netwide Assembler）来做比对。
gas属于GNU Binary Utilities(binutils)，也是GCC的一个后端。对编写较长的汇编程序而言它并非首选，不过对于类Unix系统的内核级hacking，它就无可替代了。选择AT&#038;T风格使得gas饱受争议，人们总说它只是GCC的后端，而对开发者不友好。INTEL风格汇编的教众也认为，它在可读性及编译上几乎是令人窒息。尽管如此，有一点必须了解：很多操作系统都选择了gas作为底层代码的汇编器。
基本形式
AT&#038;T汇编程序的结构与其他汇编大同小异，伪指令、标签、指令—即最多带三个操作数的助记符。要说AT&#038;T汇编的不同，最显眼的地方就是它操作数的顺序。
例如，一个简单的数据移动指令在INTEL风格下边是这个样子：

mnemonic	destination, source

在AT&#038;T风格下边则是这样：

mnemonic	source, destination

一部分人（包括我）觉得这种格式更贴切。接下来说说AT&#038;T风格指令中的操作数。
寄存器
每个IA-32架构寄存器的名字必须以&#8217;%'作前缀，如%al,%bx,%ds,%cr0，等等。

mov	%ax, %bx

如上的mov指令就是把一个16位寄存器ax中的值移动到另一个16位寄存器bx中。
字面量
每个字面量必须以&#8217;$'为前缀。 例如：

mov	$100,	%bx
mov	$A,	%al

第一个指令是把值100移动到寄存器bx中，第二个指令是把一个字节A移动到AL寄存器中。下面这个指令就是错误的：

mov	%bx,	$100

怎么说呢，这条指令是要把寄存器bx的值移动给一个字面量，显然不靠谱。
内存寻址
在AT&#038;T风格中，内存引用起来是这个格式：

segment-override:signed-offset&#40;base,index,scale&#41;

按你寻址的需求，其中的部分可以省略

%es:100&#40;%eax,%ebx,2&#41;

注意下，基地址及偏移中的数不带前缀&#8217;$'。拿几个例子和对应的NASM风格做个比较应该好些：

GAS memory operand			NASM memory operand
------------------			-------------------
&#160;
100					&#91;100&#93;
%es:100					&#91;es:100&#93;
&#40;%eax&#41;					&#91;eax&#93;
&#40;%eax,%ebx&#41;				&#91;eax+ebx&#93;
&#40;%ecx,%ebx,2&#41;				&#91;ecx+ebx*2&#93;
&#40;,%ebx,2&#41;				&#91;ebx*2&#93;
-10&#40;%eax&#41;				&#91;eax-10&#93;
%ds:-10&#40;%ebp&#41;				&#91;ds:ebp-10&#93;

实例：

mov	%ax,	100
mov	%eax,	-100&#40;%eax&#41;

第一个指令是把寄存器AX中的值移动到数据段寄存器（默认）偏移100的内存位置，第二个指令是把寄存器eax中的值移动到[eax-100]。
操作数大小
有时指明操作数的大小是必须的，尤其是移动字面量到内存。例如这个指令：

mov	$10,	100

这里只说了把值10移动到内存偏址100处，而没有说值的大小。在NASM中，这通过给操作数后面跟个byte/word/dword之类的关键词来指明。而在AT&#038;T风格里，是通过指令中b/w/l之类的后缀指明。如：

movb	$10,	%es:&#40;%eax&#41;

把值为10的一个字节移动到内存地址[ex:eax]，另如：

movl	$10,	%es:&#40;%eax&#41;

把值为10的一个长整数移动到同一位置。
再几个例子：

movl	$100, %ebx
pushl	%eax
popw	%ax

控制流程
jmp,call,ret等指令可以转移程序的执行位置。在同一代码段中跳转，是近距跳转(near)。若是跳转到不同的代码段，就是远程跳转(far)。可用的跳转地址可以来自相对偏移（label）、寄存器、内存以及段偏移指针。相对偏移通过label指明，如下：

label1:
	.
	.
  jmp	label1

使用寄存器或者内存的值做地址的操作数必须加个前缀&#8217;*'。若是远程跳转，必须加个&#8217;l'作前缀，如‘ljmp’，‘lcall’等等。例如：

GAS syntax			NASM syntax
==========			===========
&#160;
jmp	*100			jmp  near &#91;100&#93;
call	*100			call near &#91;100&#93;
jmp	*%eax			jmp  near eax
jmp	*%ecx			call near ecx
jmp	*&#40;%eax&#41;			jmp  near &#91;eax&#93;
call	*&#40;%ebx&#41;			call near &#91;ebx&#93;
ljmp	*100			jmp  far  &#91;100&#93;
lcall	*100			call far  &#91;100&#93;
ljmp	*&#40;%eax&#41;			jmp  far  &#91;eax&#93;
lcall	*&#40;%ebx&#41;			call far  &#91;ebx&#93;
ret				retn
lret				retf
lret $0x100			retf 0x100

段偏移指针按下面的格式指明：

jmp	$segment, $offset

例如：

jmp	$0x10, $0x100000

记住这些很快就能上手了。要了解gas的更多细节，不妨参阅这个文档。
]]></description>
			<content:encoded><![CDATA[<p>作者：vivek<br />
翻译：ssword<br />
原文：<a href="http://sig9.com/articles/att-syntax">http://sig9.com/articles/att-syntax</a></p>
<p>本文粗谈一下gas(1)的汇编语法，即AT&#038;T风格汇编。初次接触很可能会觉得它别扭，不过若有其他汇编语言的基础，稍事了解即可快速上手。我假设你熟悉INTEL风格汇编——也就是INTEL手册中的那种风格。方便起见，我就用NASM（Netwide Assembler）来做比对。</p>
<p>gas属于GNU Binary Utilities(binutils)，也是GCC的一个后端。对编写较长的汇编程序而言它并非首选，不过对于类Unix系统的内核级hacking，它就无可替代了。选择AT&#038;T风格使得gas饱受争议，人们总说它只是GCC的后端，而对开发者不友好。INTEL风格汇编的教众也认为，它在可读性及编译上几乎是令人窒息。尽管如此，有一点必须了解：很多操作系统都选择了gas作为底层代码的汇编器。</p>
<p><strong>基本形式</strong></p>
<p>AT&#038;T汇编程序的结构与其他汇编大同小异，伪指令、标签、指令—即最多带三个操作数的助记符。要说AT&#038;T汇编的不同，最显眼的地方就是它操作数的顺序。</p>
<p>例如，一个简单的数据移动指令在INTEL风格下边是这个样子：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">mnemonic	destination<span style="color: #339933;">,</span> source</pre></div></div>

<p>在AT&#038;T风格下边则是这样：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">mnemonic	source<span style="color: #339933;">,</span> destination</pre></div></div>

<p>一部分人（包括我）觉得这种格式更贴切。接下来说说AT&#038;T风格指令中的操作数。</p>
<p><strong>寄存器</strong></p>
<p>每个IA-32架构寄存器的名字必须以&#8217;%'作前缀，如%al,%bx,%ds,%cr0，等等。</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #00007f; font-weight: bold;">mov</span>	<span style="color: #339933;">%</span><span style="color: #00007f;">ax</span><span style="color: #339933;">,</span> <span style="color: #339933;">%</span><span style="color: #00007f;">bx</span></pre></div></div>

<p>如上的mov指令就是把一个16位寄存器ax中的值移动到另一个16位寄存器bx中。</p>
<p><strong>字面量</strong></p>
<p>每个字面量必须以&#8217;$'为前缀。 例如：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #00007f; font-weight: bold;">mov</span>	$<span style="color: #0000ff;">100</span><span style="color: #339933;">,</span>	<span style="color: #339933;">%</span><span style="color: #00007f;">bx</span>
<span style="color: #00007f; font-weight: bold;">mov</span>	$A<span style="color: #339933;">,</span>	<span style="color: #339933;">%</span><span style="color: #00007f;">al</span></pre></div></div>

<p>第一个指令是把值100移动到寄存器bx中，第二个指令是把一个字节A移动到AL寄存器中。下面这个指令就是错误的：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #00007f; font-weight: bold;">mov</span>	<span style="color: #339933;">%</span><span style="color: #00007f;">bx</span><span style="color: #339933;">,</span>	$<span style="color: #0000ff;">100</span></pre></div></div>

<p>怎么说呢，这条指令是要把寄存器bx的值移动给一个字面量，显然不靠谱。</p>
<p><strong>内存寻址</strong></p>
<p>在AT&#038;T风格中，内存引用起来是这个格式：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">segment</span><span style="color: #339933;">-</span>override<span style="color: #339933;">:</span>signed<span style="color: #339933;">-</span><span style="color: #000000; font-weight: bold;">offset</span><span style="color: #009900; font-weight: bold;">&#40;</span>base<span style="color: #339933;">,</span>index<span style="color: #339933;">,</span>scale<span style="color: #009900; font-weight: bold;">&#41;</span></pre></div></div>

<p>按你寻址的需求，其中的部分可以省略</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #339933;">%</span><span style="color: #00007f;">es</span><span style="color: #339933;">:</span><span style="color: #0000ff;">100</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,%</span><span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span><span style="color: #0000ff;">2</span><span style="color: #009900; font-weight: bold;">&#41;</span></pre></div></div>

<p>注意下，基地址及偏移中的数不带前缀&#8217;$'。拿几个例子和对应的NASM风格做个比较应该好些：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">GAS <span style="color: #000000; font-weight: bold;">memory</span> operand			NASM <span style="color: #000000; font-weight: bold;">memory</span> operand
<span style="color: #339933;">------------------</span>			<span style="color: #339933;">-------------------</span>
&nbsp;
<span style="color: #0000ff;">100</span>					<span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">100</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #339933;">%</span><span style="color: #00007f;">es</span><span style="color: #339933;">:</span><span style="color: #0000ff;">100</span>					<span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">es</span><span style="color: #339933;">:</span><span style="color: #0000ff;">100</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#41;</span>					<span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,%</span><span style="color: #00007f;">ebx</span><span style="color: #009900; font-weight: bold;">&#41;</span>				<span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">eax</span><span style="color: #339933;">+</span><span style="color: #00007f;">ebx</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ecx</span><span style="color: #339933;">,%</span><span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span><span style="color: #0000ff;">2</span><span style="color: #009900; font-weight: bold;">&#41;</span>				<span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ecx</span><span style="color: #339933;">+</span><span style="color: #00007f;">ebx</span><span style="color: #339933;">*</span><span style="color: #0000ff;">2</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span><span style="color: #0000ff;">2</span><span style="color: #009900; font-weight: bold;">&#41;</span>				<span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebx</span><span style="color: #339933;">*</span><span style="color: #0000ff;">2</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #339933;">-</span><span style="color: #0000ff;">10</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#41;</span>				<span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">eax</span><span style="color: #339933;">-</span><span style="color: #0000ff;">10</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #339933;">%</span><span style="color: #00007f;">ds</span><span style="color: #339933;">:-</span><span style="color: #0000ff;">10</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span>				<span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ds</span><span style="color: #339933;">:</span><span style="color: #00007f;">ebp</span><span style="color: #339933;">-</span><span style="color: #0000ff;">10</span><span style="color: #009900; font-weight: bold;">&#93;</span></pre></div></div>

<p>实例：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #00007f; font-weight: bold;">mov</span>	<span style="color: #339933;">%</span><span style="color: #00007f;">ax</span><span style="color: #339933;">,</span>	<span style="color: #0000ff;">100</span>
<span style="color: #00007f; font-weight: bold;">mov</span>	<span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span>	<span style="color: #339933;">-</span><span style="color: #0000ff;">100</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#41;</span></pre></div></div>

<p>第一个指令是把寄存器AX中的值移动到数据段寄存器（默认）偏移100的内存位置，第二个指令是把寄存器eax中的值移动到[eax-100]。</p>
<p><strong>操作数大小</strong></p>
<p>有时指明操作数的大小是必须的，尤其是移动字面量到内存。例如这个指令：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #00007f; font-weight: bold;">mov</span>	$<span style="color: #0000ff;">10</span><span style="color: #339933;">,</span>	<span style="color: #0000ff;">100</span></pre></div></div>

<p>这里只说了把值10移动到内存偏址100处，而没有说值的大小。在NASM中，这通过给操作数后面跟个byte/word/dword之类的关键词来指明。而在AT&#038;T风格里，是通过指令中b/w/l之类的后缀指明。如：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">movb	$<span style="color: #0000ff;">10</span><span style="color: #339933;">,</span>	<span style="color: #339933;">%</span><span style="color: #00007f;">es</span><span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#41;</span></pre></div></div>

<p>把值为10的一个字节移动到内存地址[ex:eax]，另如：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">movl	$<span style="color: #0000ff;">10</span><span style="color: #339933;">,</span>	<span style="color: #339933;">%</span><span style="color: #00007f;">es</span><span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#41;</span></pre></div></div>

<p>把值为10的一个长整数移动到同一位置。</p>
<p>再几个例子：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">movl	$<span style="color: #0000ff;">100</span><span style="color: #339933;">,</span> <span style="color: #339933;">%</span><span style="color: #00007f;">ebx</span>
pushl	<span style="color: #339933;">%</span><span style="color: #00007f;">eax</span>
popw	<span style="color: #339933;">%</span><span style="color: #00007f;">ax</span></pre></div></div>

<p><strong>控制流程</strong></p>
<p>jmp,call,ret等指令可以转移程序的执行位置。在同一代码段中跳转，是近距跳转(near)。若是跳转到不同的代码段，就是远程跳转(far)。可用的跳转地址可以来自相对偏移（label）、寄存器、内存以及段偏移指针。相对偏移通过label指明，如下：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">label1<span style="color: #339933;">:</span>
	<span style="color: #339933;">.</span>
	<span style="color: #339933;">.</span>
  <span style="color: #00007f; font-weight: bold;">jmp</span>	label1</pre></div></div>

<p>使用寄存器或者内存的值做地址的操作数必须加个前缀&#8217;*'。若是远程跳转，必须加个&#8217;l'作前缀，如‘ljmp’，‘lcall’等等。例如：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">GAS syntax			NASM syntax
==========			===========
&nbsp;
<span style="color: #00007f; font-weight: bold;">jmp</span>	<span style="color: #339933;">*</span><span style="color: #0000ff;">100</span>			<span style="color: #00007f; font-weight: bold;">jmp</span>  <span style="color: #000000; font-weight: bold;">near</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">100</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #00007f; font-weight: bold;">call</span>	<span style="color: #339933;">*</span><span style="color: #0000ff;">100</span>			<span style="color: #00007f; font-weight: bold;">call</span> <span style="color: #000000; font-weight: bold;">near</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">100</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #00007f; font-weight: bold;">jmp</span>	<span style="color: #339933;">*%</span><span style="color: #00007f;">eax</span>			<span style="color: #00007f; font-weight: bold;">jmp</span>  <span style="color: #000000; font-weight: bold;">near</span> <span style="color: #00007f;">eax</span>
<span style="color: #00007f; font-weight: bold;">jmp</span>	<span style="color: #339933;">*%</span><span style="color: #00007f;">ecx</span>			<span style="color: #00007f; font-weight: bold;">call</span> <span style="color: #000000; font-weight: bold;">near</span> <span style="color: #00007f;">ecx</span>
<span style="color: #00007f; font-weight: bold;">jmp</span>	<span style="color: #339933;">*</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#41;</span>			<span style="color: #00007f; font-weight: bold;">jmp</span>  <span style="color: #000000; font-weight: bold;">near</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #00007f; font-weight: bold;">call</span>	<span style="color: #339933;">*</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebx</span><span style="color: #009900; font-weight: bold;">&#41;</span>			<span style="color: #00007f; font-weight: bold;">call</span> <span style="color: #000000; font-weight: bold;">near</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebx</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">ljmp</span>	<span style="color: #339933;">*</span><span style="color: #0000ff;">100</span>			<span style="color: #00007f; font-weight: bold;">jmp</span>  <span style="color: #000000; font-weight: bold;">far</span>  <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">100</span><span style="color: #009900; font-weight: bold;">&#93;</span>
lcall	<span style="color: #339933;">*</span><span style="color: #0000ff;">100</span>			<span style="color: #00007f; font-weight: bold;">call</span> <span style="color: #000000; font-weight: bold;">far</span>  <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">100</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">ljmp</span>	<span style="color: #339933;">*</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#41;</span>			<span style="color: #00007f; font-weight: bold;">jmp</span>  <span style="color: #000000; font-weight: bold;">far</span>  <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#93;</span>
lcall	<span style="color: #339933;">*</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebx</span><span style="color: #009900; font-weight: bold;">&#41;</span>			<span style="color: #00007f; font-weight: bold;">call</span> <span style="color: #000000; font-weight: bold;">far</span>  <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebx</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #00007f; font-weight: bold;">ret</span>				<span style="color: #00007f; font-weight: bold;">retn</span>
lret				<span style="color: #00007f; font-weight: bold;">retf</span>
lret $<span style="color: #0000ff;">0x100</span>			<span style="color: #00007f; font-weight: bold;">retf</span> <span style="color: #0000ff;">0x100</span></pre></div></div>

<p>段偏移指针按下面的格式指明：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #00007f; font-weight: bold;">jmp</span>	$segment<span style="color: #339933;">,</span> $offset</pre></div></div>

<p>例如：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #00007f; font-weight: bold;">jmp</span>	$<span style="color: #0000ff;">0x10</span><span style="color: #339933;">,</span> $<span style="color: #0000ff;">0x100000</span></pre></div></div>

<p>记住这些很快就能上手了。要了解gas的更多细节，不妨参阅这个<a href="http://sourceware.org/binutils/docs-2.16/as/index.html">文档</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fleurer-lee.com/2010/02/17/%e7%ae%80%e4%bb%8batt%e9%a3%8e%e6%a0%bc%e6%b1%87%e7%bc%96/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
