perm filename LOGIC.SAI[3,PMP] blob sn#008092 filedate 1972-05-28 generic text, type T, neo UTF8
00100	BEGIN
00150	STRING ARRAY NAM[1:30];
00200	INTEGER NV,I,J,K,T,BRK,BK1;
00300	STRING OSF1,OSF,S1,S2;
00400	
00500	T←0;
00600	OPEN (1,"TTY",1,1,0,55,BRK,T);
00700	OPEN (2,"DSK",1,0,2,T,T,T);
00800	ENTER (2,"LOG.SAI",T);
00810	LOOKUP (1,"TTY",T);
00820	SETBREAK (1,",; ()"&10,13,"ISN");
00860	SETBREAK (2,",; ()"&13&10,"","ISN");
00900	OUTSTR("# OF VARS=");
01000	NV←CVD(INPUT(1,1));
01100	IF NV>20 THEN OUTSTR("THAT'S TOO MANY"&13&10);
01200	FOR I←1 STEP 1 UNTIL NV DO
01300	    BEGIN
01400		OUTSTR ("NAME OF V"&CVS(I)&"=");
01500		NAM[I]←INPUT(1,1);
01600	    END;
01700	OUTSTR ("TYPE FUNCTION. END WITH ;"&13&10);
01800	OSF←NULL;
01850	OSF1←NULL;
01900	BRK←0;
02000	WHILE BRK≠";" DO
02100	    BEGIN
02200		BK1←BRK;
02300		S2←S1←INPUT(1,2);
02400		IF BK1="(" OR BK1="," THEN
02500		    BEGIN
02600			J←0;
02700			FOR I←1 STEP 1 UNTIL NV DO
02800			IF EQU(NAM[I],S1) THEN
02900			 J←I;
02950			IF EQU("0",S1) ∨ EQU("1",S1) ∨ EQU(S1,"INV")
02962			 ∨EQU("NAND4",S1)∨EQU("NAND8",S1)∨EQU(S1,"AOI")
02968			 ∨EQU("ANDD",S1) THEN J←3
02975			 ELSE
02987			    BEGIN
03000				 IF J=0 THEN OUTSTR("I DON'T KNOW "&S1&13&10);
03100				S1←"I["&CVS(J)&"]";
03150			    END;
03200		    END;
03300		OSF←OSF&S1&BRK;
03350		OSF1←OSF1&S2&BRK;
03400	    END;
03500	OUT(2,"BEGIN INTEGER T,K,J;
03550	INTEGER ARRAY I[1:"&CVS(NV)&"];
03600	INTEGER PROCEDURE NAND4(INTEGER A,B,C,D);
03800		IF A=1 ∧ B=1 ∧ C=1 ∧ D=1 THEN RETURN(0)ELSE RETURN(1);
03900	INTEGER PROCEDURE NAND8(INTEGER A,B,C,D,E,F,G,H);
04000		IF A=1 ∧ B=1 ∧ C=1 ∧ D=1 ∧ E=1
04100			∧ F=1 ∧ G=1 ∧ H=1 THEN RETURN(0)ELSE RETURN(1);
04200	INTEGER PROCEDURE AOI(INTEGER I1,I2,I3,I4,J1,J2,J3,K1,K2,L1,L2);
04300		IF (I1=1 ∧ I2=1 ∧ I3=1 ∧ I4=1)
04400		  ∨ (J1=1 ∧ J2=1 ∧ J3=1)
04500		  ∨ (K1=1 ∧ K2=1)
04600		  ∨ (L1=1 ∧ L2=1) THEN RETURN(0)ELSE RETURN(1);
04700	INTEGER PROCEDURE INV(INTEGER A);
04800		IF A=1 THEN RETURN(0)ELSE RETURN(1);
04900	INTEGER PROCEDURE ANDD (INTEGER A,B,C);
05000		IF A=1 ∧ B=1 ∧ C=1 THEN RETURN(1)ELSE RETURN (0);
05100	");
05300	OUT(2,"OPEN (1,""LPT"",1,0,1,T,T,T);
05350	OUT(1,"""&OSF1&"""&13&10&10);
05400	OUT(1,""");
05500	FOR I←1 STEP 1 UNTIL NV DO OUT(2,NAM[I]&9);
05600	OUT(2,"RESULT""&13&10&10);
05700	");
05800	FOR I←1 STEP 1 UNTIL NV DO
05900	OUT(2,"FOR I["&CVS(I)&"]←0 STEP 1 UNTIL 1 DO
06000	");
06100	OUT(2,"BEGIN
06200	J←"&OSF&"
06300	FOR K←1 STEP 1 UNTIL "&CVS(NV)&" DO
06400	  OUT(1,CVS(I[K])&9);
06500	OUT(1,CVS(J)&13&10);
06600	END;
06700	RELEASE(1);
06800	END;END;END;END;");
06900	RELEASE (1);RELEASE(2);
07000	END;END;END;
07100	END;