Skip to content
Official PYQ · 1994

GATE CS 1994 Q18a — Lexical Analysis

Explain with AI
State whether the following statements are True or False with reasons for your answer

A subroutine cannot always be used to replace a macro in an assembly language program.
View worked solution

Answer: 1

The given statement is True (represented by 1).

A subroutine cannot always be used to replace a macro in an assembly language program due to the following fundamental differences:

  1. Assembly-Time Directives: Macros are expanded during the assembly phase (pre-processing) and can contain assembler directives (such as DB, DW, EQU, or storage reservation commands). These directives instruct the assembler on how to allocate memory or define constants. A subroutine, being a runtime entity consisting only of executable machine instructions, cannot perform these assembly-time operations.
  2. Textual Parameter Substitution: Macros use literal textual substitution. This allows them to accept non-value parameters such as register names (e.g., AX, BX), condition codes, or instruction opcodes. Subroutines can only pass data values or memory addresses via registers or the stack at runtime.
  3. Code Fragments and Control Flow: A macro can represent an incomplete fragment of code (for example, starting a loop or a conditional block without closing it inside the macro). A subroutine must be a complete, self-contained block of executable code with a well-defined entry point and a return instruction (e.g., RET).

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Lexical Analysis questions