Integer math on SPARCs
Theodore A. Camus
tac at cs.brown.edu
Fri May 25 03:57:27 AEST 1990
> Whenever two integer variables are multiplied together, the assembly
> code generated by the C compiler (both Sun's and gcc) generate the line:
>
> call .mul, 2
>
> rather than use the integer multiply operation. Why is that? Floating
> point multiplies generate an fmuld assembler instruction. What's going on?
Simple - in keeping with the RISC philosophy, there is no integer multiply
instruction on the SPARC ALU. The ".mul" routine computes multiplication
literally by shifts and adds, just like we learned in 3rd grade. There is
actually a "mulscc" instruction which does a shift and add in a single
cycle. (There is also a .umul for unsigned multiplication, as well as
.div, .udiv, .rem, and .urem.)
- Ted
CSnet: tac at cs.brown.edu Ted Camus
ARPAnet: tac%cs.brown.edu at relay.cs.net Box 1910 CS Dept
BITnet: tac at browncs.BITNET Brown University
"An ounce of example is worth a pound of theory." Providence, RI 02912
More information about the Comp.sys.sun
mailing list