Assembly or ....
John Mashey
mash at mips.COM
Tue Nov 29 15:25:24 AEST 1988
In article <1032 at l.cc.purdue.edu> cik at 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: <generic disclaimer, I speak for me only, etc>
UUCP: {ames,decwrl,prls,pyramid}!mips!mash OR mash at mips.com
DDD: 408-991-0253 or 408-720-1700, x253
USPS: MIPS Computer Systems, 930 E. Arques, Sunnyvale, CA 94086
More information about the Comp.lang.c
mailing list