Path: utzoo!attcan!uunet!snorkelwacker!usc!cs.utexas.edu!rice!sun-spots-request From: tac@cs.brown.edu (Theodore A. Camus) Newsgroups: comp.sys.sun Subject: Re: Integer math on SPARCs Keywords: Miscellaneous Message-ID: <8148@brazos.Rice.edu> Date: 24 May 90 17:57:27 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 21 Approved: Sun-Spots@rice.edu X-Refs: Original: v9n178 X-Sun-Spots-Digest: Volume 9, Issue 182, message 4 > 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@cs.brown.edu Ted Camus ARPAnet: tac%cs.brown.edu@relay.cs.net Box 1910 CS Dept BITnet: tac@browncs.BITNET Brown University "An ounce of example is worth a pound of theory." Providence, RI 02912