Understanding Macroprocessors: Definition and Expansion

chapter 6 n.w
1 / 18
Embed
Share

"Learn about macroprocessors and how they work, including macro instruction expansion, differences between macros and subroutine calls, and the benefits of using macros in programming. Dive into macro definitions, expansions, and practical examples to enhance your coding skills."

  • Macroprocessors
  • Definition
  • Expansion
  • Programming
  • Coding

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CHAPTER 6 MACROPROCESSORS

  2. MACROPROCESSORS A macro instruction (a macro) represents a commonly used group of statements in the source program language. The macro processor replaces each macro instruction with the corresponding group of source language statements. This is called expanding the macros. Macro programmer to write a short hand version of a program. instructions therefore allow the

  3. Macro Definition and Expansion. A macro consists of a name, a set of formal parameters and a body. The directives MACRO and MEND mark the beginning and end of respectively. a macro definition Each parameter begins with a character & Following the MACRO directive is the body of the macro (The statements that will be generated when the macro is expanded.)

  4. .

  5. Macro Definition and Expansion. The main program itself begins on line 180. The statement on line 190 is a macro call.

  6. Macro Definition and Expansion The figure above shows the output that would be generated. In the expanded form: The macro definitions have been deleted and the macro invocation statement included as a comment line. itself has been Each macro instruction has been expanded into the statements that form the body of the macro. The arguments from the macro invocation have been substituted for the parameters in the macro prototype.

  7. Differences between Macros and Subroutine calls The statements that form the expansion of the macro are generated (and assembled) each time the macro is invoked e.g. The statements from the body of the macro WRBUFF are generated twice i.e. lines 210a to 210h and lines 220a to 220h in the above figure. Statements in a subroutine appear only once regardless of how many times the subroutine is called.

  8. Differences between Macros and Subroutine calls Macro instructions are written with no labels in the body of the macro e.g. Line 135 JEQ *-3 , line 155 JLT *-14 instead of JEQ WLOOP and JLT WLOOP, where WLOOP is the label on the TD instruction that tests the output device. This definitions which would result into errors. is done to avoid duplicate label

  9. Macro processor Tables and Logic. The macro definitions are stored in a macro definition table DEFTAB which contains the macro prototype and the statements that make up the macro body. Macro names are entered into the Macro names Table NAMTAB which serves as an index to DEFTAB. For each defined macro NAMTAB contains pointers to the beginning and end of the definition in DEFTAB. The argument table, ARGTAB, is used during the expansion of macro calls. The arguments are stored in ARGTAB according to their positions in the argument list.

  10. Generation of Unique Labels. For large jumps over many instructions relative addressing is inconvenient, difficult to read. Special types of labels are therefore used. error prone and Labels within the macro body begin with the special character $. In the expansion each symbol beginning with $ is modified by replacing $ with $XX where XX is a two character alphanumeric counter of the number of macro instructions expanded. For the first macro expansion in a program XX will have the value AA. expansion, XX will be set to AB, AC etc. For succeeding macro

More Related Content