Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-02 - decus/20-0027/common.mac
There are 22 other files named common.mac in the archive. Click here to see a list.
00100	TITLE	COMMON SUBROUTINES	VERSION #2	SEPT. 1 '69
00200	SUBTTL	DON WITCRAFT	3-11-66
00300	
00400	
00500	
00600	
00700	ENTRY	EFLG3,EFLG4,EFLG5,EFLG6,EFLG7,SREAD,SWRITE
00800	
00900	;SIMULATOR READ
01000	;CALL	MOVEI	FDB,ADDRESS OF FILE DATA BLOCK
01100	;	PUSHJ	PDP,SREAD
01200	;	EOF RETURN, FILE HAS BEEN CLOSED
01300	;	NORMAL RETURN
01400	
01500	;IF SIMULATOR ERRORS ARE ENCOUNTERED, GOES TO ERROR.
01600	;DOES NOT CHECK FOR IODERR.
01700	;IF IMAGE MODE FROM DTA,MTA OR DSK, AFTER FILLING BUFFER
01800	;CONVERTS BYTE POINTER TO 8 BIT BYTES AND MULTIPLIES ITEM
01900	;COUNT BY 4.
02000	
02100	EXTERNAL ERROR
02200	
02300	SREAD:	PUSH	PDP,AC3			;SAVE AC3
02400		JSP	SRR,FIN	;EXECUTE READ IN FILEIO
02500		MOVE	AC3,CFSTAT(FDB)
02600		TRNE	AC3,-1			;FILE ERROR?
02700		PUSHJ	PDP,ERROR		;YES
02800	EFLG3:	MOVE	AC3,CDSTAT(FDB)
02900		TRNE	AC3,ERRORS-IODERR	;SIMULATOR ERROR?
03000		PUSHJ	PDP,ERROR		;YES
03100	EFLG4:	TRNN	AC3,IODEND		;NO. EOF?
03200		JRST	SREAD1			;NO.
03300		JSP	SRR,FCLOSE		;YES
03400		MOVE	AC3,CDSTAT(FDB)
03500		TRNE	AC3,ERRORS-IODERR
03600		PUSHJ	PDP,ERROR
03700	EFLG5:	SOS	-1(PDP)			;CONVERT SKIP RETURN TO NORMAL
03800	SREAD1:	POP	PDP,AC3			;RESTORE AC3
03900		AOS	(PDP)			;SKIP
04000		POPJ	PDP,			;RETURN
04100	;SIMULATOR WRITE
04200	;CALL	MOVEI	FDB,ADDRESS OF FILE DATA BLOCK
04300	;	PUSHJ	PDP,SWRITE
04400	;	RETURN
04500	
04600	
04700	SWRITE:	JSP	SRR,FOUT
04800		PUSH	PDP,AC3
04900		MOVE	AC3,CFSTAT(FDB)
05000		TRZN	AC3,IOIDM	;ILLEGAL MODE?
05100		JRST	SWRIT1
05200		MOVEI	AC3,AL		;MAKE IT ASCII
05300		HRRM	AC3,CINI(FDB)
05400		POP	PDP,AC3
05500		JSP	SRR,FCLOSE
05600		JRST	SWRITE
05700	SWRIT1:	TRNE	AC3,-1
05800		PUSHJ	PDP,ERROR
05900	EFLG6:	MOVE	AC3,CDSTAT(FDB)
06000		TRNE	AC3,ERRORS-IODERR
06100		PUSHJ	PDP,ERROR
06200	EFLG7:	POP	PDP,AC3
06300		POPJ	PDP,
06400	
     
00100	
00200	
00300	;CALL:	MOVEI 16,ADDRESS OF FILE DATA BLOCK
00400	;	JSP 17,FIN OR FOUT OR FCLOSE
00500	;	RETURN
00600	
00700	
00800	;THE IO CHANNELS JOBJDA THRU JOBJDA+20 ARE UNIDIRECTIONAL
00900	;FILE TRANSMISSION CHANNELS.
01000	
01100	
01200	
01300	
01400	
01500	
01600	
01700	
01800	
01900	ENTRY FIN,FOUT
02000	
02100	;ACCUMULATORS
02200	
02300		FAC1=12
02400		FAC2=13
02500		FAC3=14
02600		FAC4=15
02700		FP=FDB
     
00100	FOUT:	JSR	FSAVE			;LOAD FILE DATA BLOCK IN 0-11
00200		TLO	CFSTAT,FOUTB		;SET OUTPUT CALLED
00300		JRST	FIOC1
00400	
00500	FIN:	JSR	FSAVE			;LOAD FILE DATA BLOCK IN 0-11
00600		TLZ	CFSTAT,FOUTB		;SET INPUT CALLED
00700	
00800	;CHECK TO BE SURE INITIALIZATION IS COMPLETE.
00900	FIOC1:	TRNN	CINI,17			;IS CHANNEL ASSIGNED?
01000		PUSHJ	FP,FCHNAS		;NO. ASSIGN CHANNEL
01100		TLNN	CFSTAT,INITB		;IS DEVICE ATTACHED TO CHANNEL?
01200		PUSHJ	FP,FCHINI		;NO. INITIALIZE CHANNEL
01300		MOVEI	FAC2,OUTBFB+OUTPB+ENTRB+OBUFB+OCLOSB	;OUTPUT BITS
01400		TLNE	CFSTAT,FOUTB		;OUTPUT?
01500		MOVEI	FAC2,INBFB+INPB+LOOKB+IBUFB+ICLOSB	;NO SO INPUT BITS
01600		TLNE	CFSTAT,(FAC2)		;TRAP FOR
01700		JRST	FIOE1			;FILE OPEN IN WRONG DIRECTION
01800		TLNN	CFSTAT,LOOKB+ENTRB	;HAS LOOKUP OR ENTER BEEN DONE?
01900		PUSHJ	FP,FEL			;NO
02000		LDB	FAC2,[POINT 4,CINI,17]	;LOAD DATA MODE IN FAC2
02100		CAIL	FAC2,SD			;DUMP MODE?
02200		JRST	FIOC2			;YES
02300		TLNN	CFSTAT,INBFB+OUTBFB	;NO. BUFFER SET UP?
02400		PUSHJ	FP,FIOBUF		;NO
02500	FIOC2:	PUSHJ	FP,FIO			;NOW EVERYTHING IS READY .. SO DO IO
02600		PUSHJ	FP,XCTUUO
02700		STATUS	0,CDSTAT
02800		POPJ	FP,			;RESTORE AC'S & RETURN TO CALLING ROUTINE
02900	
03000	FIOE1:	TRO	CFSTAT,IOFAO		;FILE ALREADY OPEN
03100		POPJ	FP,
     
00100		;ROUTINE TO SEARCH FOR FREE CHANNEL
00200		;CALL	PUSHJ	FP,FCHNAS
00300		;IF NO FREE CHANNEL, SETS IOCNA AND EXITS TO CALLER.
00400	
00500	
00600	EXTERNAL MCLIST,CLIST
00700	
00800	FCHNAS:	MOVEI	FAC4,17			;LOAD CHANNEL NUMBER
00900	FCHNA0:	MOVSI	FAC3,MCLIST		;LOAD	[XWD -CLIST LENGTH,,0]
01000	FCHNA1:	MOVE	FAC2,CLIST(FAC3)	;SEARCH FILE DATA BLOCKS
01100		HLRZ	FAC2,CINI(FAC2)		;FOR CHANNEL C(FAC4).
01200		CAME 	FAC2,FAC4		;IS IT ASSIGNED TO THIS FILE?
01300		AOBJN	FAC3,FCHNA1		;NO. CHECKED ALL FILES?
01400		JUMPGE	FAC3,FCHNA2		;YES. WAS IT ASSIGNED?
01500		SOJG	FAC4,FCHNA0		;YES. TRY ANOTHER
01600		TRO	CFSTAT,IOCNA		;NONE AVAILABLE - SET ERROR BIT
01700	FPOPJ1:	POP	FP,FAC1			;POP OUT RETURN ADDRESS
01800		POPJ	FP,			;JRST FRET ... EXIT FILEIO
01900	
02000	FCHNA2:	HRRM	FAC4,CINI		;ASSIGN THIS CHANNEL
02100		POPJ	FP,
     
00100	;INITIALIZE CHANNEL
00200	;CALL	PUSHJ	FP,FCHINI
00300	;	RETURNS WITH CHANNEL INITIALIZED
00400	
00500	;IF NO DEVICE BY C(CDNAM, SETS IONSD AND EXITS
00600	;IF DEVICE NOT AVAILABLE, SETS IODNA AND EXITS
00700	;IF DATA MODE ILLEGAL FOR THIS DEVICE, SETS IOIDM AND EXITS
00800	;IF BUFFER HEADER ADDRESS IS < 74, SETS IOBHPD AND EXITS
00900	;IF BUFFER HEADER EXCEEDS ALLOCATED CORE, SETS IOBHOB AND EXITS
01000	
01100	EXTERNAL .JBREL
01200	
01300	FCHINI:	MOVE	FAC1,FACS+16	;LOAD NORMAL CONTENTS OF FDB
01400		DPB	CINI,[POINT 4,FCHIN1,12]	;PUT CHANNEL NUMBER IN OPEN
01500		MOVE	CDCHAR,CDNAM
01600		CALLI	CDCHAR,4	;GET DEVICE CHARACTERISTICS
01700		JUMPE	CDCHAR,FCHIE1	;NO SUCH DEVICE IF ZERO
01800		TLNN	CDCHAR,DVAVAL	;IS DEVICE AVAILABLE?
01900		JRST 	FCHIE2		;NO
02000		LDB	FAC3,[POINT 4,CINI,17]	;MODE
02100		MOVEI	FAC2,1
02200		LSH	FAC2,-(FAC3)
02300		AND	FAC2,CDCHAR	;LEGAL DATA MODE?
02400		JUMPE	FAC2,FCHIE3	
02500		CAIL	FAC3,SD		;YES. DUMP MODE?
02600		JRST 	FCHIN1		;YES
02700		TLNE	CFSTAT,FOUTB	;OUTPUT?
02800		HRLZM	CBUFH,2(FAC1)	;YES SO PUT HEADER IN LEFT HALF
     
00100	FCHIN1:	OPEN	@FACS+16	;INITIALIZE DEVICE
00200		JRST	FCHIE2		;DEVICE NOT AVAILABLE
00300		TLO	CFSTAT,INITB
00400		CAIL	FAC3,SD		;DUMP MODE?
00500		POPJ	FP,		;YES
00600		MOVSI	FAC2,OBUFB	;NO
00700		TLNN	CFSTAT,FOUTB	;OUTPUT?
00800		MOVSI	FAC2,IBUFB	;NO.
00900		OR	CFSTAT,FAC2
01000		POPJ	FP,
01100	
01200	FCHIE2:	TROA	CFSTAT,IODNA	;DEVICE NOT AVAILABLE
01300	FCHIE3:	TRO	CFSTAT,IOIDM	;ILLEGAL DATA MODE
01400		JRST	FPOPJ1		;EXIT TO CALLER
01500	
01600	FCHIE4:	TROA	CFSTAT,IOBHOB	;BUFFER HEADER OUT OF BOUNDS
01700	FCHIE5:	TRO	CFSTAT,IOBHPD	;BUFFER HEADER IN PROTECTED JOBDATA AREA
01800		JRST	FPOPJ1		;EXIT TO CALLER
01900	
02000	FCHIE1:	TRO	CFSTAT,IONSD	;NO SUCH DEVICE
02100		JRST	FPOPJ1
02200	
02300	COMOBH:	BLOCK	3		;COMMON OUTPUT BUFFER HEADER
     
00100	;LOOKUP/ENTER
00200	
00300	;CALL	PUSHJ	FP,FEL
00400	;	RETURN IF NO ERRORS
00500	
00600	
00700	EXTERNAL .JBREL
00800	
00900	
01000	FEL:	TLNE	CFSTAT,FOUTB	;LOOKUP?
01100		JRST	FENTR1		;NO
01200		PUSHJ	FP,XCTUUO	;YES
01300		LOOKUP	0,(CDIR)
01400		JRST	FLOOK3		;FILE NOT FOUND
01500		TLO	CFSTAT,LOOKB
01600	
01700		POPJ	FP,
01800	
01900	FENTR1:	PUSHJ	FP,XCTUUO
02000		ENTER	0,(CDIR)
02100		JRST	.+3
02200		TLO	CFSTAT,ENTRB
02300		POPJ	FP,
02400		TROA	CFSTAT,IODDF	;DIRECTORY FULL
02500	
02600	FLOOK1:	TRO	CFSTAT,IOFEPD	;ENTRY BLOCK IN PROTECTED JOB
02700		JRST	FPOPJ1		;JOB DATA AREA
02800	
02900	FLOOK3:	TRO	CFSTAT,IOFNF	;FILE NOT FOUND
03000		JRST	FPOPJ1
     
00100	;INBUF/OUTBUF
00200	
00300	;CALL	PUSHJ	FP,FIOBUF
00400	;	RETURN IF NO ERRORS
00500	
00600	
00700	EXTERNAL .JBFF,.JBREL
00800	
00900	
01000	FIOBUF:	TLNE	CFSTAT,FOUTB	;INPUT?
01100		JRST	FOUTB1		;NO
01200		PUSHJ	FP,XCTUUO
01300		INBUF	2		;GET 2 BUFFERS
01400		TLO	CFSTAT,INBFB
01500		POPJ	FP,
01600	
01700	FOUTB1:	PUSHJ	FP,XCTUUO
01800		OUTBUF	2		;AGAIN 2 BUFFERS
01900		TLO	CFSTAT,OUTBFB
02000		POPJ	FP,
     
00100	;INPUT/OUTPUT EXECUTION
00200	
00300	;CALL	PUSHJ	FP,FIO
00400	;	RETURN IF NO ERRORS
00500	
00600	
00700	EXTERNAL .JBREL
00800	
00900	
01000	FIO:	LDB	FAC3,[POINT 4,CINI,17]	;LOAD DATA MODE IN FAC3
01100		CAIGE	FAC3,SD		;DUMP MODE?
01200		JRST	FIOB1		;NO
01300	FIODM1:	CAMLE	CBADR,.JBREL	;IS COMMAND LIST POINTER OK?
01400		JRST	FINPE2		;NO
01500		SETZM	FAC1		;YES. CHECK COMMAND LIST
01600		SKIPN	FAC4,@(CBADR)	;DONE?
01700		JRST	FIODM2		;YES
01800		HLRE	FAC2,FAC4	;NO
01900		ADDM	FAC2,FAC1	;ACCUMULATE LENGTHS
02000		HRRZS	FAC4
02100		SUB	FAC4,FAC2
02200		CAMLE	FAC4,.JBREL	;IS DUMP REGION IN BOUNDS?
02300		JRST	FINPE3		;NO
02400		AOJA	FAC3,FIODM1	;YES
02500	
02600	FIODM2:	TLNE	CDCHAR,DVDIR	;DECTAPE?
02700		TLNE	CDCHAR,DVDSK
02800		JRST	FOUTP2		;NO
02900		HLRZ	FAC3,CDBLOCK	;YES
03000		MOVNS	FAC2,FAC1
03100		LSH	FAC2,^D8
03200		ADD	FAC3,FAC2
03300		CAMLE	FAC3,1103	;FIT ON DECTAPE?
03400		JRST	FINPE1		;NO
03500		HLL	FAC3,CDBLOCK	;YES. ADVANCE BLOCK NUMBER
03600		MOVSM	FAC3,CDBLOCK
03700	
03800	FIODM3:	TLNE	CFSTAT,FOUTB	;INPUT?
03900		JRST	FOUTP1		;NO
04000	
04100	FINP1:	;PUSHJ	FP,XCTUUO
04200		;USETI	0,(FAC3)
04300		PUSHJ	FP,XCTUUO
04400		INPUT	0
04500	
04600		TLO	CFSTAT,INPB	;SET INPUT DONE
04700		TLZ	CFSTAT,ICLOSB	;SET FILE NOT CLOSED
04800		POPJ	FP,
04900	
05000	FOUTP1:	PUSHJ	FP,XCTUUO
05100		USETO	0,(FAC3)
05200		PUSHJ	FP,XCTUUO
05300		OUTPUT	0,(CBADR)
05400	
05500	FOUTP6:	TLO	CFSTAT,OUTPB
05600		POPJ	FP,
     
00100	;NONDUMP MODE IO
00200	FIOB1:
00300	FOUTP2:	TLNE	CFSTAT,FOUTB	;INPUT?
00400		JRST	FOUTP4		;NO
00500		JRST	FINP1		;YES
00600	
00700	
00800	FOUTP3:	PUSHJ	FP,XCTUUO
00900		UGETF	0,FAC3		;GET LINK
01000		PUSHJ	FP,XCTUUO
01100		USETO	0,(FAC2)
01200		MOVSS	FAC2
01300		HRR	FAC2,FAC3
01400		MOVE	FAC3,@(CBUFH)	;STORE LINK IN BUFFER
01500		HRLM	FAC2,1(FAC3)
01600		MOVSM	FAC2,CDBLOCK	;ADVANCE BLOCK NUMBER
01700	
01800	FOUTP4:
01900	FOUTP5:	PUSHJ	FP,XCTUUO
02000		OUTPUT	0,
02100		JRST	FOUTP6
02200	
02300	FINPE1:	TROA	CFSTAT,IOIBN	;ILLEGAL DECTAPE BLOCK NUMBER
02400	
02500	FINPE2:	TRO	CFSTAT,IOCLOB	;DUMP COMMAND LIST OUT OF BOUNDS
02600		JRST	FPOPJ1
02700	
02800	FINPE3:	TROA	CFSTAT,IOCOB	;DUMP COMMAND OUT OF BOUNDS
02900	FCLOE1:	TRO	CFSTAT,IOBTH	;CHANNEL OPEN BOTH IN AND OUT
03000		JRST	FPOPJ1
     
00100	;CLOSE FILE
00200	
00300	;CALL	MOVEI	FDB,ADDRESS OF FILE DATA BLOCK
00400	;	JSP	17,FCLOSE
00500	;	RETURN
00600	
00700	
00800	ENTRY FCLOSE
00900	
01000	
01100	FCLOSE:	JSR	FSAVE		;SAVE AC'S, LOAD FILE DATA BLOCK IN 0-11
01200		TLNE	CBUFH,-1	;OPEN FOR BOTH INPUT AND OUTPUT?
01300		POPJ	FP,		;YES - SO CLOSING IS A NONO
01400		TRNN	CINI,-1		;TEST FOR CHANNEL #
01500		POPJ	FP,		;RETURN IF FILE NOT OPEN.
01600		JUMPE	CFSTAT,.-1	;ALSO RETURN IF NOT OPENED
01700		TLNE	CFSTAT,OCLOSB+ICLOSB	;FILE ALREADY CLOSED?
01800		POPJ	FP,		;YES SO LEAVE
01900		SETZM	CFSTAT		;CLOSE THE FILE AND FORGET IT
02000		PUSHJ	FP,XCTUUO
02100		CLOSE
02200		PUSHJ	FP,XCTUUO
02300		STATUS	0,CDSTAT
02400		POPJ	FP,
     
00100	;RELEASE CHANNEL
00200	
00300	;CALL	MOVEI	FDB,ADDRESS OF FILE DATA BLOCK
00400	;	JSP	17,FRELEASE
00500	;	RETURN
00600	
00700	ENTRY	FRELEA
00800	
00900	FRELEA:	JSR	FSAVE
01000	FRELE1:	TRNN	CINI,-1
01100		JRST	FRELE2
01200		PUSHJ	FP,XCTUUO
01300		RELEAS	0,
01400	FRELE2:	HLLZS	CINI
01500		SETZB	CFSTAT,CDSTAT
01600		SETZB	CDCHAR,CDBLOCK
01700		POPJ	FP,
     
00100	;SAVE ACCUMULATORS, MOVE FILE DATA BLOCK TO AC0-AC11,
00200	;SETUP PUSHDOWN POINTER
00300	
00400	;CALL	JSR	FSAVE
00500	
00600	
00700	FSAVE:	0
00800		MOVEM	0,FACS			;SAVE AC0
00900		MOVE	0,[XWD 1,FACS+1]	;LOAD BLT POINTER
01000		BLT	0,FACS+17		;SAVE AC1-AC17
01100		HRLZS	FDB			;BLT POINTER	[XWD FDB,,0]
01200		BLT	FDB,CBADR		;BLT FDB INTO 0-11
01300		MOVE	FP,[XWD -FPDN+1,FPDL]	;LOAD FP WITH PUSHD POINTER
01400		MOVSS	CINI			;SWAP CHANNEL NU TO RIGHT
01500		JRST	@FSAVE			;RETURN
01600	
01700	
01800	;RESTORE FILE DATA BLOCK AND ACCUMULATORS AND RETURN TO USER.
01900	;CALL	JRST FRET	OR	POPJ FP,
02000	
02100	
02200	FRET:	MOVSS	CINI
02300		HRRZ	FP,FACS+FDB	;LOAD FILE DATA BLOCK ADDRESS
02400		ADDI	FP,CBADR
02500		HRRM	FP,.+2
02600		HRRZ	FP,FACS+FDB	;LOAD FILE DATA BLOCK ADDRESS
02700		BLT	FP,0		;RESTORE FILE DATA BLOCK TO CORE
02800		MOVSI	17,FACS		;BLT POINTER TO RESTORE AC'S
02900		BLT	17,17		;RESTORE AC'S
03000		JRST	(SRR)
03100	
03200	
03300	FACS:	BLOCK	20
03400	FPDL:	EXP	FRET
03500		BLOCK	10
03600		FPDN=.-FPDL
     
00100	;EXECUTE UUO
00200	;CALL	PUSHJ FP,XCTUUO
00300	;	UUO
00400	
00500	
00600	XCTUUO:	DPB	CINI,[POINT 4,@(FP),12]
00700		POPJ	FP,
00800	
00900	
01000	;MOVE OUTPUT BUFFER HEADER TO COMOBH
01100	;CALL	PUSHJ FP,LDCOMH
01200	
01300	
01400	LDCOMH:	PUSH	FP,FAC3		;SAVE FAC3
01500		HRL	FAC3,CBUFH
01600		HRRI	FAC3,COMOBH
01700		BLT	FAC3,COMOBH+2
01800		POP	FP,FAC3
01900		POPJ	FP,
02000	
02100	
02200	;MOVE COMOBH TO OUTPUT BUFFER HEADER
02300	;CALL	PUSHJ FP,DPCOMH
02400	
02500	
02600	DPCOMH:	PUSH	FP,FAC3
02700		HRRZ	FAC3,CBUFH
02800		ADDI	FAC3,2
02900		HRRM	FAC3,.+3
03000		HRLI	FAC3,COMOBH
03100		HRR	FAC3,CBUFH
03200		BLT	FAC3,.
03300		POP	FP,FAC3
03400		POPJ	FP,
     
00100	;REASSIGN DEVICE
00200	;CALL	MOVEI FDB,ADDRESS FOF FILE DATA BLOCK
00300	;	JSP 17,FREASS
00400	;	JOB NUMBER
00500	;	RETURN
00600	
00700	ENTRY FREASS
00800	
00900	FREASS:	JSR	FSAVE
01000		PUSHJ	FP,FRELE1	;RELEASE DEVICE
01100		AOS	SRR
01200		MOVE	FAC1,-1(SRR)
01300		MOVE	FAC2,CDNAM
01400		CALL	FAC1,[SIXBIT /REASSI/]
01500		JUMPN	FAC1,.+2	;JOB INITIALIZED?
01600		TRO	CFSTAT,IOJNI	;NO
01700		JUMPN	FAC2,.+2	;YES. DEVICE ASSIGNED?
01800		TRO	CFSTAT,IODNA	;NO
01900		POPJ	FP,
02000		END