Google
 

Trailing-Edge - PDP-10 Archives - bb-d868b-bm_tops20_v3a_2020_dist - 3a-sources/c11sim.mac
There are 9 other files named c11sim.mac in the archive. Click here to see a list.
SUBTTL	Ed Fortmiller/EGF/JBS/MM 29-SEPTEMBER-77
;

	ENTRY	CAL11$			;

	SEARCH	MACTEN,UUOSYM,MONSYM

	%%MACT==%%MACT			;Show MACTEN version
	%%UUOS==%%UUOS			;Show UUOSYM version
;	%%MONS==%%MONS			;Show MONSYM version

	SALL				;Suppress macro expansion

;VERSION INFORMATION
;
	C11VER==1			;Major version number
	C11MIN==0			;Minor version number
	C11EDT==17			;Edit level
	C11WHO==0			;Who last patched

	TWOSEG				;Two segment program
	RELOC	400000			;Start in the HISEG




;COPYRIGHT (C) 1977, 1978 BY
;DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE AND WITH THE
;INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY  OTHER
;COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
;OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE  SOFTWARE  IS  HEREBY
;TRANSFERRED.
;
;
;THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT  NOTICE
;AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
;CORPORATION.
;
;DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY  OF  ITS
;SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.

;Now Define a Title Macro
;
	DEFINE	..TITL(V,E,W),<
IFE	W,<TITLE	C11SIM  Program to Simulate CAL11 UUO Function .C11QU - Ver V(E)>
IFN	W,<TITLE	C11SIM  Program to Simulate CAL11 UUO Function .C11QU - Ver V(E)-W>
>

;Now make a Title
;
	..TITL	\C11VER,\C11EDT,\C11WHO
; REVISION HISTORY
;
; EDIT 16 - JUNE 29, 1977
;
; EDIT 17 - SEPTEMBER 29, 1977
;		REMOVE SIBE TO IMPROVE PERFORMANCE.
;		TOPS-20 MONITOR GROUP CLAIMS THAT
;		 IF THE -11 CRASHES THE SIN WILL GIVE
;		 AND ERROR RETURN.  /JBS
;
SUBTTL	Definitions

;AC Definitions
;
	T1=1				;TEMPORARY
	T2=T1+1				;TEMPORARY
	T3=T2+1				;TEMPORARY
	T4=T3+1				;TEMPORARY
	C11=T4+1			;POINTS TO THE CAL11 BLOCK
	P=17				;PDL

	ND	MAXBYT,^D254		;MAXIMUM BYTES WE CAN TRANSFER
	ND	LIMBYT,^D4000		;MAXIMUM BYTES WITHOUT GIVING UP RESOURCES
SUBTTL	CAL11. UUO Definitions

;Functions

	.C11DP==0			;Deposit function
	.C11EX==1			;Examine function
	.C11QU==2			;Queue request function
	.C11NM==3			;Return name of program running
	.C11UP==4			;Return 0 if PDP11 is down
					;Return 1 if PDP11 is up

;Error codes

	C11NP%==1			;Caller does not have POKE privileges
	C11UF%==2			;The function is undefined on this
					; type of front end
	C11ND%==3			;Invalid DL10 port number
	C11IU%==4			;CAL11. facility in use, try again later
	C11NA%==5			;No answer from the front end after
					; 1-2 seconds
	C11TS%==6			;Queue entry too short  (DC76 only)
	C11NE%==7			;Not enough arguments
	C11AI%==10			;Examine/Deposit address was invalid
					; (more than 16 bits or front end flagged
					; it as invalid), or deposit data
					; was more than 16 bits
	C11OR%==11			;In .C11QU, illegal function code,
					; address check, illegal byte size, byte
					; offset is outside buffer, or buffer
					; is too large (requires more than
					; 16 DL10 byte pointers), or more than
					; 4095 bytes on a DTE20.
;For .C11QU function
;
;	MOVE	AC,[XWD	Length,Address]
;	CAL11.	AC,
;	  Error return
;	Success return
;
;
;ADR:	XWD	Port number,.C11QU
;	XWD	Line number,Device number
;	XWD	Number of bytes,Function code
;	XWD	Length of buffer,Buffer address
;	BYTE (12) Number of bytes per word (24) Position of first byte
;	XWD	Number of bytes transferred,Result code

;Definitions to access the "C11BLK"
;
	DEFST.	(C%PORT,0(C11),-1B17)	;The port number
	DEFST.	(C%LINE,1(C11),-1B17)	;The line number
	DEFST.	(C%DEV,1(C11),777777)	;The device number
	DEFST.	(C%NBYT,2(C11),-1B17)	;The number of bytes
	DEFST.	(C%FC,2(C11),777777)	;The function code
	DEFST.	(C%BUFS,3(C11),-1B17)	;The buffer size in words
	DEFST.	(C%BUFA,3(C11),777777)	;The buffer address
	DEFST.	(C%BPW,4(C11),-1B11)	;The number of bytes per word
	DEFST.	(C%PFB,4(C11),77777777)	;The position of the first byte
	DEFST.	(C%BXFD,5(C11),-1B17)	;The number of bytes transferred
	DEFST.	(C%RC,5(C11),777777)	;The result code
SUBTTL	SIMULATE THE CAL11. UUO

;HERE TO SIMULATE THE .C11QU FUNCTION OF THE CAL11. UUO
;
; CALL:	PUSHJ	P,CAL11$		;AC 1 POINTS TO THE CAL11 BLOCK
;					;AC 2 CONTAINS THE JFN (TOPS20)
;					;AC P POINTS TO A PDL
;	ERROR RETURN			;T1 CONTAINS THE ERROR CODE
;	OK	RETURN			;T1 POINTS TO THE CAL11 BLOCK
;					; T2 CONTAINS THE JFN
;
CAL11$::PUSH	P,1			;REMEMBER WHERE CAL11 BLOCK IS
	MOVE	1,[XWD	2,SAVEAC]	;SAVE AC'S 2-5
	BLT	1,SAVEAC+3		;DO IT
	POP	P,C11			;PUT ADR OF CAL11 BLOCK HERE
	MOVEM	2,JFN			;REMEMBER THE JFN (TOPS20)
	MOVEM	P,PDL			;REMEMBER WHERE THE PDL WAS
	STORE	(T1,FIRZRO,LSTZRO,0)	;ZERO FROM FIRZRO THRU LSTZRO
	LOAD.	(T3,C%PORT)		;GET THE PORT NUMBER
	SUBI	T3,10			;MAKE IT THE DTE NUMBER
	CAIL	T3,0			;MAKE SURE ITS IN
	 CAILE	T3,3			; THE RANGE OF 0-3 (10-13)
	  PJRST	ILLPRT			;ILLEGAL PORT NUMBER
	MOVE	T2,[POINT 8,XMTHDR,7]	;POINTER TO WHERE THE TRANSMIT
					; HEADER IS BUILT
	LOAD.	(T1,C%FC)		;GET THE FUNCTION CODE
	IDPB	T1,T2			;PUT FUNCTION CODE IN XMIT HDR
	LOAD.	(T1,C%LINE)		;GET THE LINE NUMBER
	IDPB	T1,T2			;PUT THE LINE NUMBER IN THE XMIT HDR
	LOAD.	(T1,C%DEV)		;GET THE LINE NUMBER
	IDPB	T1,T2			;PUT THE DEVICE NUMBER IN THE XMIT HDR
	IBP	T2			;GO OVER HIGH ORDER OF LENGTH
					; CAUSE CAN ONLY HAVE 8 BITS WORTH
					; UNDER TOPS20
	LOAD.	(T1,C%NBYT)		;GET NUMBER OF BYTES
	 JUMPLE	T1,ILLARG		;ZERO IS ILLEGAL
	CAILE	T1,MAXBYT		;CAN'T HAVE ANY MORE THAN THIS
	  MOVEI	T1,MAXBYT		;TRIM TO MAXBYT
	IDPB	T1,T2			;PUT THE NUMBER OF BYTES IN THE XMIT HDR
	MOVE	1,C11			;POINT REG. 1 TO CAL11. BLOCK
	PUSHJ	P,ENQ$			;REQUEST ACCESS
	  JRST	[	CAIE	T1,ENQX6	;INUSE?
			  PJRST	JSYSER		;YES, GIVE JSYS ERROR
			PJRST	C11E4	]	;YES, GIVE CAL11 ERROR 4
	MOVE	T1,JFN			;JFN FOR SOUT
	MOVE	T2,[POINT 8,XMTHDR]	;POINTER TO THE XMIT HDR FOR SOUT
	MOVNI	T3,6			;LENGTH OF HEADER TO GO OUT
	SOUT				;OUTPUT THE HEADER
	  ERJMP	JSYSER			;SOUT FAILED
	PUSHJ	P,FLUSH			;MAKE SURE HEADER IS OUT
	LOAD.	(T1,C%FC)		;GET FUNCTION CODE
	TRNN	T1,1			;ODD FUNCTION CODE MEANS READ
	  JRST	WRITE			;TAKE CARE OF WRITE
;HERE FOR READ FUNCTIONS 
;
READ:	PUSHJ	P,GETHDR		;GET THE HEADER
	LDB	T1,[POINT 8,RCVHDR+1,15]; GET NUMBER OF BYTE RETURNED
					; IN THE HEADER.
	MOVEM	T1,NBXFR		;SAVE NO OF BYTES
	JUMPE	T1,READFN		;IF NO BYTES TO FOLLOW DON'T
					; ATTEMPT TO READ ANY.
	PUSHJ	P,MKPNT			;MAKE POINTER TO BUFFER
					; RETURNS POINTER IN T2
	LDB	T4,[POINT 8,RCVHDR+1,15] ;NUMBER OF BYTES AGAIN
	MOVNS	T3			;LENGTH OF USER'S BUFFER
	CAMLE	T4,T3			;WILL MESSAGE FIT?
	 JRST	ILLARG			;NO, GIVE ERROR.
	MOVN	T3,T4			;YES, READ AS MANY BYTES
					; AS SPECIFIED IN HEADER
	SIN				;GET THE DATA PORTION
	  ERJMP	JSYSER			;OOPS
	PUSHJ	P,FLUSH			;
READFN:	LDB	T1,[POINT 8,RCVHDR,7]	;GET RESULT CODE
	LDB	T2,[POINT 8,RCVHDR+1,15] ;GET # BYTES XFERD
					; LIKE CAL11. WOULD HAVE
	JRST	SRCBYT			;EXIT
;HERE FOR WRITE FUNCTIONS
;
WRITE:	LOAD.	(T1,C%NBYT)		;SAVE BYTE COUNT SPECIFIED
	MOVEM	T1,TOTBYT		;FOR RESTORING AT EXIT
	LOAD.	(T1,C%PFB)		;SAVE POSITION OF FIRST BYTE
	MOVEM	T1,POSBYT		;FOR RESTORING LATER
WRITEB:	MOVE	T2,NBXFR		;TRANSFERRED ENOUGH?
	CAIL	T2,LIMBYT		;TO TAKE A BREAK!
	  JRST	FINISD			;YES,GIVE DELAYED RESULT
					;PREPARE FOR MORE
	PUSHJ	P,MKPNT			;POINT TO DATA
	SOUT				;SEND THE DATA
	  ERJMP	JSYSER			;OOPS
	PUSHJ	P,FLUSH			;MAKE SURE DATA IS OUT
	PUSHJ	P,GETHDR		;GET HEADER THAT CONTAINS
					; LENGTH AND RESULT CODE
	LDB	T2,[POINT 8,RCVHDR+1,15] ;COUNT OF BYTES RETURNED
	ADDM	T2,NBXFR		;UPDATE # OF BYTES XFERRED
	LDB	T1,[POINT 8,RCVHDR,7]	;GET RESULT CODE
	CAIE	T1,1			;SUCCESSFUL??
	  JRST	FINISH			;NO, TELL THE USER
	LOAD.	(T1,C%PFB)		;UPDATE THE POSITION
	ADD	T1,T2			;OF FIRST BYTE IN 
	STOR.	(T1,C%PFB)		;THE CALL11 BLOCK
	LOAD.	(T1,C%NBYT)		;UPDATE THE COUNT 
	SUB	T1,T2			;OF BYTES LEFT TO
	STOR.	(T1,C%NBYT)		;TRANSFER FOR NEXT TIME
	JUMPE	T1,FINISH		;EXIT IF NOTHING LEFT
	CAILE	T1,MAXBYT		;CAN'T HAVE MORE THAN THIS
	MOVEI	T1,MAXBYT		;TRIM TO MAXBYT
	DPB	T1,[POINT 8,XMTHDR+1,15] ;PUT # BYTES IN XMIT HDR
	MOVE	T1,JFN			;PREPARE TO SEND HEADER
	MOVE	T2,[POINT 8,XMTHDR]	;POINT TO XMIT HEADER
	MOVNI	T3,6			;LENGTH OF XMIT HEADER
	SOUT				;OUTPUT HEADER
	  ERJMP	JSYSER			;SOUT FAILED
	PUSHJ	P,FLUSH			;MAKE SURE HEADER IS OUT
	  JRST	WRITEB			;LOOP TILL ALL DONE
;
FINISD:	MOVEI	T1,2			;GIVE DELAYED RETURN
	JUMPA	FINIS2			;SO THAT RESULT CODE SAVED
FINISH:	LDB	T1,[POINT 8,RCVHDR,7]	;GET RESULT CODE IN T1
FINIS2:	MOVE	T2,TOTBYT		;RESTORE TOTAL BYTE COUNT
	STOR.	(T2,C%NBYT)		;IN THE CALL11 BLOCK
	MOVE	T2,POSBYT		; AND BYTE-POSITION
	STOR.	(T2,C%PFB)		;ALSO
	MOVE	T2,NBXFR		;GET COUNT OF BYTES XFERRED
SRCBYT:	STOR.	(T1,C%RC)		;PUT WHERE CAL11. UUO WOULD
					; HAVE PUT IT.
	STOR.	(T2,C%BXFD)		;PUT WHERE CAL11. UUO WOULD
					; HAVE PUT IT.
	AOS	(P)			;GIVE SKIP RETURN
	MOVE	1,C11			;RESTORE AC 1
	PJRST	RELDEV			;DEQUE DEVICE, RESTORE AC'S
					; AND SKIP RETURN
SUBTTL	ROUTINES

;HERE TO GET THE HEADER
;
; CALL:	PUSHJ	P,GETHDR		;JFN CONTAIN JFN
;	 RETURN				;IF SIN FAILS
;	RETURN				;WITH HEADER IN "RCVHDR"
;
GETHDR:	MOVE	T1,JFN			;JFN
	MOVE	T2,[POINT 8,RCVHDR]	;WHERE TO PUT THE HEADER
	MOVNI	T3,6			;6 BYTES OF HEADER
	SIN				;GET THE HEADER
	  ERJMP	JSYSER			;SIN FAILED
	PJRST	FLUSH			;RETURN WITH HEADER IN "RCVHDR"


;ROUTINE TO MAKE SURE DATA GETS OUT
;
; CALL:	PUSHJ	P,FLUSH			;
;	RETURN				;
;
FLUSH:	MOVE	T1,JFN			;JFN
	MOVX	T2,.MOEOF		;FORCE OUTPUT
	MOVEI	T3,1			;THEY TOLD ME TO DO THIS
	MTOPR				;MAKE SURE ALL IS OUTPUT
	  ERJMP	JSYSER			;OOPS
	POPJ	P,			;RETURN
;ROUTINE TO MAKE A POINTER TO THE BUFFER
;
; CALL:	PUSHJ	P,MKPNT			;
;	RETURN				;T1 CONTAINS JFN
;					; T2 CONTAINS POINTER
;					; T3 CONTAINS NEG LENGTH
;
MKPNT:	LOAD.	(T2,C%BPW)		;GET NUMBER OF BYTES PER WORD
	CAIL	T2,4			;CAN ONLY HAVE 4-6 BYTES
	 CAILE	T2,6			; BYTES PER WORD
	  PJRST	ILLARG			;BYTES PER WORD OUT OF RANGE
	LOAD.	(T3,C%BUFA)		;GET ADDRESS OF BUFFER
	LOAD.	(T4,C%BUFS)		;GET SIZE OF BUFFER IN WORDS
	ADDI	T4,-1(T3)		;POINT TO LAST ADDRESS IN 
					; THE BUFFER.
	HLL	T3,[	POINT	8,	;4 BYTES PER WORD
			POINT	7,	;5 BYTES PER WORD
			POINT	6, ]-4(T2)	;6 BYTES PER WORD
	LOAD.	(T2,C%PFB)		;GET NUMBER OF BYTES
	ADJBP	T2,T3			;POINT TO RIGHT PLACE
	LOAD.	(T1,C%NBYT)		;GET NUMBER OF BYTES
	ADJBP	T1,T2			;FIGURE LAST ADDRESS
					; USING IN THE BUFFER
	CAIGE	T4,(T1)			;EXCEEDING BUFFER?
	  PJRST	ILLARG			;YES, ILLEGAL ARG IN ARGUMENT BLOCK
	LOAD.	(T3,C%NBYT)		;GET NUMBER OF BYTES
	CAILE	T3,MAXBYT		;LARGER THAN MAX ALLOWED?
	  MOVEI	T3,MAXBYT		;YES, REDUCE TO MAX.
	MOVNS	T3			; AND MAKE NEGATIVE
	MOVE	T1,JFN			;RETURN JFN IN T1
	POPJ	P,			;RETURN T2 CONTAINS POINTER
					; AND T3 CONTAINS -LENGTH
					; AND T1 CONTAINS THE JFN
;HERE FOR VARIOUS ERRORS

;HERE IF WE TIMED OUT WAITING FOR A
; RESPONSE FROM THE PDP11
;
TIMOUT:	MOVEI	T1,C11NA%		;TIMEOUT ERROR CODE
	JRST	ERRRET			;GIVE ERROR RETURN

;HERE IF A LOCK WAS ALREADY REQUESTED
; FOR THE DEVICE
;
C11E4:	MOVEI	T1,C11IU%		;DEVICE IN USE
	JRST	ERRRET			;GIVE ERROR RETURN

;HERE IF A ILLEGAL ARGUMENT DISCOVERED IN
; THE CAL11 FUNCTION BLOCK
;
ILLARG:	MOVEI	T1,C11OR%		;ILLEGAL ARG RETURN
	JRST	ERRRET			;GIVE ERROR RETURN

;HERE IF THE PORT NUMBER IS OUT OF RANGE
; IN THE CAL11 FUNCTION BLOCK
;
ILLPRT:	MOVEI	T1,C11ND%		;ILLEGAL PORT NUMBER
ERRRET:
JSYSER:	MOVE	P,PDL			;RESET PDL POINTER
RELDEV:	PUSH	P,T1			;SAVE THIS AS IT HAS USER INFO IN IT
	PUSHJ	P,DEQ$			;DEQ THE DEVICE
	  PJRST	JSYSER			;DEQ DIDN'T WORK
	POP	P,T1			;RESTORE THIS AC
RESEXT:	MOVE	5,[XWD	SAVEAC,2]	;RESTORE AC'S
	BLT	5,5			; 2-5
	POPJ	P,			;RETURN TO CALLER
;ROUTINE TO GET ACCESS OF A DEVICE
;
; CALL:	PUSHJ	P,ENQ$			;AC(1) POINTS TO THE CAL11 BLOCK
;	RETURN				;WITH JSYS ERROR CODE IN AC(1)
;	RETURN				;IF GOT DEVICE AND "$ENQF" IS
;					; SET TO -1.
;
ENQ$::	HLRZ	T1,(1)			;GET THE PORT NUMBER
	DPB	T1,[POINT 3,ENQBUF+1,20] ;PUT IN LOW DIGIT IN ASCIZ STRING
	LSH	T1,-3			;GET NEXT DIGIT (SHOULD BE 0 FOR NOW)
	DPB	T1,[POINT 3,ENQBUF+1,13] ;PUT IN HIGH DIGIT IN ASCIZ STRING
	MOVX	T1,.ENQAA		;ENQ FUNCTION CODE
	MOVEI	T2,ENQBLK		;POINT TO THE ARGUMENT BLOCK
	ENQ				;REQUEST ACCESS
	  ERJMP	CPOPJ			;GIVE NON SKIP RETURN
	SETOM	$ENQF			;FLAG WE GOT THE DEVICE
					; (SO WE CAN RELEASE IT)
CPOPJ1:	AOS	(P)			;SKIP RETURN
CPOPJ:	POPJ	P,			;RETURN TO CALLER

;ROUTINE TO RELEASE THE DEVICE
;
; CALL:	PUSHJ	P,DEQ$			;
;	RETURN				;IF DEQ FAILS
;	RETURN				;IF DEQUEUED THE DEVICE
;					; AND "$ENQF" SET TO 0.
;
DEQ$::	SKIPN	$ENQF			;DO WE HAVE THE DEVICE?
	  JRST	CPOPJ1			;NO, GIVE SKIP RETURN
	SETZM	$ENQF			;FLAG WE LET GO
	MOVX	T1,.DEQDR		;DEQ FUNCTION CODE
	MOVEI	T2,ENQBLK		;POINT TO THE FUNCTION BLOCK
	DEQ				;LET GO OF THE DEVICE
	  ERJMP	CPOPJ			;GIVE NONSKIP RETURN
	JRST	CPOPJ1			; AND GIVE SKIP RETURN

;ENQ/DEQ ARGUMENT BLOCK
;
ENQBLK:	XWD	1,5			;1 LOCK,,LENGTH IS 5
	XWD	0,0			;CHN 0,,ID
	XWD	0,-2			;FLAGS,,WHEEL OR OPR
	POINT	7,ENQBUF		;STRING POINTER
	XWD	0,0			;1 RESOURCE,,NUM OF ACCESSES
SUBTTL	LOW SEGMENT STORAGE

;LOW SEGMENT STORAGE

	RELOC

ENQBUF:	ASCIZ	\DN60-P00\		;BUILD THE ENQ/DEQ SPRING HERE
					; (CHECK ENQ/DEQ CODE IF
					; CHANGING THE LENGTH OF
					; THIS STRING)
JFN:	BLOCK	1			;SAVE THE JFN HERE
PDL:	BLOCK	1			;SAVE ACP HERE

SAVEAC:	BLOCK	4			;SAVE AC'S 2-5 HERE

FIRZRO:					;FROM FIRZRO THRU LSTZRO GET ZERO'D

XMTHDR:	BLOCK	2			;FOR TRANSMITTING THE HEADER

RCVHDR:	BLOCK	2			;FOR RECEIVING THE HEADER

$ENQF::	BLOCK	1			;IF NONZERO, WE HAVE A DEVICE
					; TO DEQUEUE.
POSBYT:	BLOCK	1			;POSITION OF FIRST BYTE
TOTBYT:	BLOCK	1			;TOTAL BYTE COUNT
NBXFR:	BLOCK	1			;BYTES TRANSFERRED

	LSTZRO==.-1			;LAST LOCATION THAT GETS ZERO'D

	END