--
--	Inmos Libraries
--	Copyright (C) 1988, 1989, 1990, 1991, 1993  Inmos Limited
--
--	This library is free software; you can redistribute it and/or
--	modify it under the terms of the GNU Lesser General Public
--	License as published by the Free Software Foundation; either
--	version 2 of the License, or (at your option) any later version.
--
--	This library is distributed in the hope that it will be useful,
--	but WITHOUT ANY WARRANTY; without even the implied warranty of
--	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
--	Lesser General Public License for more details.
--
--	You should have received a copy of the GNU Lesser General Public
--	License along with this library; if not, write to the Free Software
--	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
--

--{{{  #options and #comments
#OPTION "E V"  -- no compiler libs, no vector space
#COMMENT "TA compiler library, V1.2 20/02/92"
#COMMENT "(c) Copyright INMOS Limited 1988"
--}}}

#PRAGMA TRANSLATE BITREVNBITS "BITREVNBITS%O"

--{{{  BITREVNBITS in occam
INT FUNCTION BITREVNBITS (VAL INT data, nbits)

  --{{{  history
  -- V1.1, 21/02/89.
  -- V1.2, 20/02/92, SRH.  Textual clean up and improvment in naming of
  -- parameters.
  --}}}

  INT rev :
  VALOF
    --{{{  
    INT count, temp :
    SEQ
      rev   := 0
      temp  := data
      count := nbits
      WHILE count > 0
        SEQ
          rev   := rev << 1
          rev   := rev \/ (temp /\ 1)
          temp  := temp >> 1
          count := count - 1
    --}}}
    RESULT rev
:
--}}}
