Assembly or ....

Dik T. Winter dik at cwi.nl
Wed Nov 30 10:37:09 AEST 1988


In article <21390 at apple.Apple.COM> desnoyer at Apple.COM (Peter Desnoyers) writes:
 > In article <1032 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
 > >
 > > 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.  
 > 
 > I can't think of a machine that doesn't. The only machine language
 > manuals on my desk (68000 and HPC16083) show this instruction.
 > If anyone knows of a machine that doesn't leave the remainder in
 > a register, I would be interested in knowing of it. Such a machine
 > either throws the remainder away or uses some algorithm besides
 > shift-and-subtract. (for instance hard-wired.)
 > 
Well, if I remember right, the we32000 does that (the thing in a 3b2 and a
tty5620).  It has a divide, quotient, remainder and modulus instruction
like the ns32000, but unlike the ns32000 no instruction that gives you
both.  This is (I think) an example of a machine for which the instructions
are dictated by a HLL (C in this case), which Herman Rubin so deplores.
On the other hand, this need not be wrong if the operations can be
pipelined.  E.g. if i/j and i%j take 23 cycles each, but the second can
start one cycle after the first you do not lose very much.

In article <1034 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
 > I do not know if I made it clear in my initial posting, but the problem
 > arises if the types of a, b, and c are floating.  Not that the quote from
 > my paper specifically has i an integer.

Indeed you did not make that clear (seems evident :-)).
I know no machines that gives you both quotient and remainder on a floating
point division, stronger still, before the IEEE standard there was (I
believe) no machine that would give you the remainder, only quotients
allowed.  IEEE changed that and many machines now have floating point
division and floating point remainder, but the result is floating point
for both.  This explains also why not both are returned.  To obtain the
(exact) remainder may require a larger number of steps than the
(inexact) quotient.  I agree however that those machines could return the
quotient when doing a remainder operation.  Note that IEEE did *not*
mandate operations that return two results.  So no machine I know does
return two results; even with sine and cosine, which is implemented on
many (as an extension to IEEE?).  The CORDIC algorithm will give you fast
both sine and cosine, but is only efficient in hardware.  But also here,
pipelining may be a deciding point.
-- 
dik t. winter, cwi, amsterdam, nederland
INTERNET   : dik at cwi.nl
BITNET/EARN: dik at mcvax



More information about the Comp.lang.c mailing list