Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50146/common.mac
There are 22 other files named common.mac in the archive. Click here to see a list.
TITLE	COMMON SUBROUTINES	VERSION #2	SEPT. 1 '69
SUBTTL	DON WITCRAFT	3-11-66




ENTRY	EFLG3,EFLG4,EFLG5,EFLG6,EFLG7,SREAD,SWRITE

;SIMULATOR READ
;CALL	MOVEI	FDB,ADDRESS OF FILE DATA BLOCK
;	PUSHJ	PDP,SREAD
;	EOF RETURN, FILE HAS BEEN CLOSED
;	NORMAL RETURN

;IF SIMULATOR ERRORS ARE ENCOUNTERED, GOES TO ERROR.
;DOES NOT CHECK FOR IODERR.
;IF IMAGE MODE FROM DTA,MTA OR DSK, AFTER FILLING BUFFER
;CONVERTS BYTE POINTER TO 8 BIT BYTES AND MULTIPLIES ITEM
;COUNT BY 4.

EXTERNAL ERROR

SREAD:	PUSH	PDP,AC3			;SAVE AC3
	JSP	SRR,FIN	;EXECUTE READ IN FILEIO
	MOVE	AC3,CFSTAT(FDB)
	TRNE	AC3,-1			;FILE ERROR?
	PUSHJ	PDP,ERROR		;YES
EFLG3:	MOVE	AC3,CDSTAT(FDB)
	TRNE	AC3,ERRORS-IODERR	;SIMULATOR ERROR?
	PUSHJ	PDP,ERROR		;YES
EFLG4:	TRNN	AC3,IODEND		;NO. EOF?
	JRST	SREAD1			;NO.
	JSP	SRR,FCLOSE		;YES
	MOVE	AC3,CDSTAT(FDB)
	TRNE	AC3,ERRORS-IODERR
	PUSHJ	PDP,ERROR
EFLG5:	SOS	-1(PDP)			;CONVERT SKIP RETURN TO NORMAL
SREAD1:	POP	PDP,AC3			;RESTORE AC3
	AOS	(PDP)			;SKIP
	POPJ	PDP,			;RETURN
;SIMULATOR WRITE
;CALL	MOVEI	FDB,ADDRESS OF FILE DATA BLOCK
;	PUSHJ	PDP,SWRITE
;	RETURN


SWRITE:	JSP	SRR,FOUT
	PUSH	PDP,AC3
	MOVE	AC3,CFSTAT(FDB)
	TRZN	AC3,IOIDM	;ILLEGAL MODE?
	JRST	SWRIT1
	MOVEI	AC3,AL		;MAKE IT ASCII
	HRRM	AC3,CINI(FDB)
	POP	PDP,AC3
	JSP	SRR,FCLOSE
	JRST	SWRITE
SWRIT1:	TRNE	AC3,-1
	PUSHJ	PDP,ERROR
EFLG6:	MOVE	AC3,CDSTAT(FDB)
	TRNE	AC3,ERRORS-IODERR
	PUSHJ	PDP,ERROR
EFLG7:	POP	PDP,AC3
	POPJ	PDP,


;CALL:	MOVEI 16,ADDRESS OF FILE DATA BLOCK
;	JSP 17,FIN OR FOUT OR FCLOSE
;	RETURN


;THE IO CHANNELS JOBJDA THRU JOBJDA+20 ARE UNIDIRECTIONAL
;FILE TRANSMISSION CHANNELS.









ENTRY FIN,FOUT

;ACCUMULATORS

	FAC1=12
	FAC2=13
	FAC3=14
	FAC4=15
	FP=FDB
FOUT:	JSR	FSAVE			;LOAD FILE DATA BLOCK IN 0-11
	TLO	CFSTAT,FOUTB		;SET OUTPUT CALLED
	JRST	FIOC1

FIN:	JSR	FSAVE			;LOAD FILE DATA BLOCK IN 0-11
	TLZ	CFSTAT,FOUTB		;SET INPUT CALLED

;CHECK TO BE SURE INITIALIZATION IS COMPLETE.
FIOC1:	TRNN	CINI,17			;IS CHANNEL ASSIGNED?
	PUSHJ	FP,FCHNAS		;NO. ASSIGN CHANNEL
	TLNN	CFSTAT,INITB		;IS DEVICE ATTACHED TO CHANNEL?
	PUSHJ	FP,FCHINI		;NO. INITIALIZE CHANNEL
	MOVEI	FAC2,OUTBFB+OUTPB+ENTRB+OBUFB+OCLOSB	;OUTPUT BITS
	TLNE	CFSTAT,FOUTB		;OUTPUT?
	MOVEI	FAC2,INBFB+INPB+LOOKB+IBUFB+ICLOSB	;NO SO INPUT BITS
	TLNE	CFSTAT,(FAC2)		;TRAP FOR
	JRST	FIOE1			;FILE OPEN IN WRONG DIRECTION
	TLNN	CFSTAT,LOOKB+ENTRB	;HAS LOOKUP OR ENTER BEEN DONE?
	PUSHJ	FP,FEL			;NO
	LDB	FAC2,[POINT 4,CINI,17]	;LOAD DATA MODE IN FAC2
	CAIL	FAC2,SD			;DUMP MODE?
	JRST	FIOC2			;YES
	TLNN	CFSTAT,INBFB+OUTBFB	;NO. BUFFER SET UP?
	PUSHJ	FP,FIOBUF		;NO
FIOC2:	PUSHJ	FP,FIO			;NOW EVERYTHING IS READY .. SO DO IO
	PUSHJ	FP,XCTUUO
	STATUS	0,CDSTAT
	POPJ	FP,			;RESTORE AC'S & RETURN TO CALLING ROUTINE

FIOE1:	TRO	CFSTAT,IOFAO		;FILE ALREADY OPEN
	POPJ	FP,
	;ROUTINE TO SEARCH FOR FREE CHANNEL
	;CALL	PUSHJ	FP,FCHNAS
	;IF NO FREE CHANNEL, SETS IOCNA AND EXITS TO CALLER.


EXTERNAL MCLIST,CLIST

FCHNAS:	MOVEI	FAC4,17			;LOAD CHANNEL NUMBER
FCHNA0:	MOVSI	FAC3,MCLIST		;LOAD	[XWD -CLIST LENGTH,,0]
FCHNA1:	MOVE	FAC2,CLIST(FAC3)	;SEARCH FILE DATA BLOCKS
	HLRZ	FAC2,CINI(FAC2)		;FOR CHANNEL C(FAC4).
	CAME 	FAC2,FAC4		;IS IT ASSIGNED TO THIS FILE?
	AOBJN	FAC3,FCHNA1		;NO. CHECKED ALL FILES?
	JUMPGE	FAC3,FCHNA2		;YES. WAS IT ASSIGNED?
	SOJG	FAC4,FCHNA0		;YES. TRY ANOTHER
	TRO	CFSTAT,IOCNA		;NONE AVAILABLE - SET ERROR BIT
FPOPJ1:	POP	FP,FAC1			;POP OUT RETURN ADDRESS
	POPJ	FP,			;JRST FRET ... EXIT FILEIO

FCHNA2:	HRRM	FAC4,CINI		;ASSIGN THIS CHANNEL
	POPJ	FP,
;INITIALIZE CHANNEL
;CALL	PUSHJ	FP,FCHINI
;	RETURNS WITH CHANNEL INITIALIZED

;IF NO DEVICE BY C(CDNAM, SETS IONSD AND EXITS
;IF DEVICE NOT AVAILABLE, SETS IODNA AND EXITS
;IF DATA MODE ILLEGAL FOR THIS DEVICE, SETS IOIDM AND EXITS
;IF BUFFER HEADER ADDRESS IS < 74, SETS IOBHPD AND EXITS
;IF BUFFER HEADER EXCEEDS ALLOCATED CORE, SETS IOBHOB AND EXITS

EXTERNAL JOBREL

FCHINI:	MOVE	FAC1,FACS+16	;LOAD NORMAL CONTENTS OF FDB
	DPB	CINI,[POINT 4,FCHIN1,12]	;PUT CHANNEL NUMBER IN OPEN
	MOVE	CDCHAR,CDNAM
	CALLI	CDCHAR,4	;GET DEVICE CHARACTERISTICS
	JUMPE	CDCHAR,FCHIE1	;NO SUCH DEVICE IF ZERO
	TLNN	CDCHAR,DVAVAL	;IS DEVICE AVAILABLE?
	JRST 	FCHIE2		;NO
	LDB	FAC3,[POINT 4,CINI,17]	;MODE
	MOVEI	FAC2,1
	LSH	FAC2,-(FAC3)
	AND	FAC2,CDCHAR	;LEGAL DATA MODE?
	JUMPE	FAC2,FCHIE3	
	CAIL	FAC3,SD		;YES. DUMP MODE?
	JRST 	FCHIN1		;YES
	TLNE	CFSTAT,FOUTB	;OUTPUT?
	HRLZM	CBUFH,2(FAC1)	;YES SO PUT HEADER IN LEFT HALF
FCHIN1:	OPEN	@FACS+16	;INITIALIZE DEVICE
	JRST	FCHIE2		;DEVICE NOT AVAILABLE
	TLO	CFSTAT,INITB
	CAIL	FAC3,SD		;DUMP MODE?
	POPJ	FP,		;YES
	MOVSI	FAC2,OBUFB	;NO
	TLNN	CFSTAT,FOUTB	;OUTPUT?
	MOVSI	FAC2,IBUFB	;NO.
	OR	CFSTAT,FAC2
	POPJ	FP,

FCHIE2:	TROA	CFSTAT,IODNA	;DEVICE NOT AVAILABLE
FCHIE3:	TRO	CFSTAT,IOIDM	;ILLEGAL DATA MODE
	JRST	FPOPJ1		;EXIT TO CALLER

FCHIE4:	TROA	CFSTAT,IOBHOB	;BUFFER HEADER OUT OF BOUNDS
FCHIE5:	TRO	CFSTAT,IOBHPD	;BUFFER HEADER IN PROTECTED JOBDATA AREA
	JRST	FPOPJ1		;EXIT TO CALLER

FCHIE1:	TRO	CFSTAT,IONSD	;NO SUCH DEVICE
	JRST	FPOPJ1

COMOBH:	BLOCK	3		;COMMON OUTPUT BUFFER HEADER
;LOOKUP/ENTER

;CALL	PUSHJ	FP,FEL
;	RETURN IF NO ERRORS


EXTERNAL JOBREL


FEL:	TLNE	CFSTAT,FOUTB	;LOOKUP?
	JRST	FENTR1		;NO
	PUSHJ	FP,XCTUUO	;YES
	LOOKUP	0,(CDIR)
	JRST	FLOOK3		;FILE NOT FOUND
	TLO	CFSTAT,LOOKB

	POPJ	FP,

FENTR1:	PUSHJ	FP,XCTUUO
	ENTER	0,(CDIR)
	JRST	.+3
	TLO	CFSTAT,ENTRB
	POPJ	FP,
	TROA	CFSTAT,IODDF	;DIRECTORY FULL

FLOOK1:	TRO	CFSTAT,IOFEPD	;ENTRY BLOCK IN PROTECTED JOB
	JRST	FPOPJ1		;JOB DATA AREA

FLOOK3:	TRO	CFSTAT,IOFNF	;FILE NOT FOUND
	JRST	FPOPJ1
;INBUF/OUTBUF

;CALL	PUSHJ	FP,FIOBUF
;	RETURN IF NO ERRORS


EXTERNAL JOBFF,JOBREL


FIOBUF:	TLNE	CFSTAT,FOUTB	;INPUT?
	JRST	FOUTB1		;NO
	PUSHJ	FP,XCTUUO
	INBUF	2		;GET 2 BUFFERS
	TLO	CFSTAT,INBFB
	POPJ	FP,

FOUTB1:	PUSHJ	FP,XCTUUO
	OUTBUF	2		;AGAIN 2 BUFFERS
	TLO	CFSTAT,OUTBFB
	POPJ	FP,
;INPUT/OUTPUT EXECUTION

;CALL	PUSHJ	FP,FIO
;	RETURN IF NO ERRORS


EXTERNAL JOBREL


FIO:	LDB	FAC3,[POINT 4,CINI,17]	;LOAD DATA MODE IN FAC3
	CAIGE	FAC3,SD		;DUMP MODE?
	JRST	FIOB1		;NO
FIODM1:	CAMLE	CBADR,JOBREL	;IS COMMAND LIST POINTER OK?
	JRST	FINPE2		;NO
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CE BLOCK NUMBER

FOUTP4:
FOUTP5:	PUSHJ	FP,XCTUUO
	OUTPUT	0,
	JRST	FOUTP6

FINPE1:	TROA	CFSTAT,IOIBN	;ILLEGAL DECTAPE BLOCK NUMBER

FINPE2:	TRO	CFSTAT,IOCLOB	;DUMP COMMAND LIST OUT OF BOUNDS
	JRST	FPOPJ1

FINPE3:	TROA	CFSTAT,IOCOB	;DUMP COMMAND OUT OF BOUNDS
FCLOE1:	TRO	CFSTAT,IOBTH	;CHANNEL OPEN BOTH IN AND OUT
	JRST	FPOPJ1
;CLOSE FILE

;CALL	MOVEI	FDB,ADDRESS OF FILE DATA BLOCK
;	JSP	17,FCLOSE
;	RETURN


ENTRY FCLOSE


FCLOSE:	JSR	FSAVE		;SAVE AC'S, LOAD FILE DATA BLOCK IN 0-11
	TLNE	CBUFH,-1	;OPEN FOR BOTH INPUT AND OUTPUT?
	POPJ	FP,		;YES - SO CLOSING IS A NONO
	TRNN	CINI,-1		;TEST FOR CHANNEL #
	POPJ	FP,		;RETURN IF FILE NOT OPEN.
	JUMPE	CFSTAT,.-1	;ALSO RETURN IF NOT OPENED
	TLNE	CFSTAT,OCLOSB+ICLOSB	;FILE ALREADY CLOSED?
	POPJ	FP,		;YES SO LEAVE
	SETZM	CFSTAT		;CLOSE THE FILE AND FORGET IT
	PUSHJ	FP,XCTUUO
	CLOSE
	PUSHJ	FP,XCTUUO
	STATUS	0,CDSTAT
	POPJ	FP,
;RELEASE CHANNEL

;CALL	MOVEI	FDB,ADDRESS OF FILE DATA BLOCK
;	JSP	17,FRELEASE
;	RETURN

ENTRY	FRELEA

FRELEA:	JSR	FSAVE
FRELE1:	TRNN	CINI,-1
	JRST	FRELE2
	PUSHJ	FP,XCTUUO
	RELEAS	0,
FRELE2:	HLLZS	CINI
	SETZB	CFSTAT,CDSTAT
	SETZB	CDCHAR,CDBLOCK
	POPJ	FP,
;SAVE ACCUMULATORS, MOVE FILE DATA BLOCK TO AC0-AC11,
;SETUP PUSHDOWN POINTER

;CALL	JSR	FSAVE


FSAVE:	0
	MOVEM	0,FACS			;SAVE AC0
	MOVE	0,[XWD 1,FACS+1]	;LOAD BLT POINTER
	BLT	0,FACS+17		;SAVE AC1-AC17
	HRLZS	FDB			;BLT POINTER	[XWD FDB,,0]
	BLT	FDB,CBADR		;BLT FDB INTO 0-11
	MOVE	FP,[XWD -FPDN+1,FPDL]	;LOAD FP WITH PUSHD POINTER
	MOVSS	CINI			;SWAP CHANNEL NU TO RIGHT
	JRST	@FSAVE			;RETURN


;RESTORE FILE DATA BLOCK AND ACCUMULATORS AND RETURN TO USER.
;CALL	JRST FRET	OR	POPJ FP,


FRET:	MOVSS	CINI
	HRRZ	FP,FACS+FDB	;LOAD FILE DATA BLOCK ADDRESS
	ADDI	FP,CBADR
	HRRM	FP,.+2
	HRRZ	FP,FACS+FDB	;LOAD FILE DATA BLOCK ADDRESS
	BLT	FP,0		;RESTORE FILE DATA BLOCK TO CORE
	MOVSI	17,FACS		;BLT POINTER TO RESTORE AC'S
	BLT	17,17		;RESTORE AC'S
	JRST	(SRR)


FACS:	BLOCK	20
FPDL:	EXP	FRET
	BLOCK	10
	FPDN=.-FPDL
;EXECUTE UUO
;CALL	PUSHJ FP,XCTUUO
;	UUO


XCTUUO:	DPB	CINI,[POINT 4,@(FP),12]
	POPJ	FP,


;MOVE OUTPUT BUFFER HEADER TO COMOBH
;CALL	PUSHJ FP,LDCOMH


LDCOMH:	PUSH	FP,FAC3		;SAVE FAC3
	HRL	FAC3,CBUFH
	HRRI	FAC3,COMOBH
	BLT	FAC3,COMOBH+2
	POP	FP,FAC3
	POPJ	FP,


;MOVE COMOBH TO OUTPUT BUFFER HEADER
;CALL	PUSHJ FP,DPCOMH


DPCOMH:	PUSH	FP,FAC3
	HRRZ	FAC3,CBUFH
	ADDI	FAC3,2
	HRRM	FAC3,.+3
	HRLI	FAC3,COMOBH
	HRR	FAC3,CBUFH
	BLT	FAC3,.
	POP	FP,FAC3
	POPJ	FP,
;REASSIGN DEVICE
;CALL	MOVEI FDB,ADDRESS FOF FILE DATA BLOCK
;	JSP 17,FREASS
;	JOB NUMBER
;	RETURN

ENTRY FREASS

FREASS:	JSR	FSAVE
	PUSHJ	FP,FRELE1	;RELEASE DEVICE
	AOS	SRR
	MOVE	FAC1,-1(SRR)
	MOVE	FAC2,CDNAM
	CALL	FAC1,[SIXBIT /REASSI/]
	JUMPN	FAC1,.+2	;JOB INITIALIZED?
	TRO	CFSTAT,IOJNI	;NO
	JUMPN	FAC2,.+2	;YES. DEVICE ASSIGNED?
	TRO	CFSTAT,IODNA	;NO
	POPJ	FP,
	END