Assembly or ....

Edward C Horvath ech at poseidon.ATT.COM
Thu Dec 1 13:59:59 AEST 1988


In article <1032 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
> 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,...

In article <8938 at winchester.mips.COM> mash at mips.COM (John Mashey) writes:
> Although I don't necessarily subscribe to Herman's opinions, R2000 divides
> actually do this (leave both results in registers).  

>From article <949 at taux01.UUCP>, by cjosta at taux01.UUCP (Jonathan Sweedler):
> The 32000 series has a DEI (Divide Extended Integer) instruction that
> also does this. 

Hmm, add the MC68K, the PDP-11, and the IBM s/360 et fils.  Put another way,
does anyone have an example of a common processor that DOESN'T give you the
remainder and quotient at the same time?  I don't know the Intel chips, so
perhaps the original author just knows that the *86 divide doesn't do this.

It's interesting, though, how few languages provide such a "two-valued"
functions (all right, I can feel the mathematicians cringing.  So few
languages provide functions with ranges like ZxZ, OK?).  I've seen
implementations of FORTH, by the way, where the expression
	a b /%
for example, divides a by b, leaving a/b and a%b on the stack.  Of
course, if your favorite flavor of forth didn't provide the /% operator
("word") you'd just define it...

=Ned=



More information about the Comp.lang.c mailing list