ICS 331: System Software (981)
Quiz # 6
Date: November 29, 1998 Time: 20 minutes
Question 1: (8 Points)
Given the following macro definition:
TESTMAC MACRO &ARG1, &ARG2, &ARG3, &ARG4
IF (&ARG1 NE &ARG4)
$LAB1 LDA #&ARG2
ELSE
$LAB2 LDA &ARG3
ENDIF
MEND
Generate the expanded source of the following assembly program:
COPY |
START |
0 |
COPY |
START |
0 |
CLEAR |
A |
CLEAR |
A |
||
TESTMAC |
2, X, Y, 1 |
. |
TESTMAC |
2, X, Y, 1 |
|
ADD |
Y |
AALAB1 |
LDA |
#X |
|
X |
RESW |
ADD |
Y |
||
Y |
RESW |
X |
RESW |
||
END |
X |
RESW |
|||
END |
Question 2: (6 Points)
List three advantages of using a general-purpose macro processor?
Question 3: (6 Points)
Briefly explain why the algorithm in the textbook cannot handle recursive macro calls.
The problem arises in the EXPAND
and PROCESSLINE procedures. During a recursive call to a macro EXPAND
cannot remember that it was in the invocation mode and when it comes
back it will lose its position in the initial
expanded macro.