$TITLE ('UDI OVERLAY SYSTEM CALL')
$LARGE NOWARN
/*************************************************************************/
/*                                                                       */
/*               D I S C L A I M E R   N O T I C E                       */
/*               -------------------   -----------                       */
/*                                                                       */
/*  This document and/or portions of the material and data furnished     */
/*  herewith, was developed under sponsorship of the U. S. Government.   */
/*  Neither the U.S. nor the U.S.D.O.E., nor the Leland Stanford Junior  */
/*  University, nor their employees, nor their respective contractors,   */
/*  subcontractors, or their employees, makes any warranty, express or   */
/*  implied, or assumes any liability or responsibility for accuracy,    */
/*  completeness or usefulness of any information, apparatus, product    */
/*  or process disclosed, or represents that its use will not infringe   */
/*  privately-owned rights.  Mention of any product, its manufacturer,   */
/*  or suppliers shall not, nor is it intended to, imply approval, dis-  */
/*  approval, or fitness for any particular use.  The U. S. and the      */
/*  University at all times retain the right to use and disseminate same */
/*  for any purpose whatsoever.  Such distribution shall be made by the  */
/*  National Energy Software Center at the Argonne National Laboratory   */
/*  and only subject to the distributee furnishing satisfactory proof    */
/*  that he has a valid license from the Intel Corporation in effect.    */
/*                                                                       */
/*************************************************************************/
 
DQ_OVERLAY: do;
 
/*------------------------------------------------------*/
/*							*/
/*   The function of DQ$OVERLAY in the VMS environment  */
/*   is to copy the local data for the specified        */
/*   'overlay' down into the common data overlay area   */
/*   which has been reserved in the 64K DGROUP address  */
/*   space.                                             */
/*							*/
/*------------------------------------------------------*/
 
$INCLUDE (PLM$UDI:EXCEPT.LIT)
 
declare D% byte external,       /* First byte of overlay data area */
	E% byte external;	/* Last byte +1 */
 
declare %overlay(1) structure(  /* Supplied by application system */
		name(16) byte,  /* Overlay name (string) */
		start pointer,	/* Address of first local data byte */
                stop pointer)   /* Address of last byte +1 */
		external;
 
DQ$OVERLAY: procedure (name$p,excep$p) public;
        declare (name$p,excep$p) pointer;
	declare (name based name$p) (1) byte;
	declare (status based excep$p) word;
        declare i integer;
 
        if name(0) > last(%overlay.name) then
	    do;
            status=E$SYNTAX;    /* Overlay name too long. */
	    return;
	    end;
 
	i=0;
 
        do while %overlay(i).name(0) <> 0;
            if CMPB(%_pointer(name$p),@%overlay(i).name,
                      %overlay(i).name(0)+1) = 0FFFFH then
		do;
                if %overlay(i).stop-%overlay(i).start > @E%-@D% then
		    do;
                    status=E$ADDRESS;   /* Overlay data area too small. */
		    return;
		    end;
		call MOVE(%overlay(i).stop-%overlay(i).start,
				%overlay(i).start,@D%);
		status=E$OK;
		return;
		end;
	    i=i+1;
	end;
 
        status=E$EXIST;         /* Overlay name not in table. */
	return;
 
	end DQ$OVERLAY;
 
end DQ_OVERLAY;
