<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.8">
<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">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
@import url("../raisonance.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; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<p>
<a name="i386-Jumps"></a>
<a name="i386_002dJumps"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="i386_002dFloat.html#i386_002dFloat">i386-Float</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="i386_002dMemory.html#i386_002dMemory">i386-Memory</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="i386_002dDependent.html#i386_002dDependent">i386-Dependent</a>
<hr>
</div>

<h4 class="subsection">8.11.7 Handling of Jump Instructions</h4>

<p><a name="index-jump-optimization_002c-i386-865"></a><a name="index-i386-jump-optimization-866"></a><a name="index-jump-optimization_002c-x86_002d64-867"></a><a name="index-x86_002d64-jump-optimization-868"></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 `<samp><span class="samp">data16</span></samp>' instruction prefix), since the 80386
insists upon masking `<samp><span class="samp">%eip</span></samp>' 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 `<samp><span class="samp">jcxz</span></samp>', `<samp><span class="samp">jecxz</span></samp>', `<samp><span class="samp">loop</span></samp>', `<samp><span class="samp">loopz</span></samp>',
`<samp><span class="samp">loope</span></samp>', `<samp><span class="samp">loopnz</span></samp>' and `<samp><span class="samp">loopne</span></samp>' 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&amp;T
80386 assembler tries to get around this problem by expanding `<samp><span class="samp">jcxz foo</span></samp>'
to

<pre class="smallexample">              jcxz cx_zero
              jmp cx_nonzero
     cx_zero: jmp foo
     cx_nonzero:
</pre>
   </body></html>

