Macro Instructions in Assembly Programming

NonViolentRelativity avatar
NonViolentRelativity
·
·
Download

Start Quiz

Study Flashcards

12 Questions

What is the primary purpose of a macro instruction?

To simplify and reduce repetitive coding

What is the output of a macro processor?

An assembly program

When are macros handled by the assembler?

During assembly time

What is the key difference between a macro and a subroutine?

Macros are handled by the software, while subroutines are handled by the hardware

What is the role of a preprocessor in a macro processor?

To process the input data to produce output for the macro processor

What is the relationship between the macro name and its expansion?

The macro name is replaced by the entire block of instructions

What is the major disadvantage of using subroutines?

Substantial overheads of control transfer during execution

What is the purpose of the macro preprocessor statement?

To perform auxiliary functions during macro expansion

What is the syntax of a macro call?

[ [,…]]

What is the purpose of the MACRO directive?

To specify the start of the macro definition

What is the effect of macro processing on the resulting code?

It increases the size of the resulting code

What is the purpose of the MEND directive?

To specify the end of the macro definition

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.

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.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser