user2453180
user2453180

Reputation: 131

Intel instruction set: multiply with EAX, EBX, ECX or EDX?

How do you suppose to know that when 'mul ecx' was executed. ECX would be multiplied with EAX? And not with EBX or EDX?

mul ecx, eax

would make more sense though.

Upvotes: 1

Views: 2391

Answers (1)

Ira Baxter
Ira Baxter

Reputation: 95420

The instruction set is simply defined that way.

Intel could have defined it in other ways, including ways that would have allowed you to completely specify input and output registers, but they did not.

The excuse is arguably that at the time the various multiply instructions were added to the instruction set of the CPU (8086 vintage, I think), that the existing instruction didn't have any obvious places to put multiply where it could share the general decoding scheme available to other instructions (e.g., mov, add, xor, etc), that there were not a lot of available transistors to do fancy decoding schemes to enable some other way to encode general operands, and that any transistors that were available were better dedicated to the multiplication/division logic.

Finally, the multiply instruction is needed rather less often than the general instructions (mov, add, xor) and so the effort to move the operands into place/results from fixed places doesn't cause a lot of code bloat or impact performance much. The designers did find a way to include a source operand. You should consider it lucky it wasn't simply defined as multiplying EAX and EDX to produce EDX:EAX, which is a time-honored scheme used in many earlier computer architectures. And the needs haven't changed much for integer multiply in the x86 instruction set since.

The floating point/vector arithmetic is an entirely different matter.

Upvotes: 3

Related Questions