MACDEF	MACRO M1110  21-AUG-78 22:51

TABLE OF CONTENTS



    32-    5	MACRO DEFINITION SEMANTICS

    33-   29	MACRO DIRECTIVE

    34-   73	FREEUP	DEALLOCATE MACRO STORAGE

    35-  117	DELETE MACRO DEFINITION AND NAME FROM TABLE

    36-  163	MARGSC	SCAN MACRO FORMAL ARGUMENTS

MACDEF	MACRO M1110  21-AUG-78 22:51  PAGE 26





      1						.IDENT	\X03.11\

      2					;

      3					; COPYRIGHT (C) 1977, 1978

      4					; DIGITAL EQUIPMENT CORPORATION, MAYNARD MASSACHUSETTS 01754

      5					;

      6					; THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ON A SINGLE

      7					; COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH THE INCLUSION OF THE

      8					; ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE, OR ANY OTHER COPIES THEREOF,

      9					; MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON

     10					; EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO THESE LICENSE

     11					; TERMS.  TITLE TO AND OWNERSHIP OF THE SOFTWARE SHALL AT ALL TIMES

     12					; REMAIN IN DEC.

     13					;

     14					; THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE

     15					; AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT

     16					; CORPORATION.

     17					;

     18					; DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS

     19					; SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

     20					;

     21

     22					;++

     23					; FACILITY:	VAX-11 MACRO OBJECT MODULE LIBRARY "MAR.OLB"

     24					;

     25					; ABSTRACT:	THIS MODULE IS PART OF THE VAX-11 MACRO ASSEMBLER, ITS DESCRIPTION

     26					;		IS ON THE FOLLOWING PAGE.

     27					;

     28					;

     29					; ENVIRNOMENT:	VAX-11 MACRO RUNS ON ANY VAX-11 WITH COMPATIBILITY MODE, UNDER

     30					;		THE CME (COMPATIBILITY MODE EMULATOR) OF VAX/VMS OR ON A PDP-11

     31					;		WITH EXTENDED INSTRUCTIONS UNDER RSX-11/M.

     32					;

     33					; AUTHOR:	STEVE POULSEN, CREATION DATE:  22-JUL-76

     34					;		DALE A. ROEDGER, 10-JAN-77 - 19-DEC-77

     35					;		DAVE N. CUTLER

     36					;		BENN L. SCHREIBER

     37					;

     38					; MODIFIED BY:

     39					;

     40					;--

     41					.IF NDF $DATA$

MACDEF	MACRO M1110  21-AUG-78 22:51  PAGE 32





      1						.TITLE	MACDEF

      2	000000					.PSECT	MACDEF

      3						.GLOBL	MACRO,DELETE

      4

      5						.SBTTL	MACRO DEFINITION SEMANTICS

      6					;

      7					; THESE ROUTINES DEFINE AND INTERPRET MARS MACROS.  WHEN A MACRO

      8					; DIRECTIVE IS ENCOUNTERED DURING THE FIRST PASS, THE 'MACRO'

      9					; ROUTINE IS CALLED TO HANDLE THE DEFINITION OF THE MACRO.  FIRST,

     10					; THE HEADER -- THE MACRO NAME AND ARGUMENTS -- ARE SCANNED, AND THE

     11					; ARGUMENT NAMES ARE RECORDED IN A SPECIAL TEMPORARY SYMBOL TABLE.

     12					; THEN THE BODY OF THE MACRO DEFINITION IS SCANNED FOR THESE ARGUMENTS.

     13					; AS THE LINES ARE SCANNED, THEY ARE COPIED INTO CORE AFTER THE TEMPORARY

     14					; ARGUMENT NAME SYMBOL TABLE.  WHEN AN ARGUMENT IS DISCOVERED, ITS NAME

     15					; IS REPLACED BY A BYTE CONTAINING A SPECIAL SYMBOL ('MCARG') FOLLOWED

     16					; BY A BYTE CONTAINING THE ARGUMENT NUMBER.  AFTER THE END OF THE MACRO

     17					; BODY IS REACHED, THE LINES MAKING UP THE TEXT OF THE MACRO ARE MOVED

     18					; UP IN CORE OVER THE TEMPORARY SYMBOL TABLE WHICH IS NO LONGER NEEDED.

     19					;

     20					; EACH LINE OF THE TEXT STARTS WITH A WORD CONTAINING THE LENGTH IN

     21					; BYTES OF THE MACRO LINE.  A ZERO LENGTH ENDS THE LIST.

     22					;

     23					; WHEN THE MACRO IS EXPANDED, THE LINES ARE READ FROM CORE AND ARE

     24					; COPIED INTO THE INPUT LINE BUFFER ('LINEBF').  WHEN AN ARGUMENT IS

     25					; REACHED, IT IS REPLACED BY THE REAL ARGUMENT SPECIFIED IN THE MACRO

     26					; CALL.

     27					;

MACDEF	MACRO M1110  21-AUG-78 22:51  PAGE 33

MACRO DIRECTIVE



     29					.SBTTL	MACRO DIRECTIVE

     30

     31	000000				MACRO:	;(DBG)			; DIRECTIVE = KMACRO

     32	000000					IF LS.MD+SYMVL2 IS EQ THEN		; LIST MACRO DEF?

     33	000006					    OUT #I.FLAG,<#0,#LISTIT>		; OUTPUT NO LIST FLAG

     34	000026					END

     35	000026					CALL SYMSCN				; GET MACRO NAME

     36	000032					IF R3 IS EQ THEN			; NO NAME FOUND?

     37	000036					    CALL ERORPT,#ILGMNM			; ILLEGAL MACRO NAME

     38	000046					    RETURN				; EXIT

     39	000050					END;IF

     40	000050					PUSH	CORLST				; SAVE RECLAIMED MEMORY PTR

     41	000054					LET CORLST	:= 0			; ASSUME NO HOLES IN SYMBOL TBL

     42	000060					LET R2		:= R2 + #MACNAM		; POINT TO MACRO HASH TABLE

     43	000064					LET INSERT	:= TRUE			; ADD NEW NAME

     44	000072					CALL FINDSYM				; IN MACRO SYMBOL TABLE

     45	000076					POP	CORLST				; RESTORE PTR. TO RECLAIMED MEM.

     46	000102					CALL FREEUP				; DEALLOCATE OLD MACRO

     47	000106					LET MCNAM	:= R2			; POINTER TO MACRO'S NAME

     48	000112					PUSH	CORLST				; SAVE RECLAIMED MEMORY PTR

     49	000116					LET CORLST	:= 0			; ASSUME NO HOLES IN SYMBOL TBL

     50	000122					LET SYMVL2(R2)	:= 0			; NO CREATED SYMBOLS

     51	000126					SPNOR					; IGNORE BLANKS

     52	000132					IF CHAR EQ #COMMA THEN CALL GETCHR	; SKIP OVER COMMA IF ANY

     53	000146					CALL MARGSC				; SCAN THE FORMAL ARGUMENTS

     54	000152					LET R2		:= MCNAM		; GET ADDRESS OF MACRO NAME BLK

     55	000156					LET SYMVL1(R2)	:= FREEPT		; LOAD POINTER TO MACRO BODY

     56	000164					LET SYMSEG(R2)	:B= MCARGC		; SAVE ARGUMENT COUNT

     57	000172					LET CHAR	:= #CR			; FORCE READING OF NEW LINE

     58	000200					CALL GETCHR				; TO INITIALIZE BODY

     59	000204					CALL BDYSCN				; SCAN BODY OF MACRO

     60	000210					CALL SYMSCN				; CHECK FOR .ENDM NAME

     61	000214					IF R3 IS NE THEN			; FOUND!

     62	000220					    LET R2	:= R2 + #MACNAM		; LOOK IN MACRO NAME TABLE

     63	000224					    LET INSERT	:= FALSE		; DON'T ADD NAME

     64	000230					    CALL FINDSYM			; LOOK FOR NAME

     65	000234					    IF R2 NE MCNAM THEN			; NO MATCH

     66	000242						CALL ERORPT,#MCWRNG		; STATEMENT ENDS WRONG MACRO

     67	000252					    END

     68	000252					END

     69	000252					POP	CORLST				; RESTORE PTR. TO RECLAIMED MEM.

     70	000256					RETURN

     71

MACDEF	MACRO M1110  21-AUG-78 22:51  PAGE 34

FREEUP	DEALLOCATE MACRO STORAGE



     73					.SBTTL	FREEUP	DEALLOCATE MACRO STORAGE

     74					;

     75					; DEALLOCATE OLD MACRO TEXT AND ARGS BY PLACING THEM ON FREE CORE LIST.

     76					; (CORLST)

     77					; INPUT PARAMETERS:

     78					; R2 IS ADDRESS OF MACRO NAME BLOCK

     79					;

     80

     81	000260				FREEUP::	;(DBG)			; DEALLOCATE OLD MACRO TEXT

     82	000260					LET R3		:B= SYMLEN(R2)		; NAME LENGTH

     83	000264					LET R3	:= R3 + #SYMCHRS+1 + R2 OFF.BY #1 ; ADDRESS OF BLOCK TO DEALL.

     84	000276					LET R0		:= SYMVL1(R2)		; POINT TO MACRO TEXT

     85	000302					IF RESULT IS NE THEN			; ANY?

     86	000304					    WHILE (R0) IS NE			; FIND LAST LINE

     87	000310						LET R0	:= R0 + (R0) +1 OFF.BY #1

     88	000320					    END

     89	000322					    LET R0	:= R0 + #2		; PLUS WORD OF ZERO AT END

     90	000326					    LET R1	:= FREEPT		; POINT TO FREE CORE

     91	000332					    IF R0 EQ R1 THEN			; DEALLOCATING AT END?

     92	000336						PUSH	R2

     93	000340						LET R2 := INPUTP		; POINT TO INPUT STACK

     94	000344						REPEAT

     95	000344						    IF M.NXTL(R2) HIS (R3) THEN ; CAN'T DEALL MACRO BEING EXPAND

     96	000352							LEAVE

     97	000354						    ELSE

     98	000356							LET R2 := M.LINK(R2)	; POINT TO NEXT MACRO NEST

     99	000362						    END

    100	000362						UNTIL R2 EQ M.LINK(R2)		; UNTIL END OF CHAIN

    101	000370						POP	R2			; RESTORE REGISTER

    102	000372					    END

    103	000372					    LET R1	:= (R3)			; POINT TO NEW HOLE

    104	000374					    LET (R1)+	:= CORLST		; LINK TO PREVIOUS HOLE

    105	000400					    LET CORLST	:= (R3)			; THIS HOLE IS NOW HEAD OF LIST

    106	000404					    LET R0	:= R0 - CORLST		; GET SIZE OF HOLE (IN BYTES)

    107	000410					    LET (R1)	:= R0			; FILL IN SIZE

    108	000412					    LET SYMVL1(R2) := 0			; CLEAR TEXT POINTER

    109	000416					    LET SYMSEG(R2) :B= 0		; CLEAR ARG COUNT

    110	000422					END

    111	000422					IF R3 EQ FREEPT THEN			; NEW SYMBOL?

    112	000430					    LET FREEPT	:= FREEPT + #2		; ALLOCATE WORD FOR POINTER

    113	000436					END

    114	000436					LET  (R3)+	:= FREEPT		; LOAD POINTER TO KEYWORD SPOT

    115	000442					RETURN

MACDEF	MACRO M1110  21-AUG-78 22:51  PAGE 35

DELETE MACRO DEFINITION AND NAME FROM TABLE



    117					.SBTTL	DELETE MACRO DEFINITION AND NAME FROM TABLE

    118					;

    119					; THIS ROUTINE PICKS UP THE MACRO NAME, FINDS THE ENTRY IN THE MACRO NAME

    120					; HASH TABLE, DELETES THE MACRO BODY BY CALLING "FREEUP" AND THE REMOVES

    121					; THE MACRO NAME BLOCK FROM THE HASH TABLE.

    122					;

    123	000444				DELETE:	;(DBG)				; DIRECTIVE = KMDELETE

    124	000444					LET TEMP0	:= #0			; COUNT MACROS DELETED

    125	000450				    REPEAT					; LOOP UNTIL END OF LINE

    126	000450					CALL SYMSCN				; GET MACRO NAME

    127	000454					IF R3 IS NE THEN			; LEGAL NAME?

    128	000460					    LET R2	:= R2 + #MACNAM		; USE MACRO NAME TABLE

    129	000464					    LET INSERT	:= FALSE		; JUST FIND NAME

    130	000470					    CALL FINDSYM			;

    131	000474					    IF R2 IS NE THEN			; NAME FOUND

    132	000500						LET TEMP0	:= TEMP0 +1	; COUNT THIS MACRO BEING DELETED

    133	000504						LET @SYMLNK	:= (R2)		; REMOVE THIS MACRO BLOCK

    134	000510						CALL FREEUP			; DELETE MACRO STORAGE

    135	000514						LET R3	:B= SYMLEN(R2)		; LENGTH OF MACRO NAME

    136	000520						LET R3	:= R3 + #SYMCHRS+3 OFF.BY #1 ; CACULATE LENGTH OF NAME BLK

    137	000530						LET 2(R2)  := R3		; STORE LENGTH OF NEW HOLE

    138	000534						LET (R2)   := CORLST		; ADD NEW HOLE ON FRONT OF LIST

    139	000540						LET CORLST := R2		; LIST HEAD POINTS TO THIS BLK

    140	000544					    END

    141	000544					END

    142	000544					IF CHAR NE #CR AND CHAR NE #SEMI THEN	; SKIP OVER DELIMITER

    143	000564					    CALL GETCHR

    144	000570					END

    145	000570				    UNTIL CHAR EQ #CR OR CHAR EQ #SEMI		; UNTIL EOL

    146	000610					IF CORLST IS NE THEN			; TRY TO ADD HOLES TO FREE POOL

    147	000616				GARBAG:	    LET R0	:= CORLST		; POINT TO FIRST HOLE IN CHAIN

    148	000622					    LET R2	:= #CORLST		; KEEP ADDRESS OF PREVIOUS BLOCK

    149	000626					    WHILE R0 IS NE			; LOOP UNTIL END OF CHAIN

    150	000632						LET R1	:= R0 + 2(R0)		; GET ADDRESS OF BYTE AFTER HOLE

    151	000640						IF R1 EQ FREEPT THEN		; IS HOLE CONTIGUOUS TO FREE POOL?

    152	000646						    LET FREEPT	:= R0		; ADD HOLE TO FREE POOL

    153	000652						    LET (R2)	:= (R0)		; LINK AROUND THIS HOLE

    154	000654						    GOTO GARBAG			; START AT BEGINNING OF CHAIN

    155	000656						END;IF

    156	000656						LET R2	:= R0			; UPDATE PREV. BLOCK POINTER

    157	000660						LET R0	:= (R0)			; TRY NEXT HOLE ON CHAIN

    158	000662					    END;W

    159	000664					END;IF

    160	000664					OUT #I.PRIL,<TEMP0,#0>			; PRINT NUMBER OF MACROS DELETED

    161	000704					RETURN

MACDEF	MACRO M1110  21-AUG-78 22:51  PAGE 36

MARGSC	SCAN MACRO FORMAL ARGUMENTS



    163					.SBTTL	MARGSC	SCAN MACRO FORMAL ARGUMENTS

    164					;

    165					;

    166					; THIS ROUTINE BUILDS A LIST OF MACRO ARGUMENTS.  THE LIST IS POINTED

    167					; TO BY 'MCARGP', AND 'MCARGC' CONTAINS THE NUMBER OF ARGUMENTS FOUND.

    168					; THE ARGUMENTS MAY BE SEPARATED BY TABS, SPACES, OR COMMAS.

    169					;

    170

    171	000706				MARGSC::;(DBG)				; SCAN FORMAL ARGUMENTS

    172	000706					LET MCARGC	:= 0			; NO ARGS YET

    173	000712					LET MCARGP	:= 0			; POINTER TO NAME LIST

    174	000716					SPNOR					; IGNORE SPACES/TABS

    175	000722					IF CHAR EQ #CR THEN RETURN		; NO ARGS

    176

    177	000734					REPEAT					; ONCE PER ARG

    178	000734					    SPNOR				; SKIP BLANKS

    179	000740					    IF CHAR EQ #'? THEN			; CREATED SYMBOL?

    180	000750						CALL GETCHR			; SKIP OVER '?'

    181	000754						LET R0	:= MCNAM		; POINT TO MACRO NAME

    182	000760						LET R1	:= #1 SHIFT MCARGC	; SHIFT BY ARG # - 1.

    183	000770						LET SYMVL2(R0) := SYMVL2(R0) SET.BY R1 ; MARK CREATED SYMBOL

    184	000774						SPNOR				; IGNORE BLANKS

    185	001000					    END;IF

    186	001000					    LET R0	:= CHRTAB(R0)		; GET "TOKEN" FOR CHARACTER

    187	001004					    IF R0 EQ #SYMBOL OR R0 EQ #XSYMBL OR R0 EQ #SYMNUM THEN

    188	001026						CALL GETSYM			; ACCUMULATE SYMBOL NAME

    189	001032						LET R2		:= #MCARGP	; LINKED LIST OF ARG NAMES

    190	001036						LET INSERT	:= TRUE		; NO HASH VALUE IS USED

    191	001044						CALL FINDSYM			; INSERT THE NAME

    192	001050						LET MCARGC	:= MCARGC +1	; COUNT NEW ARG

    193	001054						LET SYMVL1(R2)	:= MCARGC	; FORMAL ARG VAL IS POS NUM

    194	001062						SPNOR				; SKIP BLANKS

    195	001066						IF CHAR EQ #'= THEN		; KEYWORD ARGUMENT ?

    196	001076						    LET SYMVL2(R2) := FREEPT	; POINT TO DEFAULT ARG

    197	001104						    CALL GETCHR			; SKIP OVER EQUAL SIGN

    198	001110						    CALL ARGSCN			; SCAN THE ARGUMENT

    199	001114						END

    200	001114						IF CHAR EQ #COMMA THEN		; SKIP OVER COMMA

    201	001124						    CALL GETCHR

    202	001130						END

    203	001130					    ELSE

    204	001132						LET MCARGC	:= MCARGC +1	; COUNT ARG ANYWAY

    205	001136						CALL ERORLN,#MCRGER		; ILLEGAL MACRO ARGUMENT NAME

    206	001146						REPEAT				; SKIP CHARS UNTIL ARG DELIMITER

    207	001146						    CALL GETCHR

    208	001152						UNTIL R0 EQ #COMMA OR R0 EQ #TAB OR R0 EQ #SPACE OR R0 EQ #CR

    209	001202						IF R0 EQ #COMMA THEN CALL GETCHR ; SKIP DELIMITER TOO

    210	001214					    END

    211	001214					UNTIL CHAR EQ #CR			; SCAN TO END OF LINE

    212	001224					RETURN

    213

    214		000001 			.END

MACDEF	MACRO M1110  21-AUG-78 22:51  PAGE 36-1

SYMBOL TABLE



ARGSCN= ****** GX	IIII  = 177777   	L26     001026R     002	PSECOP= 000016   	S.ODBG= 000040

BDYSCN= ****** GX	ILGMNM= ****** GX	L27     001132R     002	PSECV1= 000012   	S.REF = 000400

BLNK  = 000040   	INPUTP= ****** GX	L3      000252R     002	PSECV2= 000014   	S.TKMS= 000377

B0      000304R     002	INSERT= ****** GX	L30     001114R     002	RGTANG= 000076   	S.WEAK= 040000

B1      000344R     002	I.FLAG= ****** GX	L31     001130R     002	RTNVAL=%000000   	TAB   = 000011

B2      000450R     002	I.PRIL= ****** GX	L32     001214R     002	R6    =%000006   	TEMP0 = ****** GX

B3      000626R     002	LBLS0 = 000036   	L33     001202R     002	R7    =%000007   	TYPS0 = 000000

B4      000734R     002	LBLS1 = 000032   	L35     001214R     002	SEMI  = 000073   	TYPS1 = 000000

B5      001146R     002	LBLS2 = 000035   	L4      000252R     002	SKIPSP= ****** GX	TYPS2 = 000000

CHAR  = ****** GX	LBLS3 = 000034   	L5      000422R     002	SPACE = 000040   	TYPS3 = 000000

CHRTAB= ****** GX	LF    = 000012   	L6      000322R     002	SYMBOL= ****** GX	XSYMBL= ****** GX

CNT   = 000006   	LFTANG= 000074   	L7      000372R     002	SYMCHR= 000012   	$DIDDO= 000000

COMMA = 000054   	LISTIT= ****** GX	MACNAM= ****** GX	SYMFLA= 000002   	$E$   = 000001

CORLST= ****** GX	LOWCAS= 000140   	MACRO   000000RG    002	SYMLEN= 000011   	$F$   = 000000

CR    = 000015   	LPTLEN= 000074   	MARGSC  000706RG    002	SYMLIN= 000000   	$I$   = 000001

DELETE  000444RG    002	LS.MD = ****** GX	MCARGC= ****** GX	SYMLNK= ****** GX	$L    = 000006

ERORLN= ****** GX	L0      000026R     002	MCARGP= ****** GX	SYMMAX= 000017   	$LL   = 000005

ERORPT= ****** GX	L1      000050R     002	MCNAM = ****** GX	SYMNUM= ****** GX	$L$   = 000000

E0      000322R     002	L10     000356R     002	MCRGER= ****** GX	SYMSCN= ****** GX	$O$   = 000000

E1      000370R     002	L11     000362R     002	MCWRNG= ****** GX	SYMSEG= 000010   	$R    = 177777

E2      000610R     002	L13     000436R     002	M.ARGC= 000014   	SYMVL1= 000004   	$SV$  = 000001

E3      000664R     002	L14     000544R     002	M.ARGS= 000016   	SYMVL2= 000006   	$T    = 000037

E4      001224R     002	L15     000544R     002	M.END = 000012   	S.ABS = 004000   	$T1   = 000005

E5      001202R     002	L16     000570R     002	M.GETL= 000004   	S.ASN = 000200   	$T2   = 000004

FF    = 000014   	L17     000610R     002	M.IFLV= 000006   	S.DBG = 002000   	$Y$   = 177773

FINDSY= ****** GX	L2      000146R     002	M.IFVL= 000010   	S.DF  = 100000   	$Z$   = 000000

FREEPT= ****** GX	L21     000664R     002	M.LINK= 000000   	S.EPT = 000100   	$$S   = 000000

FREEUP  000260RG    002	L22     000664R     002	M.NXTL= 000002   	S.EXTN= 010000   	$$T   = 000036

GARBAG  000616R     002	L23     000656R     002	OUTFRA= ****** GX	S.GLOB= 020000   	$$TT  = 000034

GETCHR= ****** GX	L24     000734R     002	PSECCH= 000020   	S.LOCL= 001000   	.$T   = 000001

GETSYM= ****** GX	L25     001000R     002



. ABS.	000000	   000

      	000000	   001

MACDEF	001226	   002

ERRORS DETECTED:  0



VIRTUAL MEMORY USED:  11964 WORDS  ( 47 PAGES)

DYNAMIC MEMORY:  13332 WORDS  ( 51 PAGES)

ELAPSED TIME:  00:02:39

OBJ$:MACDEF,LIS$:MACDEF/-SP=SRC$:MD,COMMON,MACDEF

