i386-Notes - Using as
Description: Using as

Previous: i386-Bugs, Up: i386-Dependent

#### 9.15.18 Notes

There is some trickery concerning the ‘`mul`’ and ‘`imul`’ instructions that deserves mention. The 16-, 32-, 64- and 128-bit expanding multiplies (base opcode ‘`0xf6`’; extension 4 for ‘`mul`’ and 5 for ‘`imul`’) can be output only in the one operand form. Thus, ‘`imul %ebx, %eax`’ does not select the expanding multiply; the expanding multiply would clobber the ‘`%edx`’ register, and this would confuse `gcc` output. Use ‘`imul %ebx`’ to get the 64-bit product in ‘`%edx:%eax`’.

We have added a two operand form of ‘`imul`’ when the first operand is an immediate mode expression and the second operand is a register. This is just a shorthand, so that, multiplying ‘`%eax`’ by 69, for example, can be done with ‘`imul $69, %eax`’ rather than ‘`imul $69, %eax, %eax`’.