Google
 

Trailing-Edge - PDP-10 Archives - DEC_CMS-20_V1.0_SRC - cms/sources/crcops.bli
There are no other files named crcops.bli in the archive.
MODULE CRCOPS (IDENT = '1',
		%IF
		    %BLISS(BLISS32)
		%THEN
		    LANGUAGE(BLISS32),
		    ADDRESSING_MODE(EXTERNAL=LONG_RELATIVE,
				    NONEXTERNAL=LONG_RELATIVE)
		%ELSE
		    LANGUAGE(BLISS36)
		%FI
		)=
BEGIN

!
!			COPYRIGHT (c) 1982 BY
!	      DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
!
! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
! ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH  LICENSE AND WITH THE
! INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR  ANY  OTHER
! COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
! OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
! TRANSFERRED.
!
! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE  WITHOUT  NOTICE
! AND  SHOULD  NOT  BE  CONSTRUED  AS  A COMMITMENT BY DIGITAL EQUIPMENT
! CORPORATION.
!
! DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR  RELIABILITY  OF  ITS
! SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
!

!++
! FACILITY: CMS library processor
!
! ABSTRACT:
!   This module provides routines which calculate the CRC of a file
!   for library integrity purposes. The calculated number is written
!   at the end of the file and re-calculated and checked each time the
!   entire file is read. The polynomial used is the AUTODIN-II 32-bit
!   polynomial, with an initial value of -1.
!
!
! ENVIRONMENT: VAX/VMS
!
! AUTHOR: Sue Millar, CREATION DATE: June 1981
!
! MODIFIED BY:
!
!--

!
! TABLE OF CONTENTS:
!

FORWARD ROUTINE
	CRCTABLE: NOVALUE,	  !Initialize the table for processing
	CRCCALC;		  !Calculate the CRC of a string
!
! INCLUDE FILES:
!

%if %bliss(bliss32) %then
    library 'sys$library:starlet';
%else
    require 'jsys:';
%fi

library 'XPORT:';

require 'BLISSX:' ;

require 'SCONFG:' ;

%if %bliss(bliss32)
%then
builtin
	crc;
%fi
!
! MACROS:
!
!
! EQUATED SYMBOLS:
!
!
! OWN STORAGE:

OWN
	been_called : initial(false),		! Set to true if CRCTABLE has been called
	table : vector[16];

!
! EXTERNAL REFERENCES:
!

external routine
	bug;			! Report a problem 

%if %bliss(bliss32)
%then
    external routine
	lib$crc_table : addressing_mode(general); ! Initialize polynomial table
%fi
GLOBAL ROUTINE crctable : NOVALUE =
!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine initializes the polynomial table 
!	for further use by the CRC calculations. It must be called
! 	at least once before an attempt is made to use CRCCALC.
! 	Provisions are made to insure the code is only executed once.
! 	The table is calculated using the run-time routine LIB$CRC_TABLE.
!  	For TOPS-20 this routine is a NOP.
!
! FORMAL PARAMETERS:
!
!	None
!
! IMPLICIT INPUTS:
!
!	The table to be built ( declared OWN in this module ).
!
! IMPLICIT OUTPUTS:
!
!	The CRC table is built
!
! ROUTINE VALUE and
! COMPLETION CODES:
!
!	None
!
! SIDE EFFECTS:
!
!	The OWN flag BEEN_CALLED is set at first execution, so the code is not
!	unneccessarily re-executed.
!
!--

    BEGIN

%if %bliss(bliss32) 
%then

    own
	poly : initial(%x'edb88320');


    !set up CRC table and set flag
    if not .been_called 
    then
	begin
    	lib$crc_table(poly,table);
	been_called = true;
	end;
%fi


%if %bliss(bliss36)
%then
    if not .been_called 
    then
	been_called = true;
%fi


    END;			! Routine CRCTABLE
GLOBAL ROUTINE CRCCALC ( len, ptr ) =
!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine calculates the CRC of a given string.
!	For TOPS-20 the length of the string isr returned
!
! FORMAL PARAMETERS:
!
!	len - length of string
!	ptr - pointer to string
!
! IMPLICIT INPUTS:
!
!	The table built by CRCTABLE. Do not attempt to call this routine
! 	unless CRCTABLE has been called at least once.
!
! IMPLICIT OUTPUTS:
!
!	None
!
! ROUTINE VALUE and
! COMPLETION CODES:
!
!	The calculated CRC is returned.
!
! SIDE EFFECTS:
!
!	None
!
!--


BEGIN			!Routine CRCCALC

%if %bliss(bliss32)
%then
local
    crcinit ,	! Initial value of CRC
    crcval;	! Calculated CRC

! Make sure the table has been initialized
 
if not .been_called
then
    bug(lit('CRCCALC called before table initialized in CRCTABLE'));

! Initialize
crcval = 0;
crcinit = -1;


!calculate and return CRC
crc(table,crcinit,len,.ptr,crcval);

.crcval
%fi
%if %bliss(bliss36)
%then
.len
%fi

END;			!Routine CRCCALC

END
ELUDOM