72 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
		
		
			
		
	
	
			72 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| 
								 | 
							
								<html lang="en">
							 | 
						||
| 
								 | 
							
								<head>
							 | 
						||
| 
								 | 
							
								<title>i386-Jumps - Using as</title>
							 | 
						||
| 
								 | 
							
								<meta http-equiv="Content-Type" content="text/html">
							 | 
						||
| 
								 | 
							
								<meta name="description" content="Using as">
							 | 
						||
| 
								 | 
							
								<meta name="generator" content="makeinfo 4.7">
							 | 
						||
| 
								 | 
							
								<link title="Top" rel="start" href="index.html#Top">
							 | 
						||
| 
								 | 
							
								<link rel="up" href="i386_002dDependent.html#i386_002dDependent" title="i386-Dependent">
							 | 
						||
| 
								 | 
							
								<link rel="prev" href="i386_002dMemory.html#i386_002dMemory" title="i386-Memory">
							 | 
						||
| 
								 | 
							
								<link rel="next" href="i386_002dFloat.html#i386_002dFloat" title="i386-Float">
							 | 
						||
| 
								 | 
							
								<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
							 | 
						||
| 
								 | 
							
								<!--
							 | 
						||
| 
								 | 
							
								This file documents the GNU Assembler "as".
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002,
							 | 
						||
| 
								 | 
							
								2006, 2007 Free Software Foundation, Inc.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Permission is granted to copy, distribute and/or modify this document
							 | 
						||
| 
								 | 
							
								under the terms of the GNU Free Documentation License, Version 1.1
							 | 
						||
| 
								 | 
							
								or any later version published by the Free Software Foundation;
							 | 
						||
| 
								 | 
							
								with no Invariant Sections, with no Front-Cover Texts, and with no
							 | 
						||
| 
								 | 
							
								Back-Cover Texts.  A copy of the license is included in the
							 | 
						||
| 
								 | 
							
								section entitled ``GNU Free Documentation License''.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								man end-->
							 | 
						||
| 
								 | 
							
								<meta http-equiv="Content-Style-Type" content="text/css">
							 | 
						||
| 
								 | 
							
								<style type="text/css"><!--
							 | 
						||
| 
								 | 
							
								  pre.display { font-family:inherit }
							 | 
						||
| 
								 | 
							
								  pre.format  { font-family:inherit }
							 | 
						||
| 
								 | 
							
								  pre.smalldisplay { font-family:inherit; font-size:smaller }
							 | 
						||
| 
								 | 
							
								  pre.smallformat  { font-family:inherit; font-size:smaller }
							 | 
						||
| 
								 | 
							
								  pre.smallexample { font-size:smaller }
							 | 
						||
| 
								 | 
							
								  pre.smalllisp    { font-size:smaller }
							 | 
						||
| 
								 | 
							
								  span.sc { font-variant:small-caps }
							 | 
						||
| 
								 | 
							
								  span.roman { font-family: serif; font-weight: normal; } 
							 | 
						||
| 
								 | 
							
								--></style>
							 | 
						||
| 
								 | 
							
								</head>
							 | 
						||
| 
								 | 
							
								<body>
							 | 
						||
| 
								 | 
							
								<div class="node">
							 | 
						||
| 
								 | 
							
								<p>
							 | 
						||
| 
								 | 
							
								<a name="i386_002dJumps"></a>Next: <a rel="next" accesskey="n" href="i386_002dFloat.html#i386_002dFloat">i386-Float</a>,
							 | 
						||
| 
								 | 
							
								Previous: <a rel="previous" accesskey="p" href="i386_002dMemory.html#i386_002dMemory">i386-Memory</a>,
							 | 
						||
| 
								 | 
							
								Up: <a rel="up" accesskey="u" href="i386_002dDependent.html#i386_002dDependent">i386-Dependent</a>
							 | 
						||
| 
								 | 
							
								<hr><br>
							 | 
						||
| 
								 | 
							
								</div>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<h4 class="subsection">9.13.9 Handling of Jump Instructions</h4>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<p><a name="index-jump-optimization_002c-i386-919"></a><a name="index-i386-jump-optimization-920"></a><a name="index-jump-optimization_002c-x86_002d64-921"></a><a name="index-x86_002d64-jump-optimization-922"></a>Jump instructions are always optimized to use the smallest possible
							 | 
						||
| 
								 | 
							
								displacements.  This is accomplished by using byte (8-bit) displacement
							 | 
						||
| 
								 | 
							
								jumps whenever the target is sufficiently close.  If a byte displacement
							 | 
						||
| 
								 | 
							
								is insufficient a long displacement is used.  We do not support
							 | 
						||
| 
								 | 
							
								word (16-bit) displacement jumps in 32-bit mode (i.e. prefixing the jump
							 | 
						||
| 
								 | 
							
								instruction with the <span class="samp">data16</span> instruction prefix), since the 80386
							 | 
						||
| 
								 | 
							
								insists upon masking <span class="samp">%eip</span> to 16 bits after the word displacement
							 | 
						||
| 
								 | 
							
								is added. (See also see <a href="i386_002dArch.html#i386_002dArch">i386-Arch</a>)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								   <p>Note that the <span class="samp">jcxz</span>, <span class="samp">jecxz</span>, <span class="samp">loop</span>, <span class="samp">loopz</span>,
							 | 
						||
| 
								 | 
							
								<span class="samp">loope</span>, <span class="samp">loopnz</span> and <span class="samp">loopne</span> instructions only come in byte
							 | 
						||
| 
								 | 
							
								displacements, so that if you use these instructions (<code>gcc</code> does
							 | 
						||
| 
								 | 
							
								not use them) you may get an error message (and incorrect code).  The AT&T
							 | 
						||
| 
								 | 
							
								80386 assembler tries to get around this problem by expanding <span class="samp">jcxz foo</span>
							 | 
						||
| 
								 | 
							
								to
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<pre class="smallexample">              jcxz cx_zero
							 | 
						||
| 
								 | 
							
								              jmp cx_nonzero
							 | 
						||
| 
								 | 
							
								     cx_zero: jmp foo
							 | 
						||
| 
								 | 
							
								     cx_nonzero:
							 | 
						||
| 
								 | 
							
								</pre>
							 | 
						||
| 
								 | 
							
								   </body></html>
							 | 
						||
| 
								 | 
							
								
							 |