blob: 4630810c66d8580a6570f2902e39631a10e8f27f [file] [log] [blame]
<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, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010 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>
<link rel="stylesheet" type="text/css" href="../cs.css">
</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.13.16 Notes</h4>
<p><a name="index-i386-_0040code_007bmul_007d_002c-_0040code_007bimul_007d-instructions-994"></a><a name="index-g_t_0040code_007bmul_007d-instruction_002c-i386-995"></a><a name="index-g_t_0040code_007bimul_007d-instruction_002c-i386-996"></a><a name="index-g_t_0040code_007bmul_007d-instruction_002c-x86_002d64-997"></a><a name="index-g_t_0040code_007bimul_007d-instruction_002c-x86_002d64-998"></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 2000, 2003 Free Software Foundation, Inc. -->
<!-- This is part of the GAS manual. -->
<!-- For copying conditions, see the file as.texinfo. -->
</body></html>