toolchain/share/doc/as.html/i386_002dNotes.html

70 lines
3.9 KiB
HTML
Raw Normal View History

2024-01-10 05:24:32 +00:00
<html lang="en">
<head>
<title>i386-Notes - 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_002dBugs.html#i386_002dBugs" title="i386-Bugs">
<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-Notes"></a>
<a name="i386_002dNotes"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="i386_002dBugs.html#i386_002dBugs">i386-Bugs</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="i386_002dDependent.html#i386_002dDependent">i386-Dependent</a>
<hr>
</div>
<h4 class="subsection">9.16.17 Notes</h4>
<p><a name="index-i386-_0040code_007bmul_007d_002c-_0040code_007bimul_007d-instructions-1273"></a><a name="index-g_t_0040code_007bmul_007d-instruction_002c-i386-1274"></a><a name="index-g_t_0040code_007bimul_007d-instruction_002c-i386-1275"></a><a name="index-g_t_0040code_007bmul_007d-instruction_002c-x86_002d64-1276"></a><a name="index-g_t_0040code_007bimul_007d-instruction_002c-x86_002d64-1277"></a>There is some trickery concerning the &lsquo;<samp><span class="samp">mul</span></samp>&rsquo; and &lsquo;<samp><span class="samp">imul</span></samp>&rsquo;
instructions that deserves mention. The 16-, 32-, 64- and 128-bit expanding
multiplies (base opcode &lsquo;<samp><span class="samp">0xf6</span></samp>&rsquo;; extension 4 for &lsquo;<samp><span class="samp">mul</span></samp>&rsquo; and 5
for &lsquo;<samp><span class="samp">imul</span></samp>&rsquo;) can be output only in the one operand form. Thus,
&lsquo;<samp><span class="samp">imul %ebx, %eax</span></samp>&rsquo; does <em>not</em> select the expanding multiply;
the expanding multiply would clobber the &lsquo;<samp><span class="samp">%edx</span></samp>&rsquo; register, and this
would confuse <code>gcc</code> output. Use &lsquo;<samp><span class="samp">imul %ebx</span></samp>&rsquo; to get the
64-bit product in &lsquo;<samp><span class="samp">%edx:%eax</span></samp>&rsquo;.
<p>We have added a two operand form of &lsquo;<samp><span class="samp">imul</span></samp>&rsquo; when the first operand
is an immediate mode expression and the second operand is a register.
This is just a shorthand, so that, multiplying &lsquo;<samp><span class="samp">%eax</span></samp>&rsquo; by 69, for
example, can be done with &lsquo;<samp><span class="samp">imul $69, %eax</span></samp>&rsquo; rather than &lsquo;<samp><span class="samp">imul
$69, %eax, %eax</span></samp>&rsquo;.
<!-- Copyright (C) 2002-2019 Free Software Foundation, Inc. -->
<!-- Contributed by David Mosberger-Tang <davidm@hpl.hp.com> -->
<!-- This is part of the GAS manual. -->
<!-- For copying conditions, see the file as.texinfo. -->
</body></html>