Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap2_198111 - decus/20-0038/bufio.doc
There are 2 other files named bufio.doc in the archive. Click here to see a list.
								1
	  		/***PROGRAM BUFIO.PAL, APRIL 14, 1970****
	  		/PETER LEMKIN
	  		/NATIONAL INSTITUTES OF HEALTH
	  		/BETHESDA, MD. 20014
	  		/
	  		/
	  		/
	  		/INTRODUCTION:
	  		/---------------
	  		/BUFIO.PAL IS A COLLECTION OF THREE PDP8 PAL SUBROUTINES
	  		/WHICH CAN BE USED FOR DOING ASYNCHRONOUS CHARACTER INPUT/OUTPUT.
	  		/THEY ARE ALSO USEFUL FOR DOING ANY WORD ASYNCHROUS QUEUING
	  		/IN OTHER TYPES OF PROGRAMS.
	  		/
	  		/
	  		/MINIMUM HARDWARE:
	  		/----------------
	  		/A PDP8 WITH 4K OR MORE MEMORY. THE 3 ROUTINES
	  		/ALL FIT WITHIN 1 PAGE OF MEMORY. THE QUEUE MAY RESIDE IN
	  		/A DIFFERENT FIELD THAN THE BUFIO ROUTINES.
	  		/
	  		/
	  		/
	  		/DISCUSSION:
	  		/-------------
	  		/THE QUEUE IS OF SIZE TQMAX-TQMIN. IT IS A CIRCULAR QUEUE SIMULATED
	  		/BY WRAPAROUND. THE ALGORITHM WAS TAKEN FROM KNEUTH VOL 1.
	  		/AS LONG AS THE SIZE IS NOT EXCEEDED THE QUEUE WILL BE SIMULATED 
	  		/INDEFINATELY.( BY THIS IS MEANT THAT THE AMOUNT OF DATA STORED IN
	  		/THE QUEUE MUST NOT BE GREATER THAN THE SIZE OF THE QUEUE.
	  		/THE CONVENTIONS ARE THAT DATA IS INSERTED INTO THE "FRONT" OF THE
	  		/QUEUE, AND REMOVED FROM THE "REAR" OF THE QUEUE. INITIALLY, THE 
	  		/THE EMPTY QUEUE HAS THE "FRONT" EQUAL TO THE "REAR" . THESE TWO
	  		/POINTERS ARE CALLED KFQ AND KRQ RESPECTIVELY.
	  		/
	  		/
	  		/
	  		/
	  		/USAGE:
	  		/------
	  		/1. TO CLEAR OUT THE QUEUE,
	  		/	I.E. SET FRONT=REAR:
	  		/	
	  		/	JMS INITQU /GO RESET THE QUEUE
	  		/	NORMAL RETURN /AC=0000
	  		/
	  		/2. TO INSERT A DATA WORD INTO THE REAR OF THE QUEUE:
	  		/	JMS INSRQ /DATA WORD IN THE AC
	  		/	ERROR RETURN /THE QUEUE HAS OVERFLOWED WITH THIS
	  		/		     /ATTEMPTED ADDITION. THE QUEUE WAS NOT MODIFIED.
	  		/	NORMAL RETURN /THE DATA WAS SUCCESSFULLY ADDED TO THE REAR OF
	  		/		     /THE QUEUE. THE AC=0000
	  		/
	  		/3. TO GET A DATA WORD FROM THE FRONT OF THE QUEUE:
	  		/	JMS GETFQ /GET A DATUM FROM THE QUEUE
								2
	  		/	ERROR RETURN /THE QUEUE WAS EMPTY....
	  		/	NORMAL RETURN /THE DATA IS IN THE AC...
	  		/
	  		/NORMALLY, THE QUEUE IS CLEARED BEFORE IT IS USED.
	  		/
	  		/
	  		/
	  		/
	  		/
	  		/PROGRAM DEFINITIONS:
	  		/STARTING ADDRESS IS WHEREVER YOU WANT IT.
	  		/THE QUEUE MAY BE IN ANY FIELD.
	  		/THE QUEUE SIZE =TQMAX-TQMIN
	  	0400		TQMIN=400
	  	0577		TQMAX=577  /ARBITRARY LIMITS JUST FOR EXAMPLE
	  	0177		QSIZE=TQMAX-TQMIN
	  	0000		DATFLD=00 /THE QUEUE DATA FIELD
	  	0000		INSTFD=00 /THE BUFIO INSTRUCTION FIELD.
	  		/
	  		/
	  		/
	  		/
	  		/
	  		/**************************************************************
	  		/
	  		/
	  		/
	  		/SUBROUTINE INITQU 
	  		/IS USED TO INIT THE QUEUE
	  		/RESETS THE QUEUE.
	  		/FRONT <== REAR <== TQMIN.
	  		/CALLING SEQUENCE:
	  		/	JMS INITQU
	  		/	NORMAL RETURN
	  0200	0000	INITQU,	0
	  0201	7200		CLA
	  0202	1264		TAD ITQMIN
	  0203	3266		DCA KFQ
	  0204	1266		TAD KFQ
	  0205	3265		DCA KRQ
	  0206	5600		JMP I INITQU
	  		 /
	  		/
	  		/
	  		/
	  		/
	  		/
	  		/
	  		/
	  		/
	  		/SUBROUTINE INSRQ
	  		/INSERTS A DATA WORD IN THE 
	  		/AC--> THE  REAR OF THE QUEUE.
	  		/CALLING SEQUENCE1G
	  		/    JMS INSRQ /DATA IN AC
								3
	  		/ 	ERROR RETURN /QUEUE OVERFLOW
	  		/       NORMAL RETURN /DATA ENTERED
	  		/                  /RQ POINTER ADVANCED.
	  		/
	  0207	0000	INSRQ,	 0
	  0210	3267	    DCA TQDAT /SAVE DATA
	  		/A.1 COMPUTE NEW KRQ
	  0211	1263	    TAD ITQMAX
	  0212	7041	    CIA
	  0213	1265	    TAD KRQ
	  0214	7700	    SMA CLA
	  0215	5220	    JMP .+3
	  0216	2265	    ISZ KRQ /KRQ<--KRQ+1
	  0217	5222	    JMP .+3
	  0220	1264	    TAD ITQMIN /KRQ<--TQMIN
	  0221	3265	    DCA KRQ
	  		/A.2 TEST FOR OVERFLOW
	  0222	1265	    TAD KRQ

	  0223	7041	    CIA
	  0224	1266	    TAD KFQ
	  0225	7650	    SNA CLA
	  0226	5607	    JMP I INSRQ /ERROR RETURN
	  0227	2207	    ISZ INSRQ
	  		/A.3 INSERT DATA INTO THE REAR OF THE QUEUE.
	  0230	1267	    TAD TQDAT
	  0231	6201	    CDF DATFLD
	  0232	3665	    DCA I KRQ
	  0233	6201	    CDF INSTFD
	  0234	5607	    JMP I INSRQ /RETURN
	  		/.........................................
	  		/
	  		/SUBROUTINE GETFQ
	  		/GET A DATA WORD FROM THE REAR
	  		/OF THE  QUEUE-->AC.
	  		/CALLING SEQUENCE:
	  		/    JMS GETFQ /DATA-->AC
	  		/    ERROR RETURN /QUEUE EMPTY
	  		/    NORMAL RETURN /DATA IN AC.
	  0235	0000	GETFQ,	 0
	  		/A.1 TEST IF KFQ=KRQ
	  		/IF SO QUEUE EMPTY
	  0236	7200	    CLA
	  0237	1266	    TAD KFQ
	  0240	7041	    CIA
	  0241	1265	    TAD KRQ
	  0242	7650	    SNA CLA
	  0243	5635	    JMP I GETFQ /ERROR RETURN
	  0244	2235	    ISZ GETFQ /SET UP NORMAL RETURN.
	  		/A.2 ADVANCE THE KFQ POINTER
	  0245	7200	    CLA
	  0246	1263	    TAD ITQMAX
	  0247	7041	    CIA
	  0250	1266	    TAD KFQ
	  0251	7700	    SMA CLA
								4
	  0252	5255	    JMP .+3 /YES, SET KFQ=TQMIN
	  0253	2266	    ISZ KFQ /NO, SET KFQ=KFQ+1
	  0254	5257	    JMP .+3
	  0255	1264	    TAD ITQMIN
	  0256	3266	    DCA KFQ
	  		/A.3 GET DATA FROM THE QUEUE.
	  0257	6201	    CDF DATFLD
	  0260	1666	    TAD I KFQ
	  0261	6201	    CDF INSTFD
	  0262	5635	    JMP I GETFQ /RETURN
	  		/...CONSTANTS...
	  0263	0577	ITQMAX,	 TQMAX
	  0264	0400	ITQMIN,	 TQMIN
	  0265	0400	KRQ,	 TQMIN
	  0266	0400	KFQ,	 TQMIN
	  0267	0000	TQDAT,	 0
	  		/..........................................
	  		$