Google
 

Trailing-Edge - PDP-10 Archives - KS10_APT_INSTALL_TAPE - uetp/lib/cmlbcr.mac
There is 1 other file named cmlbcr.mac in the archive. Click here to see a list.
	TITLE	CMLBLW	LOW LEVEL CORE SPECIFIC ROUTINES.
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.



	;THIS LIBRARY CONTAINS ROUTINES WHICH PERFORM FUNCTIONS
	;SUCH AS "POPJ", "BLT", STRING COPYING, CHAIN ENTRY AND
	;REMOVAL ETC. AS SUCH, IT SHOULD NOT CALL COMPLEX ROUTINES
	;AND SHOULD BE THE LAST LIBRARY SEARCHED.


	PRGEND
	TITLE	LINKS	MANIPULATE LINKS IN A CHAIN.
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL


	ENTRY	LINKOT,LINKIN

	;ROUTINE TO REMOVE AN ENTRY FROM A CHAIN. ENTER WITH
	;"PNT" POINTING TO ENTRY TO BE REMOVED. CHAIN SHOULD
	;BE POINTED TO BY AC T1. THIS LOCATION GETS
	;UPDATED IF THE FIRST ENTRY IS BEING REMOVED.

LINKOT:	PUSH	P,T1		;SAVE POINTER TO START
	HRRZ	T1,(PNT)	;GET FORWARD POINTER
	HLRZ	T2,(PNT)	;AND BACKWARD POINTER
	JUMPE	T2,NOBACK	;NO BACKWARD POINTER
	HRRM	T1,(T2)		;ELSE UPDATE FORWARD LINK
	SKIPE	T1		;IF AT END DONT UPDATE
	HRLM	T2,(T1)		;AND BACKWARD LINK
	PJRST	T1POPJ##	;OK
NOBACK:	HRRZS	(T1)		;IF AT START BE CAREFUL
	MOVEM	T1,(P)		;UPDATE START ADDRESS
	PJRST	T1POPJ##	;RESTORE START ADDRESS AND RETURN

PAGE
	;ROUTINE TO INCLUDE A NEW ENTRY IN A CHAIN. ENTER WITH
	;"BUF" POINTING TO NEW ENTRY, AND "PNT" POINTING TO PLACE
	;WITHIN THE CHAIN AFTER WHICH THE ENTRY SHOULD BE INSERTED.
	;THE FIRST ENTRY OF THE CHAIN SHOULD BE POINTED TO BY AC T1.
	;ON RETURN T1 CONTAINS POINTER TO START OF CHAIN.
	;IF "PNT" ZERO ENTRY IS PUT AT START OF CHAIN.

LINKIN:	JUMPE	PNT,LINKN1	;PUT AT START
	PUSH	P,T1		;SAVE POINTER TO START
	HRRZ	T1,(PNT)	;GET FORWARD POINTER
	HRRM	BUF,(PNT)	;UPDATE POINTER
	HRRM	T1,(BUF)	;COMPLETE FORWARD POINTERS
	HRLM	PNT,(BUF)	;DO BACKWARD POINTERS
	SKIPE	T1		;UNLESS AT END
	HRLM	BUF,(T1)	;OK
	PJRST	T1POPJ##	;RESTORE START ADDRESS AND RETURN
LINKN1:	JUMPE	T1,LINKN2	;IF FIRST ONE
	HRLM	BUF,(T1)	;MAKE LINKS
LINKN2:	HRRZM	T1,(BUF)	;PUT AT START
	MOVE	T1,BUF		;POINT TO NEW START
	POPJ	P,		;OK

	PRGEND
	TITLE	JSTNAM	ROUTINE TO GET JUST THE DIRECTORY NAME.
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	JSTNAM

	;ROUTINE TO EDIT A STRING WHICH COULD BE A FULL FILESPEC
	;AND (HOPEFULLY) REPLACE IT BY JUST THE DIRECTORY NAME.
	;ENTER WITH T1 POINTING TO AN IN-CORE STRING. THE ROUTINE
	;SCANS OVER THE STRING UNTIL IT FINDS A CHARACTER WHICH
	;IS NOT A ":" OR A "<". IF IT FINDS A ":" OR A "<" IT
	;RESETS THE OUTPUT POINTER TO THE BEGINNING OF THE STRING.
	;THE EFFECT IS THAT EITHER THE STRINGS "ABC" OR "PS:<ABC>"
	;WILL BOTH END UP AS "ABC". RETURN +1 ALWAYS WITH T1
	;POINTING TO THE STRING. THE ROUTINE OVERWRITES THE ORIGINAL.

JSTNAM:	HRLI	T1,440700	;MAKE A BYTE POINTER
	PUSH	P,T1		;SAVE IT
JSTNM2:	MOVE	T2,(P)		;SET UP OUTPUT POINTER
JSTNM1:	ILDB	T3,T1		;GET A CHARACTER
	CAIE	T3,":"		;COLON?
	CAIN	T3,"<"		;OR OPEN BACKET?
	JRST	JSTNM2		;RESET OUTPUT POINTER
	CAIL	T3,"A"		;ALPHABETIC?
	CAILE	T3,"Z"		;ANY OF THEM?
	CAIN	T3,"-"		;HYPHEN?
	JRST	JSTNM3		;OK
	CAIL	T3,"a"		;LOWER CASE?
	CAILE	T3,"z"		;ANY OF THEM?
	CAIN	T3,"."		;DOT?
	JRST	JSTNM3		;OK
	CAIL	T3,"0"		;OR NUMERIC?
	CAILE	T3,"9"		;ANY OF THEM?
	SETZM	T3		;NO-WE ARE FINISHED
JSTNM3:	IDPB	T3,T2		;SAVE CHARACTER
	JUMPN	T3,JSTNM1	;DO ALL
	PJRST	T1POPJ##	;ALL DONE

	PRGEND
	TITLE	MTCHSG	MATCH TWO STRINGS.
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	MTCHSG

	;ROUTINE TO COMPARE TWO STRINGS. ENTER WITH T1 AND T2
	;POINTING TO THE STRINGS. RETURN +1 IF NOT MATCHED, OR
	;SKIP IF EXACT MATCH.

MTCHSG:	STCMP			;COMPARE THEM
	JUMPE	T1,CPOPJ1##	;MATCH
	POPJ	P,		;NO MATCH

	PRGEND
	TITLE	COPSTG	COPY A STRING
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	COPSTG

	;ROUTINE TO COPY A STRING. ENTER WITH T1 POINTING TO
	;SOURCE STRING AND T2 POINTING TO THE DESTINATION.
	;THE LEFT HALF SHOULD CONTAIN THE MAXIMUM NUMBER OF 
	;CHARACTERS ALLOWED. RETURN +1 IF ERROR, OR SKIP IF OK.

COPSTG:	HLRZ	T3,T2		;GET COUNT
	HRLI	T1,440700	;MAKE BYTE POINTERS
	HRLI	T2,440700	;FOR INPUT AND OUTPUT
COPLP1:	JUMPE	T3,CPOPJ##	;TOO SHORT!!
	ILDB	T4,T1		;GET BYTE
	IDPB	T4,T2		;SAVE IT
	JUMPE	T4,CPOPJ1##	;ALL DONE
	SOJA	T3,COPLP1	;DO NEXT

	PRGEND
	TITLE	GTJBLK	CLEAR AND SET GTJFN BLOCK
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	GTJCLS,GTJCLR,GTJSET

	;ROUTINE TO CLEAR AND SET GTJFN BLOCK FRON CONTENTS
	;OF A,B,C,D. (SEE GTJSET)

GTJCLS:	PUSHJ	P,GTJCLR	;FIRST CLEAR IT
	PJRST	GTJSET		;AND THEN SET IT

	;ROUTINE TO CLEAR GTJFN BLOCK.

GTJCLR:	MOVEI	T1,GTJBLK##	;CLEAR GETJFN BLOCK
	MOVEI	T2,GTJBLK##+.GJBFP
	PJRST	BLTCLR##	;CLEAR IT

	;ROUTINE TO SET GTJFN BLOCK. ENTER WITH "A" POINTING TO
	;DEVICE, "B" POINTING TO DIRECTORY, "C" POINTING TO
	;FILENAME, AND "D" POINTING TO DEFAULT EXTENSION. THE LEFT
	;HALF OF "A" CAN ALSO CARRY FLAGS. THESE FLAGS ARE DESCRIBED
	;IN THE GTJFN JSYS. THE LEFT HALF OF "D" SHOULD SPECIFY
	;THE GENERATION.

GTJSET:	HLLZM	A,GTJBLK##+.GJGEN ;SAVE FLAGS
	HRRZM	A,GTJBLK##+.GJDEV ;SAVE DEVICE
	SKIPE	GTJBLK##+.GJDEV	;DEVICE SUPPLIED?
	HRROS	GTJBLK##+.GJDEV	;YES--MAKE STRING POINTER
	MOVEM	B,GTJBLK##+.GJDIR ;PUT POINTER TO DIRECTORY
	MOVEM	C,GTJBLK##+.GJNAM ;SAVE NAME
	HRROM	D,GTJBLK##+.GJEXT ;AND EXTENSION
	HLRM	D,GTJBLK##+.GJGEN ;SAVE GENERATION NUMBER
	POPJ	P,

	PRGEND
	TITLE	WHEEL	ENABLE AND DISABLE WHEEL
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	ENBWHL,DISWHL,TSTWHL

	;ROUTINE TO ENABLE WHEEL PRIVS. RETURNS SKIP IF OK.
	;RETURNS NON-SKIP IF NOT OK.

ENBWHL:	MOVEI	T1,.FHSLF	;POINT TO US
	RPCAP			;READ OUR CAPABILITIES
	TXO	T3,SC%WHL	;SET WHEEL
	EPCAP			;AT LEAST TRY
	RPCAP			;READ THEM AGAIN
	TXNN	T3,SC%WHL	;OK?
	 ERROR	CPOPJ##,<UNABLE TO SET WHEEL PRIVILEDGES>
	JRST	CPOPJ1##	;OK--SKIP

	;ROUTINE TO UNSET WHEEL. RETURNS NON-SKIP ALWAYS

DISWHL:	MOVEI	T1,.FHSLF	;POINT TO US
	RPCAP			;GET OUR CAPABILITIES
	TXZ	T3,SC%WHL	;UNSET WHEEL
	EPCAP			;TRY
	POPJ	P,		;OK

	;ROUTINE TO ESTABLISH OUR PRIVS. RETURN NON-SKIP IF NO
	;WHEEL	AND SKIP IF WHEEL.

TSTWHL:	MOVEI	T1,.FHSLF	;POINT TO US
	RPCAP			;GET OUR CAPABILITIES
	TXNN	T3,SC%WHL	;WHEEL SET?
	POPJ	P,		;NO
	JRST	CPOPJ1##	;;YES--SKIP

	PRGEND
	TITLE	TABLE	PUT ENTRIES IN TABLES AND REMOVE THEM
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	NMITAB,NMOTAB

	;ROUTINE TO PUT A NAME IN A COMMAND TABLE. ENTER WITH 
	;T1 POINTING TO NAME TABLE AND T2 CONTAINING NEW ENTRY
	;TO BE PUT IN THE TABLE. RETURNS DOUBLE SKIP IF OK OR 
	;SKIP IF ALREADY THERE, OR NON-SKIP IF ERROR.

NMITAB:	TBADD			;PUT IT IN
	ERJMP	.+2		;COULD NOT
	PJRST	CPOPJ2##	;ELSE DOUBLE SKIP
	MOVEI	T1,.FHSLF	;GET ERROR CODE
	GETER			;GET IT
	HRRZS	T2		;JUST THE ERROR CODE
	CAIE	T2,TADDX2	;ALREADY THERE?
	PJRST	JSERPJ##	;NO--TABLE FULL
	PJRST	CPOPJ1##	;ELSE SKIP

	;ROUTINE TO REMOVE ENTRY FROM COMMAND TABLE. ENTER WITH
	;T1 POINTING TO TABLE AND T2 POINTING TO NAME TO BE
	;DELETED. RETURNS +1 ALWAYS

NMOTAB:	PUSH	P,T1		;SAVE ADDRESS OF TABLE
	TBLUK			;FIND ENTRY
	TXNE	T2,TL%NOM	;THERE?
	JRST	NMOERR		;NO
	MOVE	T2,T1		;POINT TO ENTRY
	POP	P,T1		;POINT TO TABLE
	TBDEL			;DELETE IT
	POPJ	P,

NMOERR:	POP	P,(P)		;ADJUST STACK
	ERROR	CPOPJ##,<NAME NOT IN TABLE>

	PRGEND
	TITLE	SPCBUF	JUST A BUFFER FULL OF SPACES
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	SPCBUF

	;JUST A BUFFER FULL OF SPACES

SPCBUF:	REPEAT ^D40,<ASCII /     />

	PRGEND
	TITLE	BLTS	BLT OVER MEMORY
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	BLTCLR,BLTONE,BLTIT

	;ROUTINE TO CLEAR MEMORY. ENTER WITH LOWER ADDRESS IN T1
	;AND UPPER ADDRESS IN T2.

BLTCLR:	SETZM	(T1)		;CLEAR FIRST LOCATION
	PJRST	BLTIT		;CLEAR IT ALL

	;ROUTINE TO SET ONES TO MEMORY. ENTER WITH T1 POINTING TO
	;LOWER ADDRESS AND T2 POINTING TO UPPER ADDRESS.

BLTONE:	SETOM	(T1)		;SET FIRST WORD TO ONES
	PJRST	BLTIT		;DO IT ALL

	;ROUTINE TO SPREAD A WORD ACCROSS MEMORY. ENTER WITH LOWER
	;ADDRESS IN T1 AND UPPER ADDRESS IN T2. FIRST WORD OF
	;MEMORY SHOULD BE SET TO DESIRED VALUE.

BLTIT:	HRLS	T1		;MAKE A BLT POINTER
	AOS	T1		;FOR THE BLT
	BLT	T1,(T2)		;DO IT
	POPJ	P,

	PRGEND
	TITLE	LODJFN	LOAD T1 FROM OUTP OR INP
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	OUTPGT,INPGT

	;ROUTINE TO LOAD T1 FROM OUTP AND RESTORE OUTP FROM
	;T1 AT THE NEXT POPJ.

OUTPGT:	POP	P,(P)		;ADJUST THE STACK
	MOVE	T1,OUTP		;SET UP T1 FROM OUTP
	PUSHJ	P,@1(P)		;RETURN TO INLINE CODE
	 JRST	RSOUTP		;NON-SKIP RETURN
	 SKIPA			;SKIP RETURN
	AOS	(P)		;GIVE SKIPS
	AOS	(P)		;ALL OF THEM
RSOUTP:	MOVE	OUTP,T1		;SAVE T1
	POPJ	P,		;RETURN

	;ROUTINE TO LOAD T1 FROM INP AND RESTORE INP FROM
	;T1 AT THE NEXT POPJ.

INPGT:	POP	P,(P)		;ADJUST THE STACK
	MOVE	T1,INP		;SET UP T1 FROM INP
	PUSHJ	P,@1(P)		;RETURN TO INLINE CODE
	 JRST	RSINP		;NON-SKIP RETURN
	 SKIPA			;SKIP RETURN
	AOS	(P)		;GIVE SKIPS
	AOS	(P)		;ALL OF THEM
RSINP:	MOVE	INP,T1		;SAVE T1
	POPJ	P,		;RETURN

	PRGEND
	TITLE	SAVT	PRESERVE T1-T4
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	SAVT

	;ROUTINE TO PRESERVE T1-T4. ENTER WITH PUSHJ. T1-T4
	;ARE SAVED ON THE STACK. THEY ARE RESTORED AT THE NEXT
	;POPJ. SUPPORTS NON-SKIP, SKIP AND DOUBLE SKIP RETURNS.

SAVT:	EXCH	T1,(P)		;SAVE T1, AND GET PC
	PUSH	P,T2		;SAVE T2
	PUSH	P,T3		;SAVE T3
	PUSH	P,T4		;SAVE T4
	MOVEM	T1,1(P)		;SAVE OLD PC
	MOVE	T1,-3(P)	;RETORE T1
	PUSHJ	P,@1(P)		;RETURN TO INLINE CODE
	 JRST	RESTT		;NON-SKIP RETURN
	 SKIPA			;CPOPJ1
	AOS	-4(P)		;CPOPJ2
	AOS	-4(P)		;IT MAY SEEM MESSY BUT...
RESTT:	POP	P,T4		;RESTORE T4
	POP	P,T3		;RESTORE T3
	POP	P,T2		;RESTORE T2
	POP	P,T1		;AND T1
	POPJ	P,		;OK


	PRGEND
	TITLE	POPS	VARIOUS PUSH AND POP ROUTINES
	SUBTTL	C.MITCHELL 1977. ROUTINES WRITTEN AT COLOGNE.

	SEARCH	MONSYM,MACSYM,CMLBSM

	IFNDEF	.PSECT,<
	.DIRECT	.XTABM>

	SALL

	ENTRY	T21PPJ,T1POPJ,T2POPJ,CPOPJ,CPOPJ1,CPOPJ2,CPOPJ3
	ENTRY	T1PPJ1,T1PPJ2,T1PPJ3

	;ALL SORTS OF POPJ'S

CMLVER::CMSYMV			;PUT VERSION NUMBERS HERE.

T21PPJ:	POP	P,T2		;RESTORE T2, THEN..
T1POPJ:	POP	P,T1		;RESTORE T1
	POPJ	P,		;RETURN

T1PPJ3:	POP	P,T1		;RESTORE T1
CPOPJ3:	AOSA	(P)		;BUMP POINTER
T1PPJ2:	POP	P,T1		;RESTORE T1
CPOPJ2:	AOSA	(P)		;BUMP POINTER
T1PPJ1:	POP	P,T1		;RESTORE T1
CPOPJ1:	AOSA	(P)		;BUMP POINTER
T2POPJ:	POP	P,T2		;RESTORE T2
CPOPJ:	POPJ	P,		;RETURN

	END