Podcast
Questions and Answers
What is the primary purpose of a macro instruction?
What is the primary purpose of a macro instruction?
What is the output of a macro processor?
What is the output of a macro processor?
When are macros handled by the assembler?
When are macros handled by the assembler?
What is the key difference between a macro and a subroutine?
What is the key difference between a macro and a subroutine?
Signup and view all the answers
What is the role of a preprocessor in a macro processor?
What is the role of a preprocessor in a macro processor?
Signup and view all the answers
What is the relationship between the macro name and its expansion?
What is the relationship between the macro name and its expansion?
Signup and view all the answers
What is the major disadvantage of using subroutines?
What is the major disadvantage of using subroutines?
Signup and view all the answers
What is the purpose of the macro preprocessor statement?
What is the purpose of the macro preprocessor statement?
Signup and view all the answers
What is the syntax of a macro call?
What is the syntax of a macro call?
Signup and view all the answers
What is the purpose of the MACRO directive?
What is the purpose of the MACRO directive?
Signup and view all the answers
What is the effect of macro processing on the resulting code?
What is the effect of macro processing on the resulting code?
Signup and view all the answers
What is the purpose of the MEND directive?
What is the purpose of the MEND directive?
Signup and view all the answers
Study Notes
Macro Instructions
- Macro instructions are single-line abbreviations for groups of instructions.
- For every occurrence of a macro instruction within a program, the instruction must be replaced by the entire block.
Advantages of Macros
- Simplify and reduce the amount of repetitive coding.
- Reduce the possibility of errors caused by repetitive coding.
- Make an assembly program more readable.
Macro Processors
- A preprocessor can be any program that processes its input data to produce output, which is used as an input to another program.
- The outputs of the macro processors are assembly programs that become inputs to the assembler.
- The macro processor may exist independently and be called during the assembling process or be a part of the assembler implementation itself.
Difference between Macro and Subroutine
- Macro name in the mnemonic field leads to expansion only.
- Macro is completely handled by the assembler during assembly time.
- Subroutine name in a call statement in the program leads to execution.
- Subroutines are completely handled by the hardware at runtime.
- Macro definition and macro expansion are executed by the assembler.
- Hardware executes the subroutine call instruction.
Macro Definition and Call
- A macro consists of a name, a set of formal parameters, and a body of codes.
- A macro can be defined by enclosing a set of statements between a macro header and a macro end statement.
- The formal structure of a macro includes:
- Macro prototype statement: specifies the name of the macro and name and type of formal parameters.
- Model statements: specify the statements in the body of the macro from which assembly language statements are to be generated during expansion.
- Macro preprocessor statement: specifies the statement used for performing auxiliary function during macro expansion.
- A macro can be called by writing the name of the macro in the mnemonic field of the assembly language.
- The syntax of a typical macro call can be of the following form:
[ [,…]]
. - The MACRO directive in the mnemonic field specifies the start of the macro definition.
- The MEND directive specifies the end of the macro definition.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Learn about macro instructions, their advantages, and how they simplify and reduce repetitive coding in assembly programming. Understand how macro processors work and their role in preprocessing.