Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap2_198111 - decus/20-0038/bufio.pal
There are 2 other files named bufio.pal in the archive. Click here to see a list.
/***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
/	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
	TQMIN=400
	TQMAX=577  /ARBITRARY LIMITS JUST FOR EXAMPLE
	QSIZE=TQMAX-TQMIN
	DATFLD=00 /THE QUEUE DATA FIELD
	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
INITQU,	0
	CLA
	TAD ITQMIN
	DCA KFQ
	TAD KFQ
	DCA KRQ
	JMP I INITQU
 /
/
/
/
/
/
/
/
/
/SUBROUTINE INSRQ
/INSERTS A DATA WORD IN THE 
/AC--> THE  REAR OF THE QUEUE.
/CALLING SEQUENCE1G
/    JMS INSRQ /DATA IN AC
/ 	ERROR RETURN /QUEUE OVERFLOW
/       NORMAL RETURN /DATA ENTERED
/                  /RQ POINTER ADVANCED.
/
INSRQ,	 0
    DCA TQDAT /SAVE DATA
/A.1 COMPUTE NEW KRQ
    TAD ITQMAX
    CIA
    TAD KRQ
    SMA CLA
    JMP .+3
    ISZ KRQ /KRQ<--KRQ+1
    JMP .+3
    TAD ITQMIN /KRQ<--TQMIN
    DCA KRQ
/A.2 TEST FOR OVERFLOW
    TAD KRQ





    CIA
    TAD KFQ
    SNA CLA
    JMP I INSRQ /ERROR RETURN
    ISZ INSRQ
/A.3 INSERT DATA INTO THE REAR OF THE QUEUE.
    TAD TQDAT
    CDF DATFLD
    DCA I KRQ
    CDF INSTFD
    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.
GETFQ,	 0
/A.1 TEST IF KFQ=KRQ
/IF SO QUEUE EMPTY
    CLA
    TAD KFQ
    CIA
    TAD KRQ
    SNA CLA
    JMP I GETFQ /ERROR RETURN
    ISZ GETFQ /SET UP NORMAL RETURN.
/A.2 ADVANCE THE KFQ POINTER
    CLA
    TAD ITQMAX
    CIA
    TAD KFQ
    SMA CLA
    JMP .+3 /YES, SET KFQ=TQMIN
    ISZ KFQ /NO, SET KFQ=KFQ+1
    JMP .+3
    TAD ITQMIN
    DCA KFQ
/A.3 GET DATA FROM THE QUEUE.
    CDF DATFLD
    TAD I KFQ
    CDF INSTFD
    JMP I GETFQ /RETURN
/...CONSTANTS...
ITQMAX,	 TQMAX
ITQMIN,	 TQMIN
KRQ,	 TQMIN
KFQ,	 TQMIN
TQDAT,	 0
/..........................................
$