Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/system/Basis/Implementation/word32.sml
ViewVC logotype

View of /sml/trunk/src/system/Basis/Implementation/word32.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (download) (annotate)
Thu Jun 1 18:34:03 2000 UTC (19 years, 4 months ago) by monnier
File size: 1795 byte(s)
bring revisions from the vendor branch to the trunk
(* word32.sml
 *
 * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
 *
 *)

structure Word32Imp : WORD =
  struct
    infix 7 * div mod
    infix 6 + -
    infix 4 > < >= <=

    structure W32 = InlineT.Word32

    type word = Word32.word

    val wordSize = 32

    val toLargeWord   : word -> LargeWord.word = W32.toLargeWord
    val toLargeWordX  : word -> LargeWord.word = W32.toLargeWordX
    val fromLargeWord : LargeWord.word -> word = W32.fromLargeWord

    val toLargeInt    = W32.toLargeInt
    val toLargeIntX   = W32.toLargeIntX
    val fromLargeInt  = W32.fromLargeInt

    val toInt   : word -> int = W32.toInt
    val toIntX  : word -> int = W32.toIntX
    val fromInt : int -> word = W32.fromInt

    val orb  : word * word -> word = W32.orb
    val xorb : word * word -> word = W32.xorb
    val andb : word * word -> word = W32.andb
    val notb : word -> word = W32.notb

    val op * : word * word -> word = W32.*
    val op + : word * word -> word = W32.+
    val op - : word * word -> word = W32.-
    val op div : word * word -> word = W32.div
    fun op mod(a:word,b:word):word = a-(a div b)*b

    fun compare (w1, w2) =
	  if (W32.<(w1, w2)) then LESS
	  else if (W32.>(w1, w2)) then GREATER
	  else EQUAL
    val op > : word * word -> bool = W32.>
    val op >= : word * word -> bool = W32.>=
    val op < : word * word -> bool = W32.<
    val op <= : word * word -> bool = W32.<=

    val <<   = W32.chkLshift
    val >>   = W32.chkRshiftl
    val ~>>  = W32.chkRshift 

    fun min (w1, w2) = if (w1 < w2) then w1 else w2
    fun max (w1, w2) = if (w1 > w2) then w1 else w2

    val fmt = NumFormat.fmtWord
    val toString = fmt StringCvt.HEX

    val scan = NumScan.scanWord
    val fromString = PreBasis.scanString (scan StringCvt.HEX)

  end  (* structure Word32 *)



root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0