Presentation is loading. Please wait.

Presentation is loading. Please wait.

 A macro represents a commonly used group of statements in the source programming language.  The macro processor replaces each macro instruction with.

Similar presentations


Presentation on theme: " A macro represents a commonly used group of statements in the source programming language.  The macro processor replaces each macro instruction with."— Presentation transcript:

1

2  A macro represents a commonly used group of statements in the source programming language.  The macro processor replaces each macro instruction with the corresponding group of source language statements. This is called expanding the macros.  Macro instructions allow the programmer to write a shorthand version of a program, and leave the mechanical details to be handled by the macro processor.

3  The most common use of macro processors is in assembler language programming. However, macro processors can also be used with high-level programming languages, operating system command languages, etc.

4  Macro Instruction : It is a notational convenience for the programmer. It allows the programmer to write shorthand version of a program (module programming).  Macro processor : The macro processor replaces each macro instruction with the corresponding group of source language statements (expanding). Normally, it performs no analysis of the text it handles. It does not concern the meaning of the involved statements during macro expansion.

5  The design of a macro processor generally is machine independent.

6  Two new assembler directives are used in macro definition:  MACRO: identify the beginning of a macro definition.  MEND: identify the end of a macro definition.

7 Each parameter begins with ‘&’ name MACRO parameters : body : MEND

8  Body: the statements that will be generated as the expansion of the macro.

9 It is an abbreviation for a sequence of operations. E.g. A 1,DATA A 2,DATA A 3,DATA A 1,DATA A 2,DATA A 3,DATA DATA DC F’5’

10  Start of definition -------> MACRO  Macro name --------------> Name  Sequence to be abbreviated ---------->  End of definition ------------> MEND Macro pseudo-op is the first line of the definition and identifies the following line as a macro instruction name. Following the name line is the sequence of instructions being abbreviated. The definition is terminated by a line with the MEND pseudo-op.

11  Process of replacement is called macro expansion. Definition is saved in the macro processor. The occurrence in the source program of the macro name, as an operation mnemonic to be expanded is called macro call.

12  Macro Instruction Arguments : There is lack of facility as there is no way for a specific macro call to modify the coding that replaces it. An important extension of this facility consists of providing for arguments or parameters in macro calls. Corresponding macro dummy arguments will appear in macro definition.

13 E.g. A 1,DATA 1 A 2,DATA 1 A 3,DATA 1. A 1,DATA 2 A 2,DATA 2 A 3,DATA 2 DATA 1 DC F’5’ DATA 2 DC F’10’

14  In this case instructions are very similar but not identical. They can be considered to perform the same operation with a variable parameter or argument. Such a parameter is called a macro instruction argument, or “dummy argument”, it is specified on the macro name line and distinguished by the ampersand (&), which is always its first character.

15  Multiple Arguments : LOOP 1 A1,DATA 1 A2,DATA 2 A3,DATA 3 LOOP 2 A1,DATA 3 A2,DATA 2 A3,DATA 1 DATA 1 DC F’5’ DATA 2 DC F’10’ DATA 3 DC F’15’

16  AIF and AGO permit the conditional reordering of the sequence of macro expansion.


Download ppt " A macro represents a commonly used group of statements in the source programming language.  The macro processor replaces each macro instruction with."

Similar presentations


Ads by Google