0% found this document useful (0 votes)
256 views

Machine Independent Macro Processor Features

The document discusses features of a machine-independent macro processor including: 1) Concatenation of macro parameters before or after expansion 2) Generation of unique labels to avoid duplication 3) Conditional expansion using IF-ELSE-ENDIF and WHILE-ENDW constructs 4) Keyword macro parameters to specify arguments in any order for macros with many parameters

Uploaded by

gjaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
256 views

Machine Independent Macro Processor Features

The document discusses features of a machine-independent macro processor including: 1) Concatenation of macro parameters before or after expansion 2) Generation of unique labels to avoid duplication 3) Conditional expansion using IF-ELSE-ENDIF and WHILE-ENDW constructs 4) Keyword macro parameters to specify arguments in any order for macros with many parameters

Uploaded by

gjaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Macro processor

Machine independent macro


processor features

1
● 1. Concatenation of macro parameters
● 2. Generation of unique labels
● 3. Conditional macro expansion
● 4. Keyword macro parameters

2
1. Concatenation of Macro Parameters

● Pre-concatenation
» LDA X&ID1
● Post-concatenation
» LDA X&ID→1
● Example: Figure 4.6

3
2. Generation of Unique Labels
SUM MACRO &X,&Y
START
LDA &X LDA &P
LOOP COMP B LOOP COMP B
JLT LOOP JLT LOOP
….. …..
MEND
LDA &M
LOOP COMP B
START JLT LOOP
SUM P,Q …..
SUM M,N
DUPLICATION
END
OF LABELS!!!
4
SUM MACRO &X,&Y
START
LDA &X LDA &P
COMP B COMP B
JLT *-3 JLT *-3
….. …..
MEND
LDA &M
COMP B
START JLT *-3
SUM P,Q …..
SUM M,N
NOT SUITABLE
END
FOR LONG JUMPS
5
Unique Labels
SUM MACRO &X,&Y START
LDA &X LDA &P
$LP COMP B $AALP COMP B
JLT $AALP
JLT $LP
………
…..
MEND
LDA &M
START $ABLP COMP B
JLT $ABLP
SUM P,Q
……..
SUM M,N END
END
6
● Replace symbol $ with $AA, $AB, $AC…… for
each invocation .
● There is no chance of label duplication here.

7
3. Conditional Macro Expansion

● IF-ELSE-ENDIF
● WHILE-ENDW
● Macro-time variables

8
SUM MACRO &T,&X,&Y START
IF (&T EQ 1)
LDA &X LDA &P
ELSE
LDA &N
LDA &Y
ENDIF END
MEND

START
SUM 1,P,Q
SUM 0,M,N
END 9
● Macro-time variables
» any symbol that begins with the character &
and that is not a macro parameter
» macro-time variables are initialized to 0
» macro-time variables can be changed with their
values using SET

10
SUM MACRO &T,&X,&Y
IF (&T EQ 1)
&S SET 1
ENDIF START
IF (&S EQ 1)
LDA &X LDA &P
ELSE
LDA &N
LDA &Y
ENDIF END
MEND

START
SUM 1,P,Q
SUM 0,M,N
END
11
SUM MACRO &LIMIT,&X
&CTR SET 1

WHILE (&CTR LE &LIMIT) START


LDA &X
&CTR SET &CTR+1 LDA &P
LDA &P
ENDW

MEND LDA &M

START END
SUM 2,P
SUM 1,M
END
12
4. Keyword Macro Parameters

● If a macro has a large number of


parameters, and only a few of these are
given values in a typical invocation, a
different form of parameter specification
called Keyword parameters can be used.

13
SUM MACRO &A=1,&B=2,&C=3,&D=,&E=5,&F=,&G=7,&H=8
………
START
SUM 10,’ ‘,100,’ ‘,’ ‘, ’ ‘, ’ ‘ ,’ ‘
SUM ‘ ‘,20,10,’ ‘,’ ‘, ’ ‘, ’ ‘, 30

START
SUM A=10,C=100 KEYWORD MACRO
PARAMETERS
SUM C=10,H=30,B=20

14
● Each argument value is written with a keyword that
names the corresponding parameter.
● Arguments may appear in any order.
● Each keyword parameter is followed by an equal
sign. (giving default value is optional)

15

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy