GATE / CS ARCHIVE

GATE CSE 1994 / QUESTION 18(a)

Macros versus callable subroutines

Compiler Design · Compiler Phases, Linking & Loading · Full GATE CSE 1994 paper

GATE 1994, Q18(a) Descriptive
Report issue

Compiler Phases, Linking & Loading

Question 18(a), GATE 1994: State true or false with reason: A subroutine cannot always be used to replace a macro in an assembly-language program.
Question 18(a), GATE 1994: State true or false with reason: A subroutine cannot always be used to replace a macro in an assembly-language program.
Tap to enlarge
Answer & solution

Answer: True. (no official key was published)

1. A macro performs assembly-time text expansion. Its parameters may select register names, opcodes, labels, data declarations or conditional assembly. Such choices can alter the generated instruction sequence itself.

2. A subroutine is runtime code reached by a call; it has call/return and argument conventions rather than general assembly-time substitution. A macro that declares a label or storage at each expansion point cannot be replaced simply by calling one fixed subroutine.

3. Some computational macros can be rewritten as subroutines, but that limited case does not justify the universal replacement claim.

Original paper, page 6