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/compiler/PervEnv/Basis/pack-word-l16.sml
ViewVC logotype

View of /sml/trunk/src/compiler/PervEnv/Basis/pack-word-l16.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 90 - (download) (annotate)
Tue May 12 21:54:55 1998 UTC (22 years, 3 months ago)
Original Path: sml/branches/FLINT/src/compiler/PervEnv/Basis/pack-word-l16.sml
File size: 1521 byte(s)
This commit was manufactured by cvs2svn to create branch 'FLINT'.
(* pack-word-l16.sml
 * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
 * This is the non-native implementation of 16-bit little-endian packing
 * operations.

structure Pack16Little : PACK_WORD =
    structure W = LargeWord
    structure W8 = Word8
    structure W8V = InlineT.Word8Vector
    structure W8A = InlineT.Word8Array

    val bytesPerElem = 2
    val isBigEndian = false

  (* convert the byte length into word16 length (n div 2), and check the index *)
    fun chkIndex (len, i) = let
	  val len = Word.toIntX(Word.>>(Word.fromInt len, 0w1))
	    if (InlineT.DfltInt.ltu(i, len)) then () else raise Subscript

    fun mkWord (b1, b2) =
	  W.orb(W.<<(Word8.toLargeWord b2, 0w8), Word8.toLargeWord b1)

    fun signExt w = W.-(W.xorb(0wx8000, w), 0wx8000)

    fun subVec (vec, i) = let
	  val _ = chkIndex (W8V.length vec, i)
	  val k = i+i
	    mkWord (W8V.sub(vec, k), W8V.sub(vec, k+1))
    fun subVecX(vec, i) = signExt (subVec (vec, i))

    fun subArr (arr, i) = let
	  val _ = chkIndex (W8A.length arr, i)
	  val k = i+i
	    mkWord (W8A.sub(arr, k), W8A.sub(arr, k+1))
    fun subArrX(arr, i) = signExt (subArr (arr, i))

    fun update (arr, i, w) = let
	  val _ = chkIndex (W8A.length arr, i)
	  val k = i+i
	    W8A.update (arr, k, W8.fromLargeWord w);
	    W8A.update (arr, k+1, W8.fromLargeWord(W.>>(w, 0w8)))


 * $Log: pack-word-l16.sml,v $
 * Revision  1998/04/08 18:40:04  george
 * Version 110.5

ViewVC Help
Powered by ViewVC 1.0.0