COP 3402 Systems Programming

Slides:



Advertisements
Similar presentations
Macro simple idea of textual substitution useful when you need a group of instructions or directives frequently.
Advertisements

CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
The Assembly Language Level
COP 3402 Systems Programming Dr. Ali Orooji School of EECS University of Central Florida.
Macro Processor.
SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION
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.
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.
Intermediate Representation I High-Level to Low-Level IR Translation EECS 483 – Lecture 17 University of Michigan Monday, November 6, 2006.
CS412/413 Introduction to Compilers Radu Rugina Lecture 16: Efficient Translation to Low IR 25 Feb 02.
CPSC Compiler Tutorial 9 Review of Compiler.
8.2 Characteristics of a High Level Programming Language
Chih-Hung Wang Chapter 2: Assembler (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
An introduction to systems programming
1 Chapter 4 Macro Processors Source Code (with macro) Macro Processor Expanded Code Compiler or Assembler obj.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Chapter 4 Macro Processors
1 Chapter 4 Macro Processors Professor Gwan-Hwan Hwang Dept. Computer Science and Information Engineering National Taiwan Normal University 9/17/2009.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Macros. There are three basic phases for C programming. preprocessing, compiling, and linking. C input file is first passed to a preprocessing program.
Stephen P. Carl - CS 2421 Recursion Reading : Chapter 4.
1 Homework / Exam Finish up K&R Chapters 3 & 4 Starting K&R Chapter 5 Next Class HW4 due next class Go over HW3 solutions.
CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.
Chapter 13 Programming in the Large Dr. Jiung-yao Huang Dept. Comm. Eng. Nat. Chung Cheng Univ. TA: 鄭筱親 陳昱豪.
Invitation to Computer Science 5 th Edition Chapter 6 An Introduction to System Software and Virtual Machine s.
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.
4. Macro Processors1 Chapter IV: Macro Processors Overview: r To study the design and implementation of macro processors. r A macro represents a commonly.
Objective At the conclusion of this chapter you will be able to:
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
COP4020 Programming Languages Subroutines and Parameter Passing Prof. Xin Yuan.
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.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
Macro Processors.
FORTRAN History. FORTRAN - Interesting Facts n FORTRAN is the oldest Language actively in use today. n FORTRAN is still used for new software development.
Chapter 7: Macros in SAS  Macros provide for more flexible programming in SAS  Macros make SAS more “object-oriented”, like R 1 © Fall 2011 John Grego.
Introduction to Language Programming Hierarchy of programming lang. Based on machine independences: 1. Machine language 2. Assembly language 3. Higher.
© Oxford University Press All rights reserved. CHAPTER 10 THE PREPROCESSOR DIRECTIVE.
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.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
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.
Unit 10 Code Reuse. Key Concepts Abstraction Header files Implementation files Storage classes Exit function Conditional compilation Command-line arguments.
Macro Processor Design Options Recursive Macro Expansion General-Purpose Macro Processors Macro Processing within Language Translators.
Lecture 3 Translation.
Assembler, Compiler, MIPS simulator
Chapter 12 Section 1.
Computer Architecture and Assembly Language
COMPILERS Activation Records
CS 363 – Chapter 1 What is a programming language? Kinds of languages
Overview of Compilation The Compiler BACK End
Compiler Lecture 1 CS510.
Programming, Data & Testing
MACRO Processors CSCI/CMPE 3334 David Egle.
Chapter 4 Macro Processors
Overview of Compilation The Compiler BACK End
Register Variables Declaring a variable as a "register" variable is an advisory to the compiler to keep the normal location of the variable in a register,
Defining and Calling a Macro
Algorithm for One-pass Macro Processor
Chapter 1 Computer architecture Languages: machine, assembly, high
UNIT – IV MACRO PROCESSORS
CHAP 4 MACRO PROCESSORS.
Presentation transcript:

COP 3402 Systems Programming Dr. Ali Orooji School of EECS University of Central Florida

Chapter 4 - MACRO PROCESSORS Function macro expansion; substitute macro bodies for macro invocations Source Program with macro invocations Macro procesor Source Program with macros expanded assembler …

Two-Pass Macro Processor process macro definitions Pass 2 expand macro invocations Problem would not allow the body of one macro to contain definitions of other macros

PMAC MACRO ... C1MAC MACRO ... ... MEND C2MAC MACRO ...

One-Pass Macro Processor . will process macro definitions and expand macro invocations at the same time; will alternate between macro definition and macro expansion . the definition of a macro must come before any of its invocations Macro Processor Data Structures definition table DEFTAB DEFTBL - macro definitions are stored in this table - references to parameters are converted to a positional notation for efficiency in substituting arguments

name table NAMTAB NAMTBL - macro names are stored in this table along with pointers to the beginning and end of definitions in DEFTAB; serves as an index to DEFTAB argument table ARGTAB ARGTBL - used during the expansion of macro invocations - arguments in a macro invocation are stored in this table Macro Processor Logic pages 184-185 of text Figure 4.5 Algorithm for a one-pass macro processor

Machine-Independent Macro Processor Features Section 4.2 Machine-Independent Macro Processor Features Generation of Unique Labels MAC MACRO ... ... LBL ... MEND first macro expansion AALBL second macro expansion ABLBL

Conditional Macro Expansion IF ( Boolean expression ) ... ELSE ENDIF - - - - - - - - - - WHILE ( Boolean expression ) ENDW

Macro Processor Design Options Section 4.3 Macro Processor Design Options Recursive Macro Expansion Problems with previous macro processor - when a macro invokes another macro ARGTAB is overwritten - when the second macro finishes EXPANDING is set to FALSE

Solution - if macro processor is written in a high-level language that supports recursion, then there won't be problems since the compiler saves the previous values of variables on recursive calls - if macro processor must be written in a programming language that does not support recursion, then the system programmer must save the data values (this can be done using a stack)

General-Purpose Macro Processors not dependent on any particular programming language; can be used with a variety of different languages Problems - problems related to different programming languages . comments . facilities for grouping . tokens (identifiers, operators, ...) - syntax used for macro definitions and macro invocations

Macro Processing within Language Translators previous macro processor: pre-processor alternative: combining the macro processing functions with the language translator . line-by-line macro processor . integrated macro processor