4. Macro Processors1 Chapter IV: Macro Processors Overview: r To study the design and implementation of macro processors. r A macro represents a commonly.

Slides:



Advertisements
Similar presentations
COP 3402 Systems Programming
Advertisements

1 Chapter 8: Code Generation. 2 Generating Instructions from Three-address Code Example: D = (A*B)+C =* A B T1 =+ T1 C T2 = T2 D.
Macro simple idea of textual substitution useful when you need a group of instructions or directives frequently.
The Assembly Language Level
3. Loaders & Linkers1 Chapter III: Loaders and Linkers Chapter goal: r To realize how a source program be loaded into memory m Loading m Relocation m Linking.
Macro Processor.
Macro Processors (MP) Macro: Macro Processors (MP): Examples:
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.
Introduction to Computer Programming in C
1: Background1 System Programming ( 系統程式 ) Main goal: r What is a system software? m Compiler m Assembler m Loader and Linker m Debugger… r To design and.
CS412/413 Introduction to Compilers Radu Rugina Lecture 16: Efficient Translation to Low IR 25 Feb 02.
Chih-Hung Wang Chapter 2: Assembler (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
Tutorial 6 & 7 Symbol Table
An introduction to systems programming
Assemblers Dr. Monther Aldwairi 10/21/20071Dr. Monther Aldwairi.
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.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
5.3 Machine-Independent Compiler Features
Chapter 8: Writing Graphical User Interfaces
4.4 Equations as Relations
5-1 Chapter 5 - Languages and the Machine Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of Computer.
6-1 Chapter 6 - Languages and the Machine Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer.
Assemblers.
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.
PART I SISTEM UTILITIES LECTURE 5 MACROPROCESSING Ştefan Stăncescu 1.
SE: CHAPTER 7 Writing The Program
One Pass with Fixup One-pass structure definition must occur before any uses (that is, uses can have only backward references to definitions) examples:
M4 Macro-processing Language Geoffrey Sewell. What will be shown? What’s a macro processor? History of M4 Uses Autotools Syntax Hopefully, you all learn.
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
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.
2 : Assembler 1 Chapter II: Assembler Chapter goal: r Introduce the fundamental functions that any assembler must perform. m Assign machine address m Translate.
Introduction to Methods. Previously discussed There are similarities in make up of that can help you remember the construct of a class a class in the.
Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop.
Macro Processors.
Processor Fundamentals Assembly Language. Learning Objectives Show understanding of the relationship between assembly language and machine code, including.
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.
Preocedures A closer look at procedures. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
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.
One-pass structure definition must occur before any uses (that is, uses can have only backward references to definitions) examples: macro definition before.
Macro Processor Design Options Recursive Macro Expansion General-Purpose Macro Processors Macro Processing within Language Translators.
Names and Attributes Names are a key programming language feature
CS510 Compiler Lecture 4.
Computer Architecture and Assembly Language
CS 363 – Chapter 1 What is a programming language? Kinds of languages
Assembler Design Options
MACRO Processors CSCI/CMPE 3334 David Egle.
Chapter 4 Macro Processors
Exploring Microsoft Excel
Algorithm for One-pass Macro Processor
Processor Fundamentals
Chapter 9: Value-Returning Functions
Chapter 1 Computer architecture Languages: machine, assembly, high
Parameter transmission
PZ09B - Parameter transmission
UNIT – IV MACRO PROCESSORS
Chapter 10: Void Functions
Parameter transmission
CHAP 4 MACRO PROCESSORS.
Parameter transmission
Computer Architecture and System Programming Laboratory
Procedures & Macros Introduction Syntax Difference.
Presentation transcript:

4. Macro Processors1 Chapter IV: Macro Processors Overview: r To study the design and implementation of macro processors. r A macro represents a commonly used group of statements in the source programming language. r The macro processor replaces each macro instruction with the corresponding group of source language statements. (expanding)

4. Macro Processors2 r Macro definition r Invocation r Expansion (with substitution of parameters) Basic macro processor functions

4. Macro Processors3 r Macro definition r Invocation r Expansion (with substitution of parameters) Basic macro processor functions

4. Macro Processors4 r Macro definition r Invocation r Expansion (with substitution of parameters) Basic macro processor functions

4. Macro Processors5

6 Use of macros in a SIC/XE program

4. Macro Processors7 Use of macros in a SIC/XE program (cont.)

4. Macro Processors8 Program from above with macros expanded

4. Macro Processors9 Program from above with macros expanded (cont.)

4. Macro Processors10 Discussions… r Why does macro statement use JLT *-14? r Allow label?

4. Macro Processors11 Macro processor algorithm and data structures r For one-pass macro processor, the definition of a macro must appear in the source program before any statements that invoke that macro. r Three important tables are used for the macro processor: NAMTAB 、 DEFTAB 、 and ARGTAB.

4. Macro Processors12 Macro processor algorithm and data structures (cont.)

4. Macro Processors13 Macro processor algorithm and data structures

4. Macro Processors14 Macro processor algorithm and data structures (cont.)

4. Macro Processors15 Macro processor algorithm and data structures (cont.)

4. Macro Processors16 Machine-Independent Macro Processor Features ---- Concatenation of Macro Parameters r This feature enable a program to generate a series of variables named by XA1, XA2, XA3, …, etc. and XB1, XB2, XB3, …, etc. as well. r The body of the macro definition might contain a statement like LDAX&ID1 r It has some problems!! (solution: concatenation operator)

4. Macro Processors17 Machine-Independent Macro Processor Features ---- Concatenation of Macro Parameters (cont.)

4. Macro Processors18 Machine-Independent Macro Processor Features ---- Generation of unique labels r In general, the body of a macro instruction that contains labels is not possible. r It will cause duplicate definition. r Solution: use relative addressing (e.g., JEQ *03) r Drawback: For short jump, it is acceptable. For longer jump, it is not convenient, error- prone, and difficult to read.

4. Macro Processors19 Machine-Independent Macro Processor Features ---- Generation of unique labels (cont.)

4. Macro Processors20 Machine-Independent Macro Processor Features ---- Generation of unique labels (cont.)

4. Macro Processors21 Machine-Independent Macro Processor Features ---- Conditional Macro Expansion r For previous examples of macro instructions, these statements could be varied by the substitution of parameters, but the form of the statement, and the order in which they appeared, were unchanged. r Conditional macro expansion adds greatly to the power and flexibility of a macro language.

4. Macro Processors22 Machine-Independent Macro Processor Features ---- Conditional Macro Expansion (cont.)

4. Macro Processors23 Machine-Independent Macro Processor Features ---- Conditional Macro Expansion (cont.) Ps. &EORCK is a macro-time variable.

4. Macro Processors24 Machine-Independent Macro Processor Features ---- Conditional Macro Expansion (cont.)

4. Macro Processors25 Machine-Independent Macro Processor Features ---- Conditional Macro Expansion (cont.)

4. Macro Processors26 Machine-Independent Macro Processor Features ---- Macro-time looping statements

4. Macro Processors27 Machine-Independent Macro Processor Features ---- Macro-time looping statements (cont.)

4. Macro Processors28 Machine-Independent Macro Processor Features ---- Keyword Macro Parameters r Positional parameter vs. Keyword parameter GENER,, DIRECT,,,,,, 3. GENER TYPE=DIRECT, CHANNEL=3.

4. Macro Processors29 Machine-Independent Macro Processor Features ---- Keyword Macro Parameters (cont.)

4. Macro Processors30 Machine-Independent Macro Processor Features ---- Keyword Macro Parameters (cont.)

4. Macro Processors31 Machine-Independent Macro Processor Features ---- Keyword Macro Parameters (cont.)

4. Macro Processors32 Macro Processor Design Options ---- Recursive Macro Expansion r The invocation of one macro, which is defined by another macro instruction. r Using a programming language that allows recursive calls to write the macro processor.

4. Macro Processors33