Introduction. Chapter 4 Macro Processors -- Basic Macro Processor Functions. Macro expansion. Basic macro processor functions
|
|
- Sibyl Lawrence
- 5 years ago
- Views:
Transcription
1 Introduction Chapter 4 Macro Processors -- Basic Macro Processor Functions Amacroinstruction(macro)isanotational convenience for the programmer Itallowstheprogrammertowriteshorthandversionofaprogram (module programming) Themacroprocessorreplaceseachmacro instruction with the corresponding group of source language statements(expanding) Normally,itperformsnoanalysisofthetextithandles Itdoesnotconcernthemeaningoftheinvolvedstatementsduring macro expansion Thedesignofamacroprocessorgenerallyis machine independent! Basic macro processor functions Macro expansion Twonewassemblerdirectivesareusedinmacro definition MACRO:identifythebeginningofamacrodefinition MEND:identifytheendofamacrodefinition Prototypeforthemacro Eachparameterbeginswith & name MACRO parameters : body : MEND Body:thestatementsthatwillbegeneratedastheexpansionofthe macro Source M1 MACRO &D1,&D2 STA &D1 STB &D2 MEND M1 DATA1, DATA2 M1 DATA4, DATA3 Expanded source STA DATA1 STB DATA2 STA DATA4 STB DATA3
2 Example of macro definition Figure 41, pp 178 Macro invocation Amacroinvocationstatement(amacrocall)givesthe name of the macro instruction being invoked and the arguments to be used in expanding the macro macro_name p1, p2, Differencebetweenmacrocallandprocedurecall Macrocall:statementsofthemacrobodyareexpandedeachtimethe macro is invoked Procedurecall:statementsofthesubroutineappearonlyone, regardless of how many times the subroutine is called Question Howdoesaprogrammerdecidetousemacrocallsorprocedurecalls? From the viewpoint of a programmer From the viewpoint of the CPU Exchange the values of two variables Pass by Reference void exchange(int a, int b) { int temp; temp = a; a = b; b = temp; void exchange(int *p1, int *p2) { int temp; temp = *p1; *p1 = *p2; *p2 = temp; main() { int i=1, j=3; printf("before - %d %d\n", i, j); exchange(i, j); printf("after - %d %d\n", i, j); What s the result? main() { int i=1, j=3; printf("before - %d %d\n", i, j); exchange(&i, &j); printf("after - %d %d\n", i, j);
3 12 Lines of Assembly Code Swap two variables by macro Subroutine EXCH EXCH STA TEMP LDA TEMP RSUB P1 RESW 1 P2 RESW 1 TEMP RESW 1 MAIN LDA #1 STA I LDA #3 STA J Call a subroutine LDA #I STA P1 LDA #J STA P2 JSUB EXCH I RESW 1 J RESW 1 END MAIN #define swap(i,j) { int temp; temp=i; i=j; j=temp; main() { int i=1, j=3; printf("before - %d %d\n", i, j); swap(i,j); printf("after - %d %d\n", i, j); 6LinesofAssemblyCode MAIN LDA #1 STA I LDA #3 STA J Invoke a macro LDA I STA TEMP LDA J STA I LDA TEMP STA J I RESW 1 J RESW 1 TEMP RESW 1 END MAIN Macro expansion Eachmacroinvocationstatementwillbeexpandedinto thestatementsthatformthebodyofthemacro Argumentsfromthemacroinvocationaresubstitutedfor the parameters in the macro prototype(according to their positions) Inthedefinitionofmacro:parameter Inthemacroinvocation:argument Commentlineswithinthemacrobodywillbedeleted Macroinvocationstatementitselfhasbeenincludedasa comment line Thelabelonthemacroinvocationstatementhasbeen retainedasalabelonthefirststatementgeneratedinthe macro expansion Wecanuseamacroinstructioninexactlythesamewayasanassembler language mnemonic
4 Example of macro invocation Figure 41, pp 178 Example of macro expansion Figure 42, pp 179 Example of macro expansion Figure 42, pp 179 Example of macro expansion Figure 42, pp 179
5 Nolabelinthemacrobody Problemofthelabelinthebodyofmacro: Ifthesamemacroisexpandedmultipletimesatdifferentplacesin the program Therewillbeduplicatelabels,whichwillbetreatedaserrorsby the assembler Solutions: Donotuselabelsinthebodyofmacro ExplicitlyusePC-relativeaddressinginstead Ex, in RDBUFF and WRBUFF macros, JEQ *+11 JLT *-14 It is inconvenient and error-prone Thewayofavoidingsucherror-pronemethodwillbediscussedin Section 422 Two-pass macro processor Youmaydesignatwo-passmacroprocessor Pass1: Process all macro definitions Pass2: Expand all macro invocation statements However,one-passmaybeenough Becauseallmacroswouldhavetobedefinedduringthe first pass before any macro invocations were expanded The definition of a macro must appear before any statements that invoke that macro Moreover,thebodyofonemacrocancontaindefinitionsof other macros Example of recursive macro definition Figure 43, pp182 Example of recursive macro definition Figure 43, pp182 MACROS(forSIC) ContainsthedefinitionsofRDBUFFandWRBUFF written in SIC instructions MACROX(forSIC/XE) ContainsthedefinitionsofRDBUFFandWRBUFF written in SIC/XE instructions
6 Example of macro definitions AprogramthatistoberunonSICsystem could invoke MACROS whereas a program to berunonsic/xecaninvokemacrox However,definingMACROSorMACROX does not define RDBUFF and WRBUFF These definitions are processed only when aninvocationofmacrosormacroxis expanded One-pass macro processor Aone-passmacroprocessorthatalternate between macro definition and macro expansioninarecursivewayisableto handle recursive macro definition Restriction Thedefinitionofamacromustappearinthesource program before any statements that invoke that macro Thisrestrictiondoesnotcreateanyrealinconvenience Data structures for one-pass macro processor Data structures DEFTAB(definitiontable) Storesthemacrodefinitionincludingmacroprototypeandmacrobody Commentlinesareomitted Referencestothemacroinstructionparametersareconvertedtoa positional notation for efficiency in substituting arguments NAMTAB Storesmacronames ServesasanindextoDEFTAB Pointers to the beginning and the end of the macro definition (DEFTAB) ARGTAB Storestheargumentsofmacroinvocationaccordingtotheirpositionsin the argument list Asthemacroisexpanded,argumentsfromARGTABaresubstitutedfor the corresponding parameters in the macro body
7 Algorithm MAIN program - Iterations of GETLINE PROCESSLINE Procedure GETLINE If EXPANDING then getthenextlinetobeprocessedfromdeftab Else readnextlinefrominputfile Procedure PROCESSLINE DEFINE EXPAND Output source line Algorithm Figure 45, pp 184 Procedure EXPAND SetuptheargumentvaluesinARGTAB Expand a macro invocation statement(like in MAIN procedure) - Iterations of GETLINE PROCESSLINE Procedure DEFINE Make appropriate entries in DEFTAB and NAMTAB Algorithm Figure 45, pp 185 Algorithm Figure 45, pp 185
8 Handling nested macro definition Comparison of Macro Processors Design InDEFINEprocedure WhenamacrodefinitionisbeingenteredintoDEFTAB,thenormal approach is to continue until an MEND directive is reached ThiswouldnotworkfornestedmacrodefinitionbecausethefirstMEND encountered in the inner macro will terminate the whole macro definition process Tosolvethisproblem,acounterLEVELisusedtokeeptrackofthelevel of macro definitions Increase LEVEL by 1 each time a MACRO directive is read Decrease LEVEL by 1 each time a MEND directive is read A MEND terminates the whole macro definition process when LEVEL reaches 0 This process is very much like matching left and right parentheses when scanning an arithmetic expression One-passalgorithm Everymacromustbedefinedbeforeitiscalled One-passprocessorcanalternatebetweenmacro definition and macro expansion Nestedmacrodefinitionsareallowedbutnestedcalls are not Two-passalgorithm Pass1:Recognizemacrodefinitions Pass2:Recognizemacrocalls Nestedmacrodefinitionsarenotallowed
UNIT-IV: MACRO PROCESSOR
UNIT-IV: MACRO PROCESSOR A Macro represents a commonly used group of statements in the source programming language. A macro instruction (macro) is a notational convenience for the programmer o It allows
More information4.2 Machine-Independent Macro Processor Features
4.2 Machine-Independent Macro Processor Features Extensions to the basic macro processor functions Concatenation of Macro Parameters Generation of Unique Labels Conditional Macro Expansion Keyword Macro
More informationUNIT I - INTRODUCTION
UNIT I - INTRODUCTION 1. Define system software. It consists of variety of programs that supports the operation of the computer. This software makes it possible for the user to focus on the other problems
More information2.1. Basic Assembler Functions:
2.1. Basic Assembler Functions: The basic assembler functions are: Translating mnemonic language code to its equivalent object code. Assigning machine addresses to symbolic labels. SOURCE PROGRAM ASSEMBLER
More informationUNIT IV -MACROPROCESSOR
CS2304-SYSTEM SOFTWARE 2 MARK QUESTION & ANSWERS. UNIT IV -MACROPROCESSOR 1. Define macro. A macro represents a group of statements in a source language, for performing some function macro can be defined
More informationGechstudentszone.wordpress.com
UNIT - 1 MACHINE ARCHITECTURE 11 Introduction: The Software is set of instructions or programs written to carry out certain task on digital computers It is classified into system software and application
More informationCS2422 Assembly Language & System Programming
CS2422 Assembly Language & System Programming November 30, 2006 Today s Topic Assembler: Basic Functions Section 2.1 of Beck s System Software book. Reading Assignment: pages 43-52. Role of Assembler Source
More informationChapter 1 Background. Professor Gwan-Hwan Hwang Dept. Computer Science and Information Engineering National Taiwan Normal University
Chapter 1 Background Professor Gwan-Hwan Hwang Dept. Computer Science and Information Engineering National Taiwan Normal University 9/17/2009 1 Outlines 1.1 Introduction 1.2 System Software and Machine
More informationChapter 2 Assemblers Machine-Dependent Assembler Features
Chapter 2 Assemblers -- 2.2 Machine-Dependent Assembler Features Outline Instruction format and addressing mode Program relocation Instruction format and addressing mode PC-relative or Base-relative addressing
More informationChapter 1: Background
Chapter 1: Background Hsung-Pin Chang Department of Computer Science National Chung Hsing University Outline 1.1 Introduction 1.2 System Software and Machine Architecture 1.3 The Simplified Instructional
More informationGechstudentszone.wordpress.com
CHAPTER -2 2.1 Basic Assembler Functions: The basic assembler functions are: ASSEMBLERS-1 Translating mnemonic language code to its equivalent object code. Assigning machine addresses to symbolic labels.
More informationUNIT II ASSEMBLERS www.noyesengine.com www.technoscriptz.com 1 1. BASIC ASSEMBLER FUNCTIONS 2. A SIMPLE SIC ASSEMBLER 3. ASSEMBLER ALGORITHM AND DATA STRUCTURES 4. MACHINE DEPENDENT ASSEMBLER FEATURES
More informationUNIT 1: MACHINE ARCHITECTURE
VTU QUESTION PAPER SOLUTION UNIT 1: MACHINE ARCHITECTURE 1. a) Give the target address generated for the following machine instruction: (i) 032600h (ii) 03C300h (iii) 0310C303h if (B)=006000, (PC)=003000,
More informationPESIT SOUTHCAMPUS 10CS52: SYSTEM SOFTWARE QUESTION BANK
CS52: SYSTEM SOFTWARE QUESTION BANK Chapter1: MACHINE ARCHITECTURE OBJECTIVE: Main Objective is to Know about the system software and architecture of Various Machines Like SIC, SIC/XE and Programming examples
More informationINTERNAL TEST (SCHEME AND SOLUTION)
PES Institute of Technology, Bangalore South Campus (Formerly PES School of Engineering) (Hosur Road, 1KM before Electronic City, Bangalore-560 100) Dept of MCA INTERNAL TEST (SCHEME AND SOLUTION) 1 Subject
More informationCS2422 Assembly Language & System Programming
CS2422 Assembly Language & System Programming December 7, 2006 Today s Topic Assembler: Machine Dependent Features SIC/XE Program Relocation Modification Records in an Object File. Study Guide Sections
More informationChapter 2. Assembler Design
Chapter 2 Assembler Design Assembler is system software which is used to convert an assembly language program to its equivalent object code. The input to the assembler is a source code written in assembly
More informationTRB-COMPUTER INSTRUCTOR COMPUTER SCIENCE UNIT IV. SYSTEM SOFTWARE 10% DISCOUNT FOR ALL PGTRB MATERIALS WITH QUESTION BANK.
N COACHING CENTRE-TRICHY- TRB- COMPUTER INSTRUCTOR-COMPUTER SCIENCE STUDY MATERIAL-CONTACT: 822006 2017 N TRB-COMPUTER INSTRUCTOR COMPUTER SCIENCE UNIT IV SYSTEM SOFTWARE 10% DISCOUNT FOR ALL PGTRB MATERIALS
More informationAS-2883 B.Sc.(Hon s)(fifth Semester) Examination,2013 Computer Science (PCSC-503) (System Software) [Time Allowed: Three Hours] [Maximum Marks : 30]
AS-2883 B.Sc.(Hon s)(fifth Semester) Examination,2013 Computer Science (PCSC-503) (System Software) [Time Allowed: Three Hours] [Maximum Marks : 30] Note: Question Number 1 is compulsory. Marks : 10X1
More informationChapter 3 Loaders and Linkers -- Machine-Dependent Loader Feature
Chapter 3 Loaders and Linkers -- Machine-Dependent Loader Feature Motivation Shortcoming of an absolute loader Programmer needs to specify the actual address at which it will be loaded into memory. It
More informationCOMPILERS BASIC COMPILER FUNCTIONS
COMPILERS BASIC COMPILER FUNCTIONS A compiler accepts a program written in a high level language as input and produces its machine language equivalent as output. For the purpose of compiler construction,
More informationUNIT III - LOADERS AND LINKERS
3.1 Introduction to Loaders UNIT III - LOADERS AND LINKERS A loader is the part of an operating system that is responsible for loading programs into memory and prepares them for execution. Loading a program
More informationCSI 402 Lecture 5 (Assemblers Continued) 5 1 / 18
CSI 402 Lecture 5 (Assemblers Continued) 5 1 / 18 Program Relocation Example 1: Consider the SIC instruction LDA THREE Assume the following: The START directive specifies the value 100 (decimal) The LC
More informationPESIT Bangalore South Campus Department of MCA Course Information for. System Programming (13MCA24)
PESIT Bangalore South Campus Department of MCA Course Information for System Programming (13MCA24) 1.GENERAL INFORMATION Academic Year: 2015 Semester(s): 2 nd Title Code Duration (hrs) Lectures 48 Hrs
More informationCS1203-SYSTEM SOFTWARE UNIT I-INTRODUCTION
CS1203-SYSTEM SOFTWARE UNIT I-INTRODUCTION 1. Define system software. It consists of variety of programs that supports the operation of the computer. This software makes it possible for the user to focus
More informationIntroduction SIC, RISC & CISC 0. Introduction to Systems Programming This course aims at: Understanding what is going on behind the scenes The design and implementation of system software, such as Assemblers
More informationAssemblers. System Software by Leland L. Beck. Chapter 2
Assemblers System Software by Leland L. Beck Chapter 2 1 Role of Assembler Source Program Assembler Object Code Linker Executable Code Loader 2 Chapter 2 -- Outline Basic Assembler Functions Machine-dependent
More informationChapter 1. Introduction
Chapter 1 Introduction This Chapter gives you System Software & Machine Architecture The Simplified Instructional Computer SIC and SIC/XE Traditional (CISC) Machines - Complex Instruction Set Computers
More informationDHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
DHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR 621113. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING CS2304- SYSTEM SOFTWARE PART-B QUESTIONS 1. EXPLAIN THE ARCHITECTURE
More informationLOADERS AND LINKERS 1. BASIC LOADER FUNCTIONS 2. DESIGN OF AN ABSOLUTE LOADER 3. A SIMPLE BOOTSTRAP LOADER 4. MACHINE DEPENDENT LOADER FEATURES
UIT III LOADERS AD LIKERS 1. BASIC LOADER FUCTIOS 2. DESIG OF A ABSOLUTE LOADER 3. A SIMPLE BOOTSTRAP LOADER 4. MACHIE DEPEDET LOADER FEATURES 5. RELOCATIO 6. PROGRAM LIKIG 7. ALGORITHM AD DATA STRUCTURES
More informationCS2304-SYSTEM SOFTWARE 2 MARK QUESTION & ANSWERS. UNIT I INTRODUCTION
CS2304-SYSTEM SOFTWARE 2 MARK QUESTION & ANSWERS. UNIT I INTRODUCTION 1. Define System Software. System software consists of a variety of programs that supports the operations of a computer. Eg. Compiler,
More informationParameter passing. Parameter: A variable in a procedure that represents some other data from the procedure that invoked the given procedure.
Parameter passing Parameter: A variable in a procedure that represents some other data from the procedure that invoked the given procedure. Parameter transmission: How that information is passed to the
More informationUnit 2 -- Outline. Basic Assembler Functions Machine-dependent Assembler Features Machine-independent Assembler Features Assembler Design Options
Unit 2 -- Outline Basic Assembler Functions Machine-dependent Assembler Features Machine-independent Assembler Features Assembler Design Options Introduction to Assemblers Fundamental functions translating
More informationLecture-30 Assemblers To assemble a program automatically the assembler needs information in the form of assembler direct that controls the assembly.
Lecture-30 Assemblers To assemble a program automatically the assembler needs information in the form of assembler direct that controls the assembly. E.g. the assembler must be told at what address to
More informationInformatica 3 Syntax and Semantics
Informatica 3 Syntax and Semantics Marcello Restelli 9/15/07 Laurea in Ingegneria Informatica Politecnico di Milano Introduction Introduction to the concepts of syntax and semantics Binding Variables Routines
More informationUNIT II ASSEMBLERS. Figure Assembler
2.1 Basic assembler functions UNIT II ASSEMBLERS Assembler Assembler which converts assembly language programs into object files. Object files contain a combination of machine instructions, data, and information
More informationModule 27 Switch-case statements and Run-time storage management
Module 27 Switch-case statements and Run-time storage management In this module we will discuss the pending constructs in generating three-address code namely switch-case statements. We will also discuss
More informationMacro. simple idea of textual substitution useful when you need a group of instructions or directives frequently.
Macro simple idea of textual substitution useful when you need a group of instructions or directives frequently. a programming language with a quite different feel than C, Java, etc.: textual substitution
More informationTo declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows
Unti 4: C Arrays Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type An array is used to store a collection of data, but it is often more useful
More informationfor (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }
Ex: The difference between Compiler and Interpreter The interpreter actually carries out the computations specified in the source program. In other words, the output of a compiler is a program, whereas
More informationMonday, April 15, We will lead up to the Analysis and Synthesis algorithms involved by first looking at three simpler ones.
Monday, pril 15, 2013 Topics for today Code generation nalysis lgorithm 1: evaluation of postfix lgorithm 2: infix to postfix lgorithm 3: evaluation of infix lgorithm 4: infix to tree Synthesis lgorithm
More informationSystem Programming. System Software: An Introduction to Systems Programming. Leland L. Beck 3rd Edition Addison-Wesley, 1997
System Programming System Software: An Introduction to Systems Programming Leland L. Beck 3rd Edition Addison-Wesley, 1997 1 http://web.thu.edu.tw/ctyang/ 2 http://hpc.csie.thu.edu.tw/ 3 Score List Participation:
More informationPrinciples of Programming Languages
Principles of Programming Languages Lecture 06 Implementation of Block Structured Languages 1 Activations and Environment Aspects of Subroutines: Static vs Dynamic! Static subroutine: code (``reentrant
More informationFunctions. Functions are everywhere in C. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
1 Functions Functions are everywhere in C Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Introduction Function A self-contained program segment that carries
More informationCS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University
CS558 Programming Languages Winter 2018 Lecture 4a Andrew Tolmach Portland State University 1994-2018 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.
More informationRun Time Environment. Activation Records Procedure Linkage Name Translation and Variable Access
Run Time Environment Activation Records Procedure Linkage Name Translation and Variable Access Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University
More informationChapter 10. Programming in C
Chapter 10 Programming in C Lesson 05 Functions in C C program Consists of three parts preprocessor directives macros main function functions 3 Function Each has a name (for identity ID) May have the arguments
More informationMonday, March 9, 2015
Monday, March 9, 2015 Topics for today C functions and Pep/8 subroutines Passing parameters by reference Globals Locals More reverse engineering: Pep/8 to C Representation of Booleans C Functions and Pep/8
More informationPointers as Arguments
Introduction as Arguments How it Works called program on start of execution xw = &i xf = &d after excution xw = &i xf = &d caller program i? d? i 3 d.14159 x 3.14159 x 3.14159 R. K. Ghosh (IIT-Kanpur)
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationECE 2574: Data Structures and Algorithms - Recursion Part I. C. L. Wyatt
ECE 2574: Data Structures and Algorithms - Recursion Part I C. L. Wyatt Today we will introduce the notion of recursion, look at some examples, and see how to implement them in code. Introduction to recursion
More informationCPSC 213. Introduction to Computer Systems. Readings for Next 2 Lectures. Loops (S5-loop) Control Flow. Static Control Flow. Unit 1d.
Readings for Next 2 Lectures Textbook CPSC 213 Condition Codes - Loops 3.6.1-3.6.5 Introduction to Computer Systems Unit 1d Static Control Flow Control Flow 1 Loops (S5-loop) 2 The flow of control is the
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More information1.Program to find factorial of a given number
1.Program to find factorial of a given number DATA SEGMENT X DW 06H FACT DW? DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV AX,01H ;Set the value of AX as 01H. MOV CX,X
More informationAlgorithm for siftdown(int currentposition) while true (infinite loop) do if the currentposition has NO children then return
0. How would we write the BinaryHeap siftdown function recursively? [0] 6 [1] [] 15 10 Name: template class BinaryHeap { private: int maxsize; int numitems; T * heap;... [3] [4] [5] [6] 114 0
More informationChapter 2 Assemblers Assembler Design Options
Chapter 2 Assemblers -- 2.4 Assembler Design Options Outline One-pass assemblers Multi-pass assemblers Two-pass assembler with overlay structure Load-and-Go Assembler Load-and-go assembler generates their
More informationSRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I
SRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I Year & Sem: I B.E (CSE) & II Date of Exam: 21/02/2015 Subject Code & Name: CS6202 & Programming & Data
More informationWednesday, April 16, 2014
Wednesday, pril 16, 2014 Topics for today Homework #5 solutions Code generation nalysis lgorithm 4: infix to tree Synthesis lgorithm 5: tree to code Optimization HW #5 solutions 1. lda 0,i ; for sum of
More informationMachine dependent Assembler Features
Machine dependent Assembler Features Assembler Features Machine Dependent Assembler Features Instruction formats and addressing modes (SIC/XE) Program relocation Machine Independent Assembler Features
More informationUNIT 1: MACHINE ARCHITECTURE
VTU QUESTION PAPER SOLUTION UNIT 1: MACHINE ARCHITECTURE 1. Give the target address generated for the following machine instruction: (i) 032600h (ii) 03C300h (iii) 0310C303h if (B)=006000, (PC)=003000,
More informationCSE 143. Complexity Analysis. Program Efficiency. Constant Time Statements. Big Oh notation. Analyzing Loops. Constant Time Statements (2) CSE 143 1
CSE 1 Complexity Analysis Program Efficiency [Sections 12.1-12., 12., 12.9] Count number of instructions executed by program on inputs of a given size Express run time as a function of the input size Assume
More informationIntermediate Formats. for object oriented languages
Intermediate Formats for object oriented languages Program Representation Goals Enable Program Analysis and Transformation Semantic Checks, Correctness Checks, Optimizations Structure Translation to Machine
More informationWednesday, February 28, 2018
Wednesday, February 28, 2018 Topics for today C functions and Pep/9 subroutines Introduction Location of subprograms in a program Translating functions (a) Void functions (b) Void functions with parameters
More informationMonday, October 17, 2016
Monday, October 17, 2016 Topics for today C functions and Pep/8 subroutines Passing parameters by reference Globals Locals Reverse Engineering II Representation of Booleans C Functions and Pep/8 Subroutines
More informationOverview of C, Part 2. CSE 130: Introduction to Programming in C Stony Brook University
Overview of C, Part 2 CSE 130: Introduction to Programming in C Stony Brook University Integer Arithmetic in C Addition, subtraction, and multiplication work as you would expect Division (/) returns the
More informationCPSC 213. Introduction to Computer Systems. Static Control Flow. Unit 1d
CPSC 213 Introduction to Computer Systems Unit 1d Static Control Flow 1 Reading Companion 2.7.1-2.7.3, 2.7.5-2.7.6 Textbook 3.6.1-3.6.5 2 Control Flow The flow of control is the sequence of instruction
More informationFlow Control. CSC215 Lecture
Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements
More information國立嘉義大學資訊工程學系系統程式期中考考卷
國立嘉義大學資訊工程學系系統程式期中考考卷 學號 : 姓名 : 1. Please write the content in the lines. (25%) PROGB START EXTDEF B1, B2 EXTREF A1 LDA B1 +LDA A1 STA B1 +STA A1 B1 WORD 7 BUF RESB 1 B2 RESW 1 MAX EQU 1 END H^PROGA^^
More informationComputer Systems Lecture 9
Computer Systems Lecture 9 CPU Registers in x86 CPU status flags EFLAG: The Flag register holds the CPU status flags The status flags are separate bits in EFLAG where information on important conditions
More informationTutorial 1: Programming Model 1
Tutorial 1: Programming Model 1 Introduction Objectives At the end of this lab you should be able to: Use the CPU simulator to create basic CPU instructions Use the simulator to execute the basic CPU instructions
More informationLambda Calculus. Variables and Functions. cs3723 1
Lambda Calculus Variables and Functions cs3723 1 Lambda Calculus Mathematical system for functions Computation with functions Captures essence of variable binding Function parameters and substitution Can
More informationC/C++ Programming Lecture 18 Name:
. The following is the textbook's code for a linear search on an unsorted array. //***************************************************************** // The searchlist function performs a linear search
More informationSubroutines. int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;}
Subroutines Also called procedures or functions Example C code: int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;} // subroutine converts Celsius to kelvin int celtokel(int i) { return (i
More informationSAS Macro Language: Reference
SAS Macro Language: Reference INTRODUCTION Getting Started with the Macro Facility This is the macro facility language reference for the SAS System. It is a reference for the SAS macro language processor
More informationECE264 Fall 2013 Exam 1, September 24, 2013
ECE264 Fall 2013 Exam 1, September 24, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.
More informationCS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri
CS356: Discussion #6 Assembly Procedures and Arrays Marco Paolieri (paolieri@usc.edu) Procedures Functions are a key abstraction in software They break down a problem into subproblems. Reusable functionality:
More informationCS A331 Programming Language Concepts
CS A331 Programming Language Concepts Lecture 9 Subroutines (Continued) March 17, 2014 Sam Siewert Exploration Questions from Before Why Does ANSI C not support Nested Functions? Why does GCC support anyway?
More informationprocedure definition (or declaration - some make a distinction, we generally won t), e.g., void foo(int x) {... }
Parameters Terminology: procedure invocation, e.g., (in different language notations) foo(a*8) x:=goo(19,a) call hoo() actual parameters, e.g., a*8 is an actual parameter of the above inv ocation of foo
More informationSystem Software Assignment 1 Runtime Support for Procedures
System Software Assignment 1 Runtime Support for Procedures Exercise 1: Nested procedures Some programming languages like Oberon and Pascal support nested procedures. 1. Find a run-time structure for such
More informationUnit 3 Functions. 1 What is user defined function? Explain with example. Define the syntax of function in C.
1 What is user defined function? Explain with example. Define the syntax of function in C. A function is a block of code that performs a specific task. The functions which are created by programmer are
More informationFunctions. Prof. Indranil Sen Gupta. Dept. of Computer Science & Engg. Indian Institute t of Technology Kharagpur. Introduction
Functions Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute t of Technology Kharagpur Programming and Data Structure 1 Function Introduction A self-contained program segment that
More informationAryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9
Fundamental of C Programming Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Q2. Write down the C statement to calculate percentage where three subjects English, hindi, maths
More informationIntermediate Programming, Spring 2017*
600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general
More informationLESSON 6 FLOW OF CONTROL
LESSON 6 FLOW OF CONTROL This lesson discusses a variety of flow of control constructs. The break and continue statements are used to interrupt ordinary iterative flow of control in loops. In addition,
More informationCHAD Language Reference Manual
CHAD Language Reference Manual INTRODUCTION The CHAD programming language is a limited purpose programming language designed to allow teachers and students to quickly code algorithms involving arrays,
More information'C' Programming Language
F.Y. Diploma : Sem. II [DE/EJ/ET/EN/EX] 'C' Programming Language Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define pointer. Write syntax
More informationCS64 Week 5 Lecture 1. Kyle Dewey
CS64 Week 5 Lecture 1 Kyle Dewey Overview More branches in MIPS Memory in MIPS MIPS Calling Convention More Branches in MIPS else_if.asm nested_if.asm nested_else_if.asm Memory in MIPS Accessing Memory
More informationCSCI565 Compiler Design
CSCI565 Compiler Design Spring 2011 Homework 4 Solution Due Date: April 6, 2011 in class Problem 1: Activation Records and Stack Layout [50 points] Consider the following C source program shown below.
More informationCOP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen
COP4020 Programming Languages Subroutines and Parameter Passing Prof. Robert van Engelen Overview Parameter passing modes Subroutine closures as parameters Special-purpose parameters Function returns COP4020
More informationCSE 230 Intermediate Programming in C and C++ Functions
CSE 230 Intermediate Programming in C and C++ Functions Fall 2017 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu http://www3.cs.stonybrook.edu/~cse230/ Concept of Functions
More information& Technology. G) Functions. void. Argument2, Example: (Argument1, Syllabus for 1. 1 What. has a unique. 2) Function name. passed to.
Computer Programming and Utilization (CPU) 110003 G) Functions 1 What is user defined function? Explain with example. Define the syntax of function in C. A function is a block of code that performs a specific
More informationPrinciples of Computer Architecture. Chapter 5: Languages and the Machine
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 5: Languages and the Machine 5-2 Chapter 5 - Languages and the Machine 5.1 The Compilation
More informationCS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their
More informationIntermediate Formats. Martin Rinard Laboratory for Computer Science
MIT 6.035 Intermediate Formats Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Program Representation Goals Enable Program Analysis and Transformation Semantic Checks,
More informationSAS Macro Dynamics - From Simple Basics to Powerful Invocations Rick Andrews, Office of the Actuary, CMS, Baltimore, MD
Paper BB-7 SAS Macro Dynamics - From Simple Basics to Powerful Invocations Rick Andrews, Office of the Actuary, CMS, Baltimore, MD ABSTRACT The SAS Macro Facility offers a mechanism for expanding and customizing
More informationLoaders. Systems Programming. Outline. Basic Loader Functions
Loaders Systems Programming Chapter 3 Linkers and Loaders A loader is a system program that performs the loading function. many also support relocation & linking others have a separate linker and loader
More informationChapter 9 Subroutines and Control Abstraction. June 22, 2016
Chapter 9 Subroutines and Control Abstraction June 22, 2016 Stack layout Common to have subroutine activation record allocated on a stack Typical fare for a frame: arguments, return value, saved registers,
More informationRun-Time Environments
1 Run-Time Environments Chapter 7 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2011 2 Procedure Activation and Lifetime A procedure is activated when called
More informationLearning C Language. For BEGINNERS. Remember! Practice will make you perfect!!! :D. The 6 th week / May 24 th, Su-Jin Oh
Remember! Practice will make you perfect!!! :D Learning C Language For BEGINNERS The 6 th week / May 24 th, 26 Su-Jin Oh sujinohkor@gmail.com 1 Index Basics Operator Precedence Table and ASCII Code Table
More informationCompilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1
Compilers 8. Run-time Support Laszlo Böszörmenyi Compilers Run-time - 1 Run-Time Environment A compiler needs an abstract model of the runtime environment of the compiled code It must generate code for
More information