Xref: utzoo comp.arch:10554 comp.lang.misc:3055 Path: utzoo!attcan!uunet!ginosko!husc6!purdue!mentor.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.arch,comp.lang.misc Subject: Re: Double Width Integer Multiplication and Division Summary: Responses Message-ID: <1399@l.cc.purdue.edu> Date: 8 Jul 89 15:19:09 GMT References: <57125@linus.UUCP> <1989Jun24.230056.27774@utzoo.uucp> <4909@ficc.uu.net> Followup-To: comp.lang.misc Organization: Purdue University Statistics Department Lines: 82 In article <4909@ficc.uu.net>, peter@ficc.uu.net (Peter da Silva) writes: > In article <1388@l.cc.purdue.edu>, cik@l.cc.purdue.edu (Herman Rubin) writes: > > For example, on a machine in which there is division yielding a quotient > > and a remainder, I want to write > > > q,r = x/y; > > (1) What does this do when no such operation exists? What does q = x/y; get you if division does not exist? There are such machines. Would it be totally rash to suggest that the reason that this does not exist on more machines may be related to the fact that it does not exist in the languages? > (2) How does this fit in with the rest of the expression syntax? I do not see the problem here. The fact that there are a fair number of people now using it is a good reason to keep it. If you mean, how does it fit into compound expressions, there are ways of doing it, but I am not sure that I care. If I have to give them up, but can specify local temporaries, I will. > (3) Get a good optimiser and say: > q = x/y; > r = x%y; Does your language even have long long? The same remark holds about temporaries. And if I have to put them in adjacent registers because of the hardware, I will. > (4) Is it obvious which is the quotient and which is the remainder > when you have something like: > tens,relx = muscle0.fiber/potential; All languages have conventions. I find many of them more annoying than this problem. > (5) What if x or y contain other operations that could require a > quotient or remainder? If it is necessary to break a complex operation into simple parts, do it. This does not apply to the original problem, as the operation wanted is, on many machines, a single machine instruction. If the machine can do it in one instruction, I demand that I can put it in the language as one statement. I do not expect everything to be portable. > (6) What does this mean: > q,r,s = x/y/z; I do not know. I am not even sure what a = x/y/z; means. I would not use that without parentheses. I suspect that what is wanted is a pair of statements, with an intermediate result a declared temporary. > (7) What does this sort of micro-optimisation gain you? Except in a > tight loop, very little. Since you're intending to be machine- > specific anyway, why not squirrel that loop away in an assembly > routine? Notation can be very important. I consider the introduction of algebraic symbols by Diophantus a major contribution. My complaint about assembly language (not machine language) is that it is written in a thoroughly obfuscated notation. But machine language needs an "alphabet." I am perfectly willing to write in what I call a HLL machine language. Given a decent macro processor, in which the syntax, including the macro name, is arbitrary, I would write that. This is really what a compiler is; a macro processor, possibly with an optimizer added. Some "optimizers" do little more than add to the macro processor. So what I am saying is that if the machine can do it, I want a reasonable way to include it. I do not consider the current assemblers reasonable, and I have pointed out some of the reasons why. > Peter da Silva, Xenix Support, Ferranti International Controls Corporation. > Business: peter@ficc.uu.net, +1 713 274 5180. | "WHAT HAPPENED TO ALL > Personal: peter@sugar.hackercorp.com. `-_-' | THE WOMEN IN TEXAS?" > Quote: Have you hugged your wolf today? 'U` | -- ACS1W@jane.uh.edu (meesh) -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu (Internet, bitnet, UUCP)