0
24kviews
Explain different pseudo-ops used for conditional macro expansion along an example.
1 Answer
4
560views

MACRO

• In an assembly language program there can be group of instructions that may be repeated again and again.

• So we combine these instruction to a single group and assign a name to it which is called as MACRO..

• A macro is an extension to the basic ASSEMBLER language. They provide a means for generating a commonly used sequence of assembler instructions/statements.

• The sequence of instructions/statements will be coded ONE time within the macro definition. Whenever the sequence is needed within a program, the macro will be "called"

• MACRO is defined as a single line abbreviation for a group of instruction.

• Syntax : Macro
Macro name

} macro body

MEND

• Execution is faster in macro .There is no transfer of control in Macro.

• Features of Macro processor:

1) Recognized the macro definition.

2) Save macro definition.

3) Recognized the macro call.

4) Perform macro expansion.

Conditional Macro

• The macro processor replaces each macro instruction with the corresponding group of source language statements. This is called macro expansion or expanding the macros.

• Conditional assembly are frequently considered to be mechanisms that allow a single version of the source code for a program to be used to generate multiple versions of the executable.

• Most macro processors can also modify the sequence of statements generated for a macro expansion, depending on the arguments supplied in the macro invocation. Conditional Assembly is commonly used to describe this feature. It is also referred to as conditional macro expansion.

• Conditional Assembly can be achieved with the help of AIF and AGO statements.

  1. AIF Statement
  • It is used to specify the branching condition.

  • This statements provides conditional branching facility.

  • Syntax : AIF (condition) Label

  • If condition is satisfied the label is executed else it continue with the next execution.

  • It performs an arithmetic test and branches only if tested condition is true.

  1. AGO Statement
  • This statement provides the unconditional branching facilities.

  • We do not specify the condition

  • Syntax : AGO. Label

  • It specifies the label appearing on some other statement in the macro instruction definition.

  • The macro processor continues the sequential processing of instructions with the indicated statement.

  • These statements are directives to the macro processor and do not appear in macro expansion.

enter image description here

Labels staring with a period (.), such as .FINI, are macro labels and do not appear in the output of the macro processor.

• FINI directs the macro processor to skip to the statement labelled.

  1. LCL Statement:
  • This statement is used for defining the Local Variables (Expansion variables).

  • Local variables are always initialize to zero.

  1. SET Statement:
  • This statement is used for manipulating the value of expansion variables.

  • It is used to make the updation in Local variables.

  1. ANOP Statement:
  • This statement performs no operations.

enter image description here

Please log in to add an answer.