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?

  1. Programmers need not to know about different macro functions for each compiler or assembler language.
  2. Cost of producing the MP will be only once and will not be repeated for different languages.
  3. Saving in software maintenance since only one MP will be maintained

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.