Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-11 - 43,50535/macs.mac
There are no other files named macs.mac in the archive.
	UNIVERSAL MACS

	DEFINE WHENSK (TEST,THEN,ELSE,%ELSE,%FI) <
		TEST
		IFB <ELSE>, <JRST %FI>
		IFNB <ELSE>, <JRST %ELSE>
		THEN
		IFNB <ELSE>, <JRST %FI
			    %ELSE: ELSE>
		%FI: >

	DEFINE UNLJMP (TEST,THEN,ELSE,%ELSE,%FI) <
		IFB <ELSE>,<TEST %FI>
		IFNB <ELSE>,<TEST %ELSE>
		THEN
		IFNB <ELSE>,<JRST %FI
			     %ELSE:ELSE>
		%FI:  >

	DEFINE DO (CODE,%LOOP)
	<   %LOOP: CODE %LOOP
	>

	DEFINE WHLSKP (TEST,CODE,%LOOP,%OUT)
	<   %LOOP: TEST
	    JRST %OUT
	    CODE %LOOP
	    %OUT:
	>

	DEFINE UNTILJ (TEST,CODE,%LOOP,%OUT)
	<   %LOOP: TEST %OUT
	    CODE %LOOP
	    %OUT:
	>

	DEFINE ALTEND (LABEL,CODE,%END)
	<   JRST %END
	    LABEL: CODE
	    %END:
	>


	OPDEF CALL [PUSHJ 17,0]
	OPDEF RETURN [POPJ 17,0]
	DEFINE PROC (NAME) <NAME:>
	DEFINE MSG (TEXT) <OUTSTR[ASCIZ TEXT]>
	DEFINE MSGN (TEXT)
	<   OUTSTR [ASCIZ "
TEXT" ]
	>

	DEFINE PRMSG (TEXT) <PRSTR[ASCIZ TEXT] >
	DEFINE PRMSGN (TEXT)
	<   PRSTR [ASCIZ"
TEXT"]
	>

	DEFINE SETF(X) <TXO F,X>
	DEFINE UNSETF(X) <TXZ F,X>
	DEFINE SKPOFF(X) <TXNE F,X>
	DEFINE SKPON(X) <TXNN F,X>
	DEFINE CHNGF(X) <TXC F,X>
	DEFINE MOVEMM (A,B,R)
	<   MOVE R,A
	    MOVEM R,B
	>
	DEFINE MOVEIM (A,B,R)
	<   MOVEI R,A
	    MOVEM R,B
	>

	AC=16
	SP=17

	DEFINE SAVR(N)		; SAVE REGISTERS 1 TO N; USES REG AC
	<   IFL N-4,
	    <   PUSH SP,1
		IFG N-1, <PUSH SP,2>
		IFG N-2, <PUSH SP,3>
	    >
	    IFGE N-4,
	    <	HRLI AC,1
		HRRI AC,1(SP)
		ADJSP SP,N
		BLT AC,(SP)
	    >
	>

	DEFINE RESTOR (N)	; RESTORES REGISTERS 1 TO N; USES REG 16
	<    JSP 16,RSTOR##-N  >

	DEFINE RSTRET (N)	; RESTORES REGS.1 TO N AND RETURNS TO
				; ORIGINAL CALLING ADDRESS.
	<    JRST RSTRN##-N  >

	DEFINE REGDEF
	<  F=0	; FLAGS
	   S1=5		; "HIGHER LEVEL" WORK REGISTERS
	   S2=6
	   S3=7
	   S4=10
	   T1=11	; "LOWER LEVEL" WORK REGISTERS
	   T2=12
	   T3=13
	   T4=14
			; 16 IS USED BY "RESTOR"
	   SP=17	; STACK POINTER
	>

	DEFINE UPCASE (CHAR)
	<   CAIL CHAR,"a"		; LESS THAN LOWER CASE A?
	    CAILE CHAR,"z"		; LESS THAN OR EQUAL TO LOWER CASE Z?
	    SKIPA
	    TRZ CHAR,40		; UPPER CASIFY IT
	>

	DEFINE TXYZ (Y,Z)
	< IRP Y,
	    < IRP Z,
		<	DEFINE TX'Y'Z (AC,FLAGS)
			<  IFE FLAGS&777777B17,<TR'Y'Z AC,FLAGS >
			   IFN FLAGS&777777B17,<
				IFE FLAGS&777777B35,<TL'Y'Z AC,(FLAGS) >
				IFN FLAGS&777777B35,<TD'Y'Z AC,[FLAGS] >
			    >
			>
		 >
	    >
	>

	TXYZ <N,Z,O,C>,<E,N,A, >

	DEFINE CLEAR (LOC,LEN)
	; CLEARS LEN (GE 2) WORDS STARTING AT LOC
	; USES T1 AS WORK
	<   SETZM LOC
	    MOVE T1,[LOC,,LOC+1]
	    BLT T1,LOC+LEN-1
	>

	DEFINE MOVX (A,F)
	; MOVES A FLAG F INTO REGISTER A.
	<   IFE F&777777B17, <MOVEI A,F>
	    IFN F&777777B17, <
		IFE F&777777B35, <MOVSI A,(F) >
		IFN F&777777B35, <MOVE A,[F] >
	    >
	>

	DEFINE SETFIL (C,MODE,OBUF,IBUF,ARGBLK,FLAG)
	<   OPEN C, [ MODE
		      SIXBIT/DSK/
		      OBUF,,IBUF ]
	    JRST [ MSGN <ERROR IN OPENING CHANNEL>
		   EXIT  ]
	    IFNB <FLAG>,
	    <	DEFINE X
		<   MOVEI S1,ARGBLK
		    CALL RDFNAM
		    JUMPE S1, [ MSGN <ERROR IN FILENAME>
				EXIT	]
		    MSGN <ENTER PROJECT NUMBER >
		    INCHWL CH
		    CALL OCTIN
		    CALL GETLF
		    HRLM T1,ARGBLK+3
		    MSGN <ENTER PROGRAMMER NUMBER >
		    INCHWL CH
		    CALL OCTIN
		    CALL GETLF
		    HRRM T1,ARGBLK+3
		>
		IFE FLAG-1, <X>
		IFN FLAG-1, < WHENSK <SKIPE ARGBLK>,<X> >
	    >
	    SETZM ARGBLK+2
	    IFN IBUF, <LOOKUP C,ARGBLK>
	    IFE IBUF, <ENTER  C,ARGBLK>
	    JRST [ MSGN <ERROR IN LOOKUP OR ENTER>
			EXIT  ]
	>

	DEFINE DEFFIL (C,MODE,DEV,OBUF,IBUF,NAME,EXT,PROT,ARGBLK,
			PPN,SFD1,SFD2,PATH)
		; THIS MACRO OPENS A CHANNEL THEN DOES A LOOKUP OR ENTER
		; ON A SPECIFIED FILE.
		; C IS CHANNEL NUMBER, MODE IS DATA MODE,
		; DEV IS DEVICE, E.G. DSKB,
		; ONLY ONE OF OBUF AND IBUF SHOULD BE SET (THE OTHER
		;   BEING 0) - THESE ARE THE BUFFER CONTROL BLOCK ADDRESSES,
		; NAME IS ADDRESS OF A WORD CONTAINING FILENAME,
		; EXT IS ADDRESS OF A WORD CONTAINING FILE EXTENSION,
		; PROT IS ADDRESS OF A WORD. FOR LOOKUP'S THIS WORD SHOULD
		;   CONTAIN 0, ON EXIT IT WILL CONTAIN THE PROTECTION
		;   CODE IN BITS 0-8. FOR ENTER'S THIS WORD SHOULD CONTAIN
		;   THE PROTECTION REQUIRED (BITS 0-8) OR 0 FOR DEFAULT.
		;   CANNOT HAVE [0] AS PROT.
		; ARGBLK IS ADDRESS OF A 4 WORD BLOCK TO BE USED AS WORK.
		; THE FOLLOWING ITEMS MAY ALL BE OMMITTED, IN WHICH
		;   CASE THE FILE IS DEFINED IN THE CURRENT PATH:
		; PPN IS ADDRESS OF A WORD CONTAINING THE PPN (IF IT
		;   CONTAINS 0 THEN OWN PPN; IF IT CONTAINS A VALUE LESS
		;   THAN 0, THEN OWN PPN AND CURRENT PATH (SO SFD1,SFD2,
		;   PATH THEN IGNORED).
		; SFD1 AND SFD2 ARE ADDRESSES OF WORDS CONTAINING NAMES
		;   OF SUB-FILE DIRECTORIES, (OR CONTAINING 0),
		; PATH IS ADDRESS OF A 6 WORD BLOCK FOR USE AS WORK.
		; NOTES: (I) THE MACRO REQUIRES A LABEL "ERROPN" FOR USE
		;   IF THE OPEN UUO FAILS.
		; (II) THE VALUES IN PPN,SFD1,SFD2 CAN BE READ AND SET UP
		;   USING THE PROC "RDPATH".
		; (III) THE ARGS PPN,SFD1,SFD2,PATH CAN ALL BE OMMITTED
		;    (ALL AT ONCE, NOT INDIVIDUALLY) IN WHICH CASE THE
		;    FILE WILL BE IN OWN PPN AND CURRENT PATH.
		; (IV) T1 IS RETURNED AS -1 IF SUCCESSFUL, ELSE AS
		;    THE LOOKUP/ENTER ERROR CODE

	<   OPEN C, [MODE
		     SIXBIT/DEV/
		     OBUF,,IBUF ]
	    JRST ERROPN
	    MOVEMM NAME,ARGBLK,T1
	    MOVEMM EXT,ARGBLK+1,T1
	    MOVEMM PROT,ARGBLK+2,T1
	    SETZM ARGBLK+3
	    IFNB <PPN>,
	    <	WHENSK <SKIPGE PPN>,
		<   MOVEI T1,PATH
		    MOVEM T1,ARGBLK+3
		    MOVNI T1,2
		    MOVEM T1,PATH
		    MOVEI T1,1
		    MOVEM T1,PATH+1
		    MOVEMM PPN,PATH+2,T1
		    MOVEMM SFD1,PATH+3,T1
		    MOVEMM SFD2,PATH+4,T1
		    SETZM PATH+5 >
	    >
	    MOVNI T1,1
	    IFN IBUF,<LOOKUP C,ARGBLK>
	    IFE IBUF,<ENTER C,ARGBLK>
	    HRRZ T1,ARGBLK+1	; GET ERROR CODE
	    MOVEMM ARGBLK+2,PROT,T2
	>

	DEFINE DEFFL2 (C,MODE,DEV,OBUF,IBUF,NAME,EXT,PROT,ARGBLK,
			PPN,SFD1,SFD2,PATH,NBUF)
		; AS DEFFIL BUT DEV  IS ADDRESS OF A LOCATION
		; CONTAINING SIXBIT DEVICE NAME, AND NBUF IS NUMBER OF
		; BUFFERS TO SET UP (0 FOR DEFAULT)

	<   MOVEI T1,MODE
	    MOVEM T1,ARGBLK
	    MOVEMM DEV,ARGBLK+1,T1
	    MOVEMM [OBUF,,IBUF],ARGBLK+2,T1
	    OPEN C,ARGBLK
	    JRST ERROPN
	    IFN IBUF,<INBUF C,NBUF>
	    IFE IBUF,<OUTBUF C,NBUF>
	    MOVEMM NAME,ARGBLK,T1
	    MOVEMM EXT,ARGBLK+1,T1
	    MOVEMM PROT,ARGBLK+2,T1
	    SETZM ARGBLK+3
	    IFNB <PPN>,
	    <	WHENSK <SKIPGE PPN>,
		<   MOVEI T1,PATH
		    MOVEM T1,ARGBLK+3
		    MOVNI T1,2
		    MOVEM T1,PATH
		    MOVEI T1,1
		    MOVEM T1,PATH+1
		    MOVEMM PPN,PATH+2,T1
		    MOVEMM SFD1,PATH+3,T1
		    MOVEMM SFD2,PATH+4,T1
		    SETZM PATH+5 >
	    >
	    MOVNI T1,1
	    IFN IBUF,<LOOKUP C,ARGBLK>
	    IFE IBUF,<ENTER C,ARGBLK>
	    HRRZ T1,ARGBLK+1	; GET ERROR CODE
	    MOVEMM ARGBLK+2,PROT,T2
	>

	END