Xref: utzoo comp.arch:21048 comp.lang.misc:6681 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!spool.mu.edu!news.nd.edu!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin From: hrubin@pop.stat.purdue.edu (Herman Rubin) Newsgroups: comp.arch,comp.lang.misc Subject: Re: bizarre instructions Summary: Syntax changes would be needed Message-ID: <6728@mentor.cc.purdue.edu> Date: 24 Feb 91 18:18:53 GMT References: <9102220245.AA14853@ucbvax.Berkeley.EDU> Sender: news@mentor.cc.purdue.edu Followup-To: comp.arch Lines: 54 In article <9102220245.AA14853@ucbvax.Berkeley.EDU>, JBS@IBM.COM writes: ................ > Regarding a function to get a the 8 byte product of 2 > 4 byte integers I don't see why this is any worse than Montgomery's > function. In any case it is not needed. Let i4,j4 be 4 byte > i8,j8,k8 be 8 byte. Then write > i8=i4 > j8=j4 > k8=i8*j8 > A sufficiently intelligent compiler will do the right thing. It may > work to write > k8=i4*j4 > This sometimes works in the analogous case where k8 is 4 byte and i4 > and j4 are 2 bytes. However I am not sure strictly speaking that it > should. What does the Fortran standard say? The first approach would require a very intelligent compiler, indeed. The second approach is the "right" one. However, every standard I have read would try the first. Since i8*j8 might not even exist on the machine, at best an inlined function would have to be brought in instead of the single hardware instruction for k8=i4*j4. I have never seen any language description in which the type of the result in a replacement statement affected what operation is performed. The closest I know is the C format, which may or may not work, k8 = (*int8)i4*j4. > As for getting both q and r this is easy just write > iq=ia/ib > ir=mod(ia,ib) > A reasonable compiler will only generate 1 divide with remainder. > I will confess however that while this works when everything is > 4 bytes I don't quite see how to make it work when ia is 8 bytes > (since it seems unreasonable to define the quotient of a 8 byte > integer by a 4 byte integer to be 4 bytes and if it is defined > to be 8 bytes it is then unsafe to use the usual 8 byte by 4 byte > giving 4 byte quotient instruction). > James B. Shearer I do not see why the case of ia being 8 bits is any worse. Sure, there is the problem of overflow, but so what? Also, it should not be ever necessary to do something as complicated as the mod(ia,ib) notation for basic operators, or even not so basic, and more than it should be necessary to write add(a,b) for a+b. But what is really needed in notation is something like iq,ir = ia/ib. -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399 Phone: (317)494-6054 hrubin@l.cc.purdue.edu (Internet, bitnet) {purdue,pur-ee}!l.cc!hrubin(UUCP) Brought to you by Super Global Mega Corp .com