[MLton-devel] Fwd: C back end for MLton

Matthew Fluet Matthew Fluet <fluet@CS.Cornell.EDU>
Tue, 5 Nov 2002 12:02:16 -0500 (EST)


> > Here's what I got back from the gcc mail list:
> ...
> > I forgot to mention:  The use of asm is nonsensical here anyway.  A simple
> >   int Int_quot (int n, int d) { return n / d; }
> > produces exactly the same code.
> 
> Henry, care to comment?  I believe that that asm is in MLton at your
> request.

In a Feb 4, 2002 mail, I pointed out:

K&R are a little lax on the semantics of / and % on negative operands:
"The direction of truncation for / and the sign of the result for % are
machine-dependent for negative operands, ..." (p. 41)  (See also p. 205.)

The SML Basis is very specific on directions of truncation and signs.

Probably, gcc just maps / and % to their hardware equivalents, which, at
least on x86, correspond to the Basis.  But, nothing in ANSI C prevents it
from doing something else; likewise, Visual C++ might have a different
interpretation.



-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel