Xref: utzoo comp.lang.c++:2113 comp.lang.c:14358 comp.lang.forth:665 comp.lang.fortran:1532 comp.lang.misc:2188 comp.arch:7349
Path: utzoo!utgpu!watmath!clyde!att!rutgers!mailrus!ames!vsi1!daver!mips!mash
From: mash@mips.COM (John Mashey)
Newsgroups: comp.lang.c++,comp.lang.c,comp.lang.forth,comp.lang.fortran,comp.lang.misc,comp.arch
Subject: Re: Assembly or ....
Message-ID: <8938@winchester.mips.COM>
Date: 29 Nov 88 05:25:24 GMT
References: <1388@aucs.UUCP> <729@convex.UUCP> <1961@crete.cs.glasgow.ac.uk> <8993@smoke.BRL.MIL> <1032@l.cc.purdue.edu>
Reply-To: mash@mips.COM (John Mashey)
Organization: MIPS Computer Systems, Sunnyvale, CA
Lines: 27

In article <1032@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes:
...
>Another effect of the HLL tyranny is that the operations which are beyond
>the ken of th HLL designers are disappearing from the machines.  Other
>useful operations are not getting in.  For example, suppose we want to
>divide a by b, obtaining an integer result i and a remainder c.  I know
>of no machine with this instruction, and this is not that unusual an 
>instruction to demand.  It is cheap in hardware, and extremely expensive
>in software--at least 4 instructions.

Although I don't necessarily subscribe to Herman's opinions, R2000 divides
actually do this (leave both results in registers).  Although I shouldn't
have been, I was surprised to find that the following C code, compiled
unoptimized (optimized, it essentially disappears, of course):

main() {
	register i,j,k;
	i = j / 7;
	k = j % 7;
}

generates one divide instruction to get both of the results.
-- 
-john mashey	DISCLAIMER: 
UUCP: 	{ames,decwrl,prls,pyramid}!mips!mash  OR  mash@mips.com
DDD:  	408-991-0253 or 408-720-1700, x253
USPS: 	MIPS Computer Systems, 930 E. Arques, Sunnyvale, CA 94086