Google
 

Trailing-Edge - PDP-10 Archives - BB-JR93K-BB_1990 - 10,7/decmai/mx/mxntlb.r36
There are 13 other files named mxntlb.r36 in the archive. Click here to see a list.
!	COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1985, 1989.
!	ALL RIGHTS RESERVED.
!
!	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 THAT IS NOT SUPPLIED BY DIGITAL.
!++
! Facility: LSG DECnet Network Management
!
! Abstract:
!
!	This file contains macros that facilitate handling
!	of 8 bit bytes protocol messages.
!
! Environment:	BLISS-36, BLISS-32, and BLISS-16.
!
! Author(s): Steven M. Jenness, Dale C. Gunn
!
! Creation date: 23-Oct-80
!
!--
! DECnet message processing macros
!
!	N.B - These macros are here for convenience at this time only
!             and are specific to BLISS-36. 
!
!             THEY ARE NOT TRANSPORTABLE! In time they will have to 
!             be moved to a machine specific library.
%sbttl 'Write Macros'

! Macro - PUTB
!
! Function - To write a 8 bit value to the next position in
!            a DECnet byte string.  The pointer to the byte
!            string is updated to point to the next free position.
!
! Parameters -
!
!    VALUE      8 Bit value to write
!    POINTER    Address of byte string pointer


macro
     PUTB (VALUE, POINTER) =
         ch$wchar_a (VALUE, POINTER) %;


! Macro - PUTW
!
! Function - To write a 16 bit value as the next two bytes in
!            a DECnet byte string.  The pointer to the byte
!            string is updated to point to the next free position.
!
! Parameters -
!
!    VALUE      Address of 16 bit value to write
!    POINTER    Address of byte string pointer


macro
     PUTW (VALUE, POINTER) = 
         begin
         ch$wchar_a (.VALUE<0,8,0>, POINTER);
         ch$wchar_a (.VALUE<8,8,0>, POINTER);
         end %;


! Macro - EX_PUTW
!
! Function - To write the given value to a byte string.  The
!            value is written as the smallest number of bytes
!            possible (1 byte for 8 bits, 2 bytes for 16 bits).
!
! Parameters -
!
!    VALUE       Value to write (8 or 16 bits)
!    POINTER     Address of byte string pointer


macro
     EX_PUTW (VALUE, POINTER) =
         if VALUE gtr 128
         then begin
              local $$EX_PUTW_X;

              $$EX_PUTW_X = VALUE;
              ch$wchar_a (.$$EX_PUTW_X<0,7>+128, POINTER);
              ch$wchar_a (.$$EX_PUTW_X<7,7>, POINTER);
              end
         else ch$wchar_a (VALUE, POINTER); %;
%sbttl 'Read Macros'

! Macro - GETB
!
! Function - To get the next 8 bit value from a byte string.
!            The byte pointer is updated to point to the next
!	     byte to read.
!
! Parameters -
!
!    POINTER	Address of byte string pointer
!
! Value returned -
!
!    The next byte in the string.


macro
     GETB (POINTER) =
         begin
         ch$rchar_a (POINTER)
         end %;


! Macro - GETW
!
! Function - To get the next two bytes in a byte string and make
!	     a 16 bit value from them.   The byte pointer is updated
!	     to point to the next byte in the string.
!
! Parameters -
!
!    POINTER    Address of byte string pointer
!
! Value returned -
!
!    The value constructed from the next two bytes in the string.
!    The first byte is the lower order 8 bits and the second byte
!    is the high order 8 bits.


%if $MCB %then
macro
     GETW (POINTER) =
         begin
         stacklocal $$GETB_X;

         $$GETB_X<0,8,0> = ch$rchar_a (POINTER);
         $$GETB_X<8,8,0> = ch$rchar_a (POINTER);
         .$$GETB_X<0,16,0>
         end %;
%fi

%if not $MCB %then
macro
     GETW (POINTER) =
         begin
	 register T1;	!\  Use two statements to avoid use of commas,
	 register T2;	!/   cause this macro gets used in other macros

         T1 = ch$rchar_a (POINTER);
         T2 = ch$rchar_a (POINTER);
	 .T2 ^ 8 or .T1
         end %;
%fi

! Macro - GETW_NA
!
! Function - To get the next two bytes in a byte string and make
!	     a 16 bit value from them.   The byte pointer is not
!            updated.
!
! Parameters -
!
!    POINTER	Byte string pointer
!
! Value returned -
!
!    The value constructed from the next two bytes in the string.
!    The first byte is the lower order 8 bits and the second byte
!    is the high order 8 bits.

macro
     GETW_NA (POINTER) =
         begin
         %if $MCB
         %then stacklocal
         %else local %fi $$GETW_NA_X;

         $$GETW_NA_X<0,8,0> = ch$rchar (POINTER);
         $$GETW_NA_X<8,8,0> = ch$rchar (ch$plus (POINTER,1));
         .$$GETW_NA_X<0,16,0> 
         end %;


! Macro - GETN
!
! Function - To get then next "N" bytes and construct a value
!	     from them.   The bytes read are in ascending
!	     significance (i.e. lowest order byte is the first
!	     byte read).
!
! Parameters -
!
!    POINTER	Address of byte string pointer
!    COUNT	Number of bytes to read
!
! Value returned -
!
!    The value constructed from the sequence of bytes read.
!

macro
     GETN (POINTER, COUNT) =
         begin
         local $$GETN_X;

         $$GETN_X = ch$rchar_a (POINTER);
         incr $$GETN_P from 8 to ((COUNT-1)*8) by 8
         do $$GETN_X = .$$GETN_X + ch$rchar_a (POINTER)^.$$GETN_P;
         .$$GETN_X
         end %;
%sbttl 'String Length Checking Macros'

! Macro - NEXTB
!
! Function - This macro checks a string length to see if it
!            is long enough to contain a byte field.  If it does
!            it increments the string count past the next byte.
!
! Parameters -
!
!    MAXIMUM    Maximum number of bytes in the string
!    COUNT      Number of bytes already used in the string
!
! Returns -
!
!    $true   String contains one more byte
!    $false  End of string reached
!
! Side effects -
!
!    The value in COUNT is updated to point beyond the next byte.


macro
     NEXTB (MAXIMUM, COUNT) =
         begin
         local $$NEXTB_TEMP;

         if MAXIMUM geq ($$NEXTB_TEMP = .COUNT + 1)
         then begin
              COUNT = .$$NEXTB_TEMP;
              (1 eql 1)
              end
         else (1 eql 0)
         end %;


! Macro - NEXTW
!
! Function - This macro checks a string length to see if it
!            is long enough to contain a word (2 byte) field.
!            If it does it increments the string count past
!            the next word.
!
! Parameters -
!
!    MAXIMUM    Maximum number of bytes in the string
!    COUNT      Number of bytes already used in the string
!
! Returns -
!
!    $true   String contains one more word
!    $false  End of string reached
!
! Side effects -
!
!    The value in COUNT is updated to point beyond the next word.


macro
     NEXTW (MAXIMUM, COUNT) =
         begin
         local $$NEXTW_TEMP;

         if MAXIMUM geq ($$NEXTW_TEMP = .COUNT + 2)
         then begin
              COUNT = .$$NEXTW_TEMP;
              (1 eql 1)
              end
         else (1 eql 0)
         end %;


! Macro - NEXTN
!
! Function - This macro checks a string length to see if it
!            is long enough to contain a field of COUNT bytes.
!            If it does it increments the string count past
!            COUNT bytes.
!
! Parameters -
!
!    MAXIMUM    Maximum number of bytes in the string
!    USED       Number of bytes already used in the string
!    COUNT      Number of bytes in field
!
! Returns -
!
!    $true   String contains COUNT bytes
!    $false  End of string reached
!
! Side effects -
!
!    The value in USED is updated to point beyond COUNT bytes.


macro
     NEXTN (MAXIMUM, USED, COUNT) =
         begin
         local $$NEXTN_TEMP;

         if MAXIMUM geq ($$NEXTN_TEMP = .USED + COUNT)
         then begin
              USED = .$$NEXTN_TEMP;
              (1 eql 1)
              end
         else (1 eql 0)
         end %;


! Macro - NEXTF
!
! Function - This macro checks a string length to see if it
!            is long enough to contain a counted field.
!            If it does it sets the count past the end of
!            of the field.
!
! Parameters -
!
!    MAXIMUM    Maximum number of bytes in the string
!    COUNT      Number of bytes already used in the string
!    POINTER    Pointer into string being checked
!
! Returns -
!
!    $true   String contains a counted field
!    $false  End of string reached
!
! Side effects -
!
!    The value in COUNT is updated to point beyond the
!    counted field.
!

macro
     NEXTF (MAXIMUM, COUNT, POINTER) =
         begin
         local $$NEXTF_TEMP;

         if MAXIMUM geq ($$NEXTF_TEMP = .COUNT + 1)
         then begin
              COUNT = .$$NEXTF_TEMP + ch$rchar (POINTER);
              (1 eql 1)
              end
         else (1 eql 0)
         end %;
%sbttl '32 Bit Data Manipulation Macros'

! Macro - PUT32
!
! Function - This macro writes a 32 bit value as four bytes
!            (LSB first) to a output string.
!
! Parameters -
!
!    VALUE      Address of 32 bit value
!    POINTER    Address of output byte pointer


macro
     PUT32 (VALUE, POINTER) =
         begin
         bind $$PUT32_VALUE = VALUE : THIRTY_TWO_BIT;

         PUTB (.$$PUT32_VALUE[$32BYTE1], POINTER);
         PUTB (.$$PUT32_VALUE[$32BYTE2], POINTER);
         PUTB (.$$PUT32_VALUE[$32BYTE3], POINTER);
         PUTB (.$$PUT32_VALUE[$32BYTE4], POINTER);
         end %;


! Macro - GET32
!
! Function - This macro reads a 32 bit value as four bytes
!            (LSB first) from a input string.
!
! Parameters -
!
!    POINTER    Address of input byte pointer
!    VALUE      Address of 32 bit value


macro
     GET32 (POINTER, VALUE) =
         begin
         bind $$GET32_VALUE = VALUE : THIRTY_TWO_BIT;

         %if $TOPS10 or $TOPS20
         %then $$GET32_VALUE = 0;
         %fi

         $$GET32_VALUE[$32BYTE1] = GETB (POINTER);
         $$GET32_VALUE[$32BYTE2] = GETB (POINTER);
         $$GET32_VALUE[$32BYTE3] = GETB (POINTER);
         $$GET32_VALUE[$32BYTE4] = GETB (POINTER);
         end %;


! Macro - %MOV32
!
! Function - This macro moves a 32 bit value from one 32 bit
!            storage area to another.
!
! Parameters -
!
!    SOURCE     Address of 32 bit value to move FROM
!    TARGET     Address of 32 bit value to move TO


macro
     %MOV32 (SOURCE, TARGET) =
         begin
         %if not $MCB
         %then TARGET = (.SOURCE)<0,32,1>;
         %else bind $$MOV32_TARGET = TARGET : THIRTY_TWO_BIT,
                    $$MOV32_SOURCE = SOURCE : THIRTY_TWO_BIT;

               $$MOV32_TARGET[$32WORD1] = .$$MOV32_SOURCE[$32WORD1];
               $$MOV32_TARGET[$32WORD2] = .$$MOV32_SOURCE[$32WORD2];
         %fi
         end %;


! Macro - %MOVT32
!
! Function - This macro moves a fullword value in a BLISS variable
!            to a 32 bit value storage area.
!            The source value is restricted to the machine word
!            size.
!
! Parameters -
!
!    SOURCE     Address of fullword value to move FROM
!    TARGET     Address of 32 bit value to move TO


macro
     %MOVT32 (SOURCE, TARGET) =
         begin
         %if not $MCB
         %then TARGET = .SOURCE;
         %else bind $$MOVT32_TARGET = TARGET : THIRTY_TWO_BIT;

               $$MOVT32_TARGET[$32WORD1] = .SOURCE;
               $$MOVT32_TARGET[$32WORD2] = 0;
         %fi
         end %;


! Macro - %MOVF32
!
! Function - This macro moves a 32 bit value from a 32 bit storage
!            area to a BLISS variable as a fullword value.
!            The destination value is truncated to the machine word
!            size.
!
! Parameters -
!
!    SOURCE     Address of 32 bit value to move FROM
!    TARGET     Address of fullword value to move TO


macro
     %MOVF32 (SOURCE, TARGET) =
         begin
         %if not $MCB
         %then TARGET = (.SOURCE)<0,32>;
         %else bind $$MOVF32_SOURCE = SOURCE : THIRTY_TWO_BIT;

               TARGET = .$$MOVF32_SOURCE[$32WORD1];
         %fi
         end %;


! Macro - %MOVI32
!
! Function - This macro moves an immediate BLISS fullword value
!            to a 32 bit value storage area.
!
! Parameters -
!
!    VALUE      Fullword value to move FROM
!    TARGET     Address of 32 bit value to move TO


macro
     %MOVI32 (VALUE, TARGET) =
         begin
         %if not $MCB
         %then TARGET = VALUE;
         %else bind $$MOVI32_TARGET = TARGET : THIRTY_TWO_BIT;

               $$MOVI32_TARGET[$32WORD1] = VALUE;
               $$MOVI32_TARGET[$32WORD2] = 0;
         %fi
         end %;


! Macro - %ADD32
!
! Function - This macro adds one 32 bit value to another
!            (VALUE1 + VALUE2) and stores the result in the
!            second value.
!
! Parameters -
!
!    VALUE1     Address of first 32 bit value
!    VALUE2     Address of second 32 bit value


macro
     %ADD32 (VALUE1, VALUE2) =
         begin
         %if not $MCB
         %then VALUE2 = (.VALUE2)<0,32> + (.VALUE1)<0,32>;
         %else linkage $$ADD32 = jsr (register = 0, register = 1);
               external routine $ADD32 : $$ADD32 novalue;

               $ADD32 (VALUE1, VALUE2);
         %fi
         end %;


! Macro - %CMP32
!
! Function - This macro compares two 32 bit values using
!            the specified boolean operation.
!
! Parameters -
!
!    VALUE1     Address of first 32 bit value
!    BOOLEAN    Bliss boolean mnemonic
!    VALUE2     Address of second 32 bit value


macro
     %CMP32 (VALUE1, BOOLEAN, VALUE2) =
         begin
         %if not $MCB
         %then (.VALUE1)<0,32> BOOLEAN (.VALUE2)<0,32>
         %else stacklocal $$CMP32_CV : THIRTY_TWO_BIT;
               bind $$CMP32_C = $$CMP32_CV;

               %MOV32 (VALUE1, $$CMP32_C);
               %SUB32 (VALUE2, $$CMP32_C);
               %SGN32 ($$CMP32_C) BOOLEAN 0
         %fi
         end %;


! Macro - %SUB32
!
! Function - This macro subtracts one 32 bit value from another
!            (VALUE2 - VALUE1) and stores the result in the
!            second value.
!
! Parameters -
!
!    VALUE1   Address of first 32 bit value
!    VALUE2   Address of second 32 bit value


macro
     %SUB32 (VALUE1, VALUE2) =
         begin
         %if not $MCB
         %then VALUE2 = (.VALUE2)<0,32> - (.VALUE1)<0,32>;
         %else linkage $$SUB32 = jsr (register = 0, register = 1);
               external routine $SUB32 : $$SUB32 novalue;

               $SUB32 (VALUE1, VALUE2);
         %fi
         end %;


! Macro - %CMPI32
!
! Function - This macro compares a 32 bit value against a
!            fullword value using the specified boolean operation.
!
! Parameters -
!
!    VALUE      Address of 32 bit value
!    BOOLEAN    Bliss boolean mnemonic
!    FULLWORD   Fullword value


macro
     %CMPI32 (VALUE, BOOLEAN, FULLWORD) =
         begin
         %if not $MCB
         %then (.VALUE)<0,32> BOOLEAN FULLWORD
         %else stacklocal $$CMPI32_CV : THIRTY_TWO_BIT;
               bind $$CMPI32_C = $$CMPI32_CV;

               %MOVI32 (FULLWORD, $$CMPI32_C);
               %SUB32 (VALUE, $$CMPI32_C);
               0 BOOLEAN %SGN32 ($$CMPI32_C)
         %fi
         end %;


! Macro - %SUBI32
!
! Function - This macro subtracts a fullword value from a
!            32 bit value (32bit - fullword) and stores the
!            result in the 32 bit location.
!
! Parameters -
!
!    FULLWORD   Fullword value
!    VALUE      Address of 32 bit value


macro
     %SUBI32 (FULLWORD, VALUE) =
         begin
         %if not $MCB
         %then VALUE = (.VALUE)<0,32> - FULLWORD;
         %else local $$SUBI32_C : THIRTY_TWO_BIT;

               %MOVI32 (FULLWORD, $$SUBI32_C);
               %SUB32 ($$SUBI32_C, VALUE);
         %fi
         end %;


! Macro - %ADDI32
!
! Function - This macro adds a fullword value to a
!            32 bit value (32bit + fullword) and stores the
!            result in the 32 bit location.
!
! Parameters -
!
!    FULLWORD   Fullword value
!    VALUE      Address of 32 bit value


macro
     %ADDI32 (FULLWORD, VALUE) =
         begin
         %if not $MCB
         %then VALUE = (.VALUE)<0,32> + FULLWORD;
         %else local $$ADDI32_C : THIRTY_TWO_BIT;

               %MOVI32 (FULLWORD, $$ADDI32_C);
               %ADD32 ($$ADDI32_C, VALUE);
         %fi
         end %;


! Macro - %SGN32
!
! Function - This macro returns the sign of the given 32 bit value
!
! Parameters -
!
!    VALUE      Address of 32 bit value


macro
     %SGN32 (VALUE) =
         begin
         %if not $MCB
         %then SIGN (.VALUE<0,32,1>)
         %else linkage $$SGN32 = jsr (register = 1);
               external routine $SGN32 : $$SGN32;

               $SGN32 (VALUE)
         %fi
         end %;


! Macro - %ASLI32
!
! Function - This macro shifts a 32 bit value (32bit + fullword) left by
!            number of bits specified by the immediate value.
!
! Parameters -
!
!    POSITION  Positive value to shift
!    VALUE     Address of 32 bit value


macro
     %ASLI32 (POSITION, VALUE) =
         begin
         %if not $MCB
         %then VALUE = .VALUE ^ POSITION;
         %else bind $$ASLI32_VALUE = VALUE : THIRTY_TWO_BIT;

               decru $$ASL_INDEX from POSITION to 1
               do begin
                  builtin ROT;

                  $$ASLI32_VALUE[$32WORD1] = ROT (.$$ASLI32_VALUE[$32WORD1], 1);
                  $$ASLI32_VALUE[$32WORD2] = ROT (.$$ASLI32_VALUE[$32WORD2], 1);
                  end;
         %fi
         end %;
%sbttl '32 Bit Structure Definition'

! Structure - THIRTY_TWO_BIT
!
! Function  - Define the storage and access to a 32 bit value.


%if not $MCB
%then field THIRTY_TWO_BIT_FIELDS =
          set
          $32BYTE1 = [0,  0, 8, 0],
          $32BYTE2 = [0,  8, 8, 0],
          $32BYTE3 = [0, 16, 8, 0],
          $32BYTE4 = [0, 24, 8, 0]
          tes;

       macro
            THIRTY_TWO_BIT = block [1] field (THIRTY_TWO_BIT_FIELDS) %;

%else field THIRTY_TWO_BIT_FIELDS =
          set
          $32BYTE1 = [0,  0,  8, 0],
          $32BYTE2 = [0,  8,  8, 0],
          $32BYTE3 = [1,  0,  8, 0],
          $32BYTE4 = [1,  8,  8, 0],
          $32WORD1 = [0,  0, 16, 0],
          $32WORD2 = [1,  0, 16, 0]
          tes;

      macro
           THIRTY_TWO_BIT = block [2] field (THIRTY_TWO_BIT_FIELDS) %;
%fi
	

! Structure - SIGNED_BYTE
!
! Function  - Define a signed 8 bit byte value.


$field SIGNED_BYTE =
    set
    VALUE = [0, 0, 8, 1]                ! Signed eight bit byte
    tes;

macro
     $SIGNED_BYTE_VALUE =
         block [1] field (SIGNED_BYTE) %;

! Structure - SIGNED_WORD
!
! Function - Define a signed 16 bit value

$field SIGNED_WORD =
       set
       $16VALUE = [0, 0, 16, 1]         ! Signed sixteen bits
       tes;

macro
     $SIGNED_WORD_VALUE =
         block [1] field (SIGNED_WORD) %;

%title ''
%sbttl ''

!
! [End of NETLIB.REQ]
! Local Modes:
! Mode:BLISS
! Auto Save Mode:2
! Comment Column:40
! Comment Rounding:+1
! End: