toolchain/share/doc/as.html/i386_002dJumps.html

74 lines
3.8 KiB
HTML
Raw Permalink Normal View History

2024-01-10 05:24:32 +00:00
<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.13">
<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-2019 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.3
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''.
-->
<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; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="i386-Jumps"></a>
<a name="i386_002dJumps"></a>
<p>
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">9.16.8 Handling of Jump Instructions</h4>
<p><a name="index-jump-optimization_002c-i386-1225"></a><a name="index-i386-jump-optimization-1226"></a><a name="index-jump-optimization_002c-x86_002d64-1227"></a><a name="index-x86_002d64-jump-optimization-1228"></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 &lsquo;<samp><span class="samp">data16</span></samp>&rsquo; instruction prefix), since the 80386
insists upon masking &lsquo;<samp><span class="samp">%eip</span></samp>&rsquo; 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 &lsquo;<samp><span class="samp">jcxz</span></samp>&rsquo;, &lsquo;<samp><span class="samp">jecxz</span></samp>&rsquo;, &lsquo;<samp><span class="samp">loop</span></samp>&rsquo;, &lsquo;<samp><span class="samp">loopz</span></samp>&rsquo;,
&lsquo;<samp><span class="samp">loope</span></samp>&rsquo;, &lsquo;<samp><span class="samp">loopnz</span></samp>&rsquo; and &lsquo;<samp><span class="samp">loopne</span></samp>&rsquo; 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 &lsquo;<samp><span class="samp">jcxz foo</span></samp>&rsquo;
to
<pre class="smallexample"> jcxz cx_zero
jmp cx_nonzero
cx_zero: jmp foo
cx_nonzero:
</pre>
</body></html>