1 Macro Processors. 2 Macro Processor l Recognize macro definitions l Save the macro definition l Recognize macro calls l Expand macro calls Source Code.

Slides:



Advertisements
Similar presentations
COP 3402 Systems Programming
Advertisements

Review What is a virtual function? What can be achieved with virtual functions? How to define a pure virtual function? What is an abstract class? Can a.
Macro simple idea of textual substitution useful when you need a group of instructions or directives frequently.
Programming With Java ICS201 University Of Hail1 Chapter 13 Inner Classes.
Chapter 8 Scope, Lifetime and More on Functions. Definitions Scope –The region of program code where it is legal to reference (use) an identifier Three.
The Assembly Language Level
Macro Processor.
Lecture 16 Subroutine Calls and Parameter Passing Semantics Dragon: Sec. 7.5 Fischer: Sec Procedure declaration procedure p( a, b : integer, f :
Macro Processors (MP) Macro: Macro Processors (MP): Examples:
Chapter 11: Creating and Using Macro Programs 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Implementing Subprograms
8.2 Characteristics of a High Level Programming Language
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
An introduction to systems programming
EECC250 - Shaaban #1 lec #18 Winter Assembly Language Macros Most assemblers include support for macros. The term macro refers to a word that.
1 Chapter 4 Macro Processors Source Code (with macro) Macro Processor Expanded Code Compiler or Assembler obj.
Chapter 4 Macro Processors
1. 2 FUNCTION INLINE FUNCTION DIFFERENCE BETWEEN FUNCTION AND INLINE FUNCTION CONCLUSION 3.
Inline Function. 2 Expanded in a line when it is invoked Ie compiler replace the function call with function code To make a function inline the function.
1 Chapter 4 Macro Processors Professor Gwan-Hwan Hwang Dept. Computer Science and Information Engineering National Taiwan Normal University 9/17/2009.
Macro & Function. Function consumes more time When a function is called, the copy of the arguments are passed to the parameters in the function. After.
CS 2104 Prog. Lang. Concepts Subprograms
Assembly Language Macros Most assemblers include support for macros. The term macro refers to a word that stands for an entire group of instructions. Macro.
Chapter 1 Computer architecture Languages: machine, assembly, high
An introduction to systems programming
Machine Independent Macro Processor Features Concatenation of Macro Parameters Generation of Unique Labels Conditional Macro Expansion Keyword Macro.
4. Macro Processors1 Chapter IV: Macro Processors Overview: r To study the design and implementation of macro processors. r A macro represents a commonly.
PART I SISTEM UTILITIES LECTURE 5 MACROPROCESSING Ştefan Stăncescu 1.
CPS120: Introduction to Computer Science Decision Making in Programs.
ICS312 Set 14 MACROS. Macros The program structure is similar to that for procedures. As for procedure names, macro names represent a group of instructions.
Introduction to SAS Macros Center for Statistical Consulting Short Course April 15, 2004.
Week 2-3 Control flow (review) Conditional statements If, else, else if, switch-case, break Loop constructs for, while, do-while, break, continue, label--go;
BMTRY 789 Lecture 10: SAS MACRO Facility Annie N. Simpson, MSc.
Macro Processors.
L what are predefined functions? l what is? n function name n argument(s) n return value n function call n function invocation n nested function call l.
Macro Processors Basic Functions Machine-Independent Features Design Options Implementation Examples.
 A macro represents a commonly used group of statements in the source programming language.  The macro processor replaces each macro instruction with.
Methods.
Preocedures A closer look at procedures. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
Procedure Activations Programming Language. Exploration Name ocurrenceDeclarationLocationValue scopeactivationstate a.From names to their declarations.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
1 Chapter 4 Macro Processors. 2 Introduction A macro instruction (abbreviated to macro) is simply a notational convenience for the programmer. A macro.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 11–Macro-Processors.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Macro Processor Design Options Recursive Macro Expansion General-Purpose Macro Processors Macro Processing within Language Translators.
Lecture 3 Translation.
System Programming System Software:
Language Translation Compilation vs. interpretation.
Predefined Functions Revisited
Computer Architecture and Assembly Language
Modern JavaScript Develop And Design
MACRO Processors CSCI/CMPE 3334 David Egle.
Chapter 4 Macro Processors
Functions I Creating a programming with small logical units of code.
Macro Variable’s scope
Algorithm for One-pass Macro Processor
Array and Method.
Procedure Activations
What time is it?. What time is it? Major Concepts: a data structure model: basic representation of data, such as integers, logic values, and characters.
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Computer Architecture and System Programming Laboratory
Chapter 1 Computer architecture Languages: machine, assembly, high
Predefined Functions Revisited
Chapter 11: The Preprocessor
UNIT – IV MACRO PROCESSORS
Functions I Creating a programming with small logical units of code.
Lecture 3 - Instruction Set - Al
CHAP 4 MACRO PROCESSORS.
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Computer Architecture and System Programming Laboratory
Presentation transcript:

1 Macro Processors

2 Macro Processor l Recognize macro definitions l Save the macro definition l Recognize macro calls l Expand macro calls Source Code (with macro) Macro Processor Expanded Code Compiler or Assembler obj

3 Macro Definition l copy code l parameter substitution l macro instruction defining macros

4 Copy code -- Example Source STRG MACRO STADATA1 STBDATA2 STXDATA3 MEND. STRG. STRG. Expanded source. STADATA1 STBDATA2 STXDATA3. STADATA1 STBDATA2 STXDATA3. { {

5 Parameter Substitution -- Example Source STRG MACRO&a1, &a2, &a3 STA&a1 STB&a2 STX&a3 MEND. STRGDATA1, DATA2, DATA3. STRGDATA4, DATA5, DATA6. Expanded souce. STADATA1 STBDATA2 STXDATA3. STADATA4 STBDATA5 STXDATA6. { {

6 TEST START 2000h CELTOFERMACRO&CEL &FER LDA&CEL MULTNINE DIVFIVE ADDTHIRTYTWO STA&FER MEND CELTOFERCF CRESW1 FRESW1 NINEWORD9 FIVEWORD5 THIRYTWOWORD32 END Sample Code

7 One-Pass Macro Processor l Prerequisite »every macro must be defined before it is called l Sub-procedures »macro definition: DEFINE »macro invocation: EXPAND DEFINE EXPAND PROCESSLINE DEFTAB NAMTAB ARGTAB MACRO CALL

8 Data Structures -- Global Variables l DEFTAB l NAMTAB l ARGTAB EXPANDING

10

11

12 Nested Macros Definition l Macro definition within macros »process inner macro definition, during the expansion of outer macro Outer macro definition Inner macro definition

13 TEST START 2000h MACROSMACRO CELTOFERMACRO&CEL &FER LDA&CEL MULTNINE DIVFIVE ADDTHIRTYTWO STA&FER MEND MACROFMACRO CELTOFERMACRO&CEL &FER LDAF&CEL MULTFNINE DIVFFIVE ADDFTHIRTYTWO STAF&FER MEND Integer instructions set Floating point instructions set Nested Macro Definition Example

14 MACROS CELTOFERC F CRESW1 FRESW1 NINEWORD9 FIVEWORD5 THIRYTWOWORD32 MACROF CELTOFERC F CRESW1 FRESW1 NINEWORD9 FIVEWORD5 THIRYTWOWORD32 END Nested Macro Definition Example

15 One-Pass Macro Processor That Allows Nested Macro Definition l Sub-procedures »macro definition: DEFINE »macro invocation: EXPAND l EXPAND may invoke DEFINE when encounter macro definition DEFINE EXPAND PROCESSLINE DEFTAB NAMTAB ARGTAB Expanding MACRO CALL MACRO Definition

16 1-Pass Macro Processor