perm filename MUNGE.SAI[UOR,AIL] blob sn#248607 filedate 1976-11-19 generic text, type T, neo UTF8
DEFINE STANSW = "FALSE";
ENTRY AMUNGE,UNMUNGE,GMUNGE,GUNMUN;
BEGIN "MUNGE"
IFC NOT STANSW THENC
     
     BOOLEAN PROCEDURE IFGLOBAL(INTEGER X);
            RETURN(FALSE);
     DEFINE GLOBAL = "";
ENDC
   INTEGER ARSUB1,ARSUB2,ARSUB3,ARSUB4,ARSUB5;
   EXTERNAL INTEGER DATM,GDATM;
IFC STANSW THENC
   EXTERNAL INTEGER PROCEDURE IFGLOBAL(ITEMVAR X);
ENDC

   DEFINE P="'17",
	  !="COMMENT";

   INTERNAL SIMPLE INTEGER PROCEDURE AMUNGE(ITEMVAR X);
   BEGIN INTEGER RETVAL,GLBFLAG;INTERNAL LABEL AMUNG2;
	 LABEL GLBITM;
      START!CODE
	      PUSH	P,-1(P);	! THE ITEM;
	      PUSHJ	P,IFGLOBAL;	! SEE IF GLOBAL;
	      MOVE	3,-1(P);	! THE PARAM.;
	      JUMPN	1,GLBITM;	! YES, GLOBAL ITEM;
	      HRRZ	3,@DATM;	! THE ARRAY DESCRIPTOR;
	      JRST	AMUNG2;		! HAVE DESCRIPTOR;
      GLBITM: HRRZ	3,@GDATM;	! GET GLOBAL DESCRIPTOR;
      AMUNG2: SKIPG	-2(3);		! STRING ARRAY?;
	      SUBI	3,1;		! YES.;
	      HRRZ	1,-1(3);	! TOTAL SIZE OF ARRAY;
	      SKIPG	-1(3);		! STRING ARRAY?;
	      LSH	1,-1;		! YES DIVIDE SIZE BY TWO;
	      MOVEM	1,RETVAL;	! VALUE TO BE RETURNED;
	      HRROI	4,-1(3);	! LAST OF WORDS TO BE SAVED;
	      POP	4,ARSUB1;	! DIMEN ENTRY;
	      POP	4,ARSUB2;	! MULT.;
	      POP	4,ARSUB3;	! UPPER BOUND;
	      POP	4,ARSUB4;	! LOWER BOUND;
	      POP	4,ARSUB5;	! VIRT ORG OR MULT;
	      HRRZI	5,-1(3);	! VIRT ORG OF MUNGED ARRAY;
	      MOVEM	5,-5(3);	! MUNGE VIRT ORG.;
	      MOVEI	5,1;		
	      MOVEM	5,-4(3);	! LOWER BOUND IS 1;
	      MOVEM	1,-3(3);	! UPPER BOUND IS SIZE;
	      MOVEM	5,-2(3);	! MULTIPLIER IS 1;
	      SKIPG	-1(3);		! STRING ARRAY?;
	      MOVNI	5,1;		! NEGATE DIMENSION;
	      HRLM	5,-1(3);	! STORE DIMENSION= 1;
      END;
      RETURN(RETVAL);
   END;

   INTERNAL SIMPLE PROCEDURE UNMUNGE(ITEMVAR X);
   BEGIN INTERNAL LABEL UNMUN2; LABEL GLBITM;
	   START!CODE
	      PUSH	P,-1(P);
	      PUSHJ	P,IFGLOBAL;
	      MOVE	3,-1(P);
	      JUMPN	1,GLBITM;
	      HRRZ	3,@DATM;
	      JRST	UNMUN2;
    GLBITM:   HRRZ	3,@GDATM;
    UNMUN2:   SKIPG	-2(3);
	      SUBI	3,1;
	      MOVE	1,ARSUB1;
	      MOVEM	1,-1(3);
	      MOVE	1,ARSUB2;
	      MOVEM	1,-2(3);
	      MOVE	1,ARSUB3;
	      MOVEM	1,-3(3);
	      MOVE	1,ARSUB4;
	      MOVEM	1,-4(3);
	      MOVE	1,ARSUB5;
	      MOVEM	1,-5(3);
	   END;
   END;

   INTERNAL SIMPLE INTEGER PROCEDURE GMUNGE(ITEMVAR X);
   BEGIN EXTERNAL INTEGER AMUNG2;
	START!CODE
	      HRRZ 3,-1('17);
	      HRRZ 3,@GDATM;
	      JRST AMUNG2;
	END;
   END;

   INTERNAL SIMPLE PROCEDURE GUNMUN(ITEMVAR X);
   BEGIN EXTERNAL INTEGER UNMUN2;
      START!CODE
	HRRZ 3,-1('17);
	HRRZ 3,@GDATM;
        JRST UNMUN2;
      END;
   END;

END "MUNGE"