Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-04 - 43,50325/io.bli
There are no other files named io.bli in the archive.
00100	MODULE IO(ENTRIES=(LOOKUP,ENTER,OPENIN,OPENOUT,CLOSEIN,
00150			GETINCH, GETOUTCH,
00200			CLOSEOUT,PURGEOUT,OUTMSG,READ,WRITE),TIMER)=
00300	BEGIN
00400	%%
00500	%
00600	             THIS  MODULE PROVIDES SOME I/O EXAMPLES USING BLISS. FOR
00700	        THIS SET  OF  EXAMPLES,  WE  WILL  ASSUME  A  STATIC  CHANNEL
00800	        ASSIGNMENT.    ALL  INPUT  WILL BE ON CHANNEL "INCH", AND ALL
00900	        OUTPUT ON CHANNEL "OUTCH".    THE  THREE-WORD  BUFFER  HEADER
01000	        AREAS  WILL BE "IBUFH" AND "OBUFH" AND ARE DECLARED GLOBAL IN
01100	        SOME OTHER MODULE.
01200	%
01300	%%
01400	
01500	BIND
01600		INCH=1,
01700		OUTCH=2;
01800	
01900	%%
02000	%
02100		HERE ARE SOME USEFUL MACHINE OPERATIONS
02200	%
02300	%%
02400	
02500	MACHOP
02600		CALLI=#047,
02700		OPEN=#050,
02800		TTCALL=#051,
02900		IN=#056,
03000		OUT=#057,
03100		GETSTS=#062,
03200		STATZ=#063,
03300		CLOSEUUO=#070,
03400		RELEAS=#071,
03500		LOOKUPUUO=#076,
03600		ENTERUUO=#077,
03700		XCT=#256;
03800	
03900	%%
04000	%
04100	             THE  FOLLOWING  MACRO  RETURNS "TRUE" IF THE INSTRUCTION
04200	        GIVEN AS ITS PARAMETER SKIPS, AND  FALSE  IF  IT DOES NOT.
04300	        PARAMETER GIVEN.
04400	%
04500	%%
04600	
04700	MACRO
04800		SKIP(OP)=BEGIN
04900				VREG_1; OP; VREG_0; .VREG
05000			 END$;
05100	
05200	%%
05300	%
05400		HERE ARE SOME USEFUL MACROS
05500	%
05600	%%
05700	
05800	MACRO
05900		RESET=CALLI(0)$,
06000	
06100		COUNT(BUFH)=BUFH[2]$,
06200		PTR(BUFH)=BUFH[1]$;
06300	
06400	%%
06500	%
06600	             IBUFH AND OBUFH  MUST  BE  DECLARED  GLOBAL  IN  ANOTHER
06700	        MODULE
06800	%
06900	%%
07000	
07100	EXTERNAL
07200		IBUFH[3],
07300		OBUFH[3];
     
00100	%%
00200	%
00300	             "OPENIN" AND  "OPENOUT"  TAKE  THREE  PARAMETERS:    THE
00400	        DEVICE STATUS (INCLUDING DATA MODE), THE LOGICAL DEVICE NAME,
00500	        AND THE BUFFER POINTERS, PRECISELY AS SPECIFIED FOR THE  OPEN
00600	        UUO.  THESE  ROUTINES  RETURN  "TRUE"  IF THEY SUCCEEDED, AND
00700	        "FALSE" IF THEY FAILED.
00800	%
00900	%%
01000	
01100	GLOBAL ROUTINE OPENIN(STATUS,LDEV,BUF)=(SKIP(OPEN(INCH,STATUS)));
01200	
01300	GLOBAL ROUTINE OPENOUT(STATUS,LDEV,BUF)=(SKIP(OPEN(OUTCH,STATUS)));
01400	
     
00100	%%
00200	%
00300	        "GETINCH" AND "GETOUTCH" RETURN THE CHANNEL  NUMBERS
00400	        OF  THE  INPUT  AND OUTPUT CHANNELS.  THIS IS SO THE
00500	        USER CAN IMPLEMENT OTHER UUO'S INDEPENDENT  OF  WHAT
00600	        THE CHANNEL ASSIGNMENTS ARE HERE.
00700	%
00800	%%
00900	
01000	GLOBAL ROUTINE GETINCH=INCH;
01100	
01200	GLOBAL ROUTINE GETOUTCH=OUTCH;
01300	
     
00100	%%
00200	%
00300	             THE PARAMETER PASSED TO LOOKUP  OR  ENTER  MUST  BE  THE
00400	        ADDRESS  OF  A  FOUR-WORD  CONTROL BLOCK, AS SPECIFIED IN THE
00500	        MANUAL.   THE CONTENTS OF THIS CONTROL BLOCK WILL BE  ALTERED
00600	        BY  THE  UUO,  AND CONSEQUENTLY MUST NOT RESIDE IN THE HISEG.
00700	        THESE ROUTINES RETURN "TRUE" IF THEY SUCCEED AND  "FALSE"  IF
00800	        THEY FAIL.
00900	%
01000	%%
01100	
01200	GLOBAL ROUTINE LOOKUP(LOOKUPBLOCK)=SKIP(LOOKUPUUO(INCH,LOOKUPBLOCK,0,1));
01300	GLOBAL ROUTINE ENTER(ENTERBLOCK)=SKIP(ENTERUUO(OUTCH,ENTERBLOCK,0,1));
     
00100	%%
00200	%
00300	             THE ROUTINE "READ" RETURNS ONE OF THE FOLLOWING  VALUES:
00400	        -1  IF  END-OF-FILE; -2 IF OTHER I/O ERROR; A POSITIVE NUMBER
00500	        IS THE CHARACTER RETURNED.
00600	%
00700	%%
00800	
00900	GLOBAL ROUTINE READ=
01000	    BEGIN
01100		IF (COUNT(IBUFH)_.COUNT(IBUFH)-1) LEQ 0 
01200		  THEN
01300		    BEGIN
01400			IF SKIP(IN(INCH)) 
01500			   THEN
01600				(IF SKIP (STATZ(INCH,#740000))
01700					THEN
01800						-1
01900					ELSE
02000						-2)
02100			    ELSE
02200				SCANI(PTR(IBUFH))
02300		    END
02400		  ELSE
02500			SCANI(PTR(IBUFH))
02600	    END;
     
00100	%%
00200	%
00300	             THE  ROUTINE  "WRITE"  RETURNS "TRUE" IF IT SUCCESSFULLY
00400	        WROTE OUT THE CHARACTER GIVEN AND "FALSE" IF IT DID NOT.
00500	%
00600	%%
00700	GLOBAL ROUTINE WRITE(CHAR)=
00800	    BEGIN
00900		IF (COUNT(OBUFH)_.COUNT(OBUFH)-1) LEQ 0
01000		  THEN
01100			BEGIN
01200				IF SKIP(OUT(OUTCH)) THEN RETURN 0
01300			END;
01400		REPLACEI(PTR(OBUFH),.CHAR);
01500		1
01600	    END;
01700	
01800	GLOBAL ROUTINE PURGEOUT=
01900	BEGIN
02000		IF SKIP(OUT(OUTCH)) THEN 0 ELSE 1
02100	END;
     
00100	%%
00200	%
00300	             THE  FOLLOWING  ROUTINES  CLOSE THE CHANNELS AND RELEASE
00400	        THE DEVICES.  THEIR VALUE IS UNDEFINED.
00500	%
00600	%%
00700	
00800	GLOBAL ROUTINE CLOSEIN=(CLOSEUUO(INCH); RELEAS(INCH));
00900	
01000	GLOBAL ROUTINE CLOSEOUT=(CLOSEUUO(OUTCH); RELEAS(OUTCH));
01100	
     
00100	%%
00200	%
00300	             THIS  ROUTINE  IS  USEFUL FOR OUTPUTTING MESSAGES TO THE
00400	        TELETYPE. IT TAKES ONE PARAMETER, THE  POINTER  TO  AN  ASCIZ
00500	        STRING (E.G., PLIT ASCIZ 'TEXT...').  ITS VALUE IS UNDEFINED.
00600	%
00700	%%
00800	GLOBAL ROUTINE OUTMSG(TEXT)=
00900		TTCALL(3,TEXT,,1);
01000	END ELUDOM;