Ss4 - SlideShare [PDF]

Jan 21, 2015 - The design of the macro processor is generally machine independent. 3. BASIC MACRO PROCESSOR FUNCTIONSBAS

37 downloads 31 Views 544KB Size

Recommend Stories


Definisi kenyamanan - SlideShare [PDF]
Jan 8, 2015 - Definisi Kenyamanan Kolcaba (1992, dalam Potter & Perry, 2005) megungkapkan kenyamanan/rasa nyaman adalah suatu keadaan telah terpenuhinya kebutuhan dasar manu…

Holt.doc - SlideShare [PDF]
Jun 21, 2010 - ... Alternatives •Vocabulary Workshop Tests •Test Answer Keys Available upon request, one per teacher, year of purchase 0030573998/Media Literacy and Communication Skills, 106.92 122.96 VCR and First Course Monitor •Support and P

Maine explosion - SlideShare [PDF]
Dec 19, 2013 - Which do you think would have been the most reliable story? Why ... Document B: New York Times (Modified) MAINE'S HULL WILL DECIDE Divers Will Inspect the Ship's Hull to Find Out Whether the Explosion Was from the Outside or ... Now, f

myntra ppt - SlideShare [PDF]
Mar 12, 2013 - Capabilities Order Processing and Delivery: Myntra attempts to order and ship every order within 24 hrs.It offers free shipping within India on all products It can ship internationally to all major countries. Technological: Myntra

Teater Bangsawan - SlideShare [PDF]
Dec 3, 2011 - Pada masa itulah anak-anak bangsawan berjaya mengolah, membentukdan menentukan gaya teater dramatik bangsawan sebagaimana yang ..... Dengan adanya kemampuankumpulan untuk mengetengahkan pelakon handalan yang berbakat,dan denganpenggunaa

Bmi - SlideShare [PDF]
Aug 3, 2012 - BMIWhat is BMI?How do you use BMI?By Kathryn Kotula, R.D., M.S., M.P.H..

Recruitment And Selection - SlideShare [PDF]
Apr 2, 2010 - EXECUTIVE SUMMARY People form an integral part of the organization. The efficiency and ... Recruitment and selection form the process of hiring the employees. ... Determine the present and future requirement of the organization in conju

Recruitment And Selection - SlideShare [PDF]
Apr 2, 2010 - EXECUTIVE SUMMARY People form an integral part of the organization. The efficiency and ... Recruitment and selection form the process of hiring the employees. ... Determine the present and future requirement of the organization in conju

Historia GRUPO GEA - SlideShare [PDF]
Apr 1, 2011 - Online Course - LinkedIn Learning. Folleto historia admon. Claudia Espinosa. Cómo hacer una práctica de lectura. jcrojo. Ensayos de Historia Económica. jcrojo. La aparición de la gran empresa moderna. jcrojo. Continuación estrategi

Sd1ips ips riduwan - SlideShare [PDF]
Feb 2, 2011 - Gambar 3.3 keluargatuliskan contoh-contoh sikap kasih sayang ayahdan ibu kepada dirimu Ilmu P. 2. kasih sayang antar keluarga. ... dalam keluarga 1. ...... yosef beragama kristen gusti beragama hindu Gambar 4.4belajar bersama mereka sal

Idea Transcript


SlideShare Explore Search You

Upload Login Signup

Search

Submit Search

Home Explore Presentation Courses PowerPoint Courses by LinkedIn Learning Search Successfully reported this slideshow.

1 of 87

Ss4 2,203 views Share Like Download ...

INTRODUCTIONINTRODUCTION A macro instruction (Macro) is a notational convenience for the programmer Allows the programm...

Jaya Chavan Follow

Published on Jan 21, 2015

about macro processor ... Published in: Engineering 0 Comments 4 Likes Statistics Notes

Full Name Comment goes here. 12 hours ago Delete Reply Spam Block Are you sure you want to Yes No BASIC MACRO PROCESSOR FUNCTIONSBASIC MACRO PROCESSOR FUNCTIONS Directives used during usage of Macro: Macro: Indicates ... Your message goes here

Share your thoughts… Post Be the first to comment

Sibin Prasad 2 weeks ago

MACRO EXPANSIONMACRO EXPANSION

Sruthi das , Student at college of engineering perumon 3 weeks ago

Rishabh Singh , Student at New Government Polytechnic, Patna-13 7 months ago

Tara ram Goyal , Student at Mbm Engineering College Jodhpur at Dotsquares 10 months ago No Downloads Views Total views 2,203 On SlideShare BASIC MACRO PROCESSORBASIC MACRO PROCESSOR FUNCTIONSFUNCTIONS 0 From Embeds 0 Number of Embeds 4 Actions Shares 0 Downloads 129 Comments 0 Likes 4 Embeds 0 No embeds No notes for slide

Ss4 1. 1. UNIT – IVUNIT – IV MACRO PROCESSORS 2. 2. INTRODUCTIONINTRODUCTION A macro instruction (Macro) is a notational convenience for the programmer Allows the programmer to write short hand programs (modular programming). The macro processor replaces each macro instruction with its equivalent block of instructions. The macro processor is not concerned with the meaning of MACRO INVOCATIONMACRO INVOCATION A macro invocation statement (a macro call) gives the name of the macro instruction bein... the involved statements during expansion. The design of the macro processor is generally machine independent. 3. 3. BASIC MACRO PROCESSOR FUNCTIONSBASIC MACRO PROCESSOR FUNCTIONS Directives used during usage of Macro: Macro: Indicates begin of Macro MEND: indicates end of Macro Prototype for Macro: Each argument starts with Name and macro Parameter list . . MEND BODY: The statement will be generated as the expansion of Macro 4. 4. MACRO EXPANSIONMACRO EXPANSION 5. 5. BASIC MACRO PROCESSORBASIC MACRO PROCESSOR FUNCTIONSFUNCTIONS 6. 6. MACRO INVOCATIONMACRO INVOCATION A macro invocation statement (a macro call) gives the name of the macro instruction being invoked and the arguments to be used in expanding the macro. macro_name p1, p2, … Difference between macro call and procedure call Macro call: statements of the macro body are expanded each time the macro is invoked. Procedure call: statements of the subroutine appear only one, regardless of how many times the subroutine is called. 7. 7. MACRO INVOCATIONMACRO INVOCATION Question How does a programmer decide to use macro calls or procedure calls? From the viewpoint of a programmer From the viewpoint of the CPU 8. 8. EXCHANGE THE VALUES OF TWOEXCHANGE THE VALUES OF TWO VARIABLESVARIABLES void exchange(int a, int b) { int temp; temp = a; a = b; b = temp; } main() { int i=1, j=3; printf("BEFORE - %d %dn", i, j); exchange(i, j); printf("AFTER - %d %dn", i, j); } What’s the result? 9. 9. 12 LINES OF ASSEMBLY CODE12 LINES OF ASSEMBLY CODE 10. 10. SWAP TWO VARIABLES BY MACROSWAP TWO VARIABLES BY MACRO #define swap(i,j) { int temp; temp=i; i=j; j=temp; } main() { int i=1, j=3; printf("BEFORE - %d %dn", i, j); swap(i,j); printf("AFTER - %d %dn", i, j); } 11. 11. BASIC MACRO PROCESSORBASIC MACRO PROCESSOR FUNCTIONSFUNCTIONS 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 12. 12. MACRO EXPANSIONMACRO EXPANSION Each macro invocation statement will be expanded into the statements that form the body of the macro. Arguments from the macro invocation are substituted for the parameters in the macro prototype (according to their positions). In the definition of macro: parameter In the macro invocation: argument 13. 13. MACRO EXPANSIONMACRO EXPANSION Comment lines within the macro body will be deleted. Macro invocation statement itself has been included as a comment line. The label on the macro invocation statement has been retained as a label on the first statement generated in the macro expansion. We can use a macro instruction in exactly the same way as an assembler language mnemonic. MACRO INVOCATIONMACRO INVOCATION Question How does a programmer decide to use macro calls or procedure calls? From th... 14. 14. MACRO INVOCATION: A PROGRAMMACRO INVOCATION: A PROGRAM 15. 15. MACRO EXPANSION: A PROGRAMMACRO EXPANSION: A PROGRAM 16. 16. MACRO EXPANSION: A PROGRAMMACRO EXPANSION: A PROGRAM 17. 17. MACRO EXPANSION: A PROGRAMMACRO EXPANSION: A PROGRAM 18. 18. NO LABEL IN MACRO BODYNO LABEL IN MACRO BODY Problem of the label in the body of macro: If the same macro is expanded multiple times at different places in the program … There will be duplicate labels, which will be treated as errors by the assembler. Solutions: Do not use labels in the body of macro. Explicitly use PCrelative addressing instead. Ex, in RDBUFF and WRBUFF macros, 19. 19. TWO-PASS MACRO PROCESSORTWO-PASS MACRO PROCESSOR You may design a two-pass macro processor Pass 1: Process all macro definitions Pass 2: Expand all macro invocation statements 20. 20. TWO-PASS MACRO PROCESSORTWO-PASS MACRO PROCESSOR However, one-pass may be enough Because all macros would have to be defined during the first pass before any macro invocations were expanded. The definition of a macro must appear before any statements that invoke that macro. Moreover, the body of one macro can contain definitions of other macros. 21. 21. EXAMPLE OF RECURSIVE MACROEXAMPLE OF RECURSIVE MACRO DEFINITIONDEFINITION MACROS (for SIC) Contains the definitions of RDBUFF and WRBUFF written in SIC instructions. 22. 22. RECURSIVE MACRO DEFINITIONRECURSIVE MACRO DEFINITION MACROX (for SIC/XE) Contains the definitions of RDBUFF and WRBUFF written in SIC/XE instructions. 23. 23. MACRO DEFINITION: AN EXAMPLEMACRO DEFINITION: AN EXAMPLE A program that is to be run on SIC system could invoke MACROS whereas a program to be run on SIC/XE can invoke MACROX. However, defining MACROS or MACROX does not define RDBUFF and WRBUFF. These definitions are processed only when an invocation of MACROS or MACROX is expanded. 24. 24. ONE-PASS MACRO PROCESSORONE-PASS MACRO PROCESSOR A one-pass macro processor that alternate between macro definition and macro expansion in a recursive way is able to handle recursive macro definition. Restriction The definition of a macro must appear in the source program before any statements that invoke that macro. This restriction does not create any real inconvenience. 25. 25. DATA STRUCTURE FOR ONE-PASSDATA STRUCTURE FOR ONE-PASS MACRO PROCESSORMACRO PROCESSOR DEFTAB (definition table) Stores the macro definition including macro prototype and macro body Comment lines are omitted. References to the macro instruction parameters are converted to a positional notation for efficiency in substituting arguments. 26. 26. DATA STRUCTURE FOR ONE-PASSDATA STRUCTURE FOR ONE-PASS MACRO PROCESSORMACRO PROCESSOR NAMTAB Stores macro names Serves as an index to DEFTAB Pointers to the beginning and the end of the macro definition (DEFTAB) ARGTAB Stores the arguments of macro invocation according to their positions in the argument list As the macro is expanded, arguments from ARGTAB are substituted for the corresponding parameters in the macro body. 27. 27. DATA STRUCTUREDATA STRUCTURE 28. 28. NEXT – AFTER A BREAKNEXT – AFTER A BREAK Algorithms Nested macros Comparison of different macro design Machine-Independent macro features 29. 29. ALGORITHMALGORITHM 30. 30. ALGORITHMALGORITHM 31. 31. ALGORITHMALGORITHM 32. 32. ALGORITHMALGORITHM 33. 33. HANDLING NESTED MACROHANDLING NESTED MACRO In DEFINE procedure When a macro definition is being entered into DEFTAB, the normal approach is to continue until an MEND directive is reached. This would not work for nested macro definition because the first MEND encountered in the inner macro will terminate the whole macro definition process. 34. 34. HANDLING NESTED MACROHANDLING NESTED MACRO To solve this problem, a counter LEVEL is used to keep track of the level 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. 35. 35. COMPARISON OF MACROCOMPARISON OF MACRO PROCESSOR DESIGNPROCESSOR DESIGN One-pass algorithm Every macro must be defined before it is called One-pass processor can alternate between macro definition and macro expansion Nested macro definitions are allowed but nested calls are not 36. 36. COMPARISON OF MACROCOMPARISON OF MACRO PROCESSOR DESIGNPROCESSOR DESIGN Two-pass algorithm Pass1: Recognize macro definitions Pass2: Recognize macro calls Nested macro definitions are not allowed 37. 37. MACHINE-INDEPENDENT MACROMACHINE-INDEPENDENT MACRO PROCESSOR FEATURESPROCESSOR FEATURES 38. 38. CONCATENATION OF MACROCONCATENATION OF MACRO PARAMETERSPARAMETERS Concatenation parameters with other character strings. Used when a program consists a set of series of variables. 39. 39. COMPARISON OF MACROCOMPARISON OF MACRO PROCESSOR DESIGNPROCESSOR DESIGN Ambiguity problem If &ID and &ID1 are parameters 12 LINES OF ASSEMBLY CODE12 LINES OF ASSEMBLY CODE Solution to this ambiguity problem Use a special concatenation operator “- >” to specify the end of the parameter 40. 40. COMPARISON OF MACROCOMPARISON OF MACRO PROCESSOR DESIGNPROCESSOR DESIGN 41. 41. GENERATING UNIQUE LABELSGENERATING UNIQUE LABELS Labels in the macro body may cause “duplicate labels” problem if the macro is invocated and expanded multiple times. Ex: •Use of relative addressing at the source statement level is very inconvenient, error-prone, and difficult to read. 42. 42. GENERATING UNIQUE LABELSGENERATING UNIQUE LABELS Let the macro processor generate unique labels for each macro invocation and expansion. During macro expansion, the $ will be replaced with $xx, where xx is a two-character alphanumeric counter of the number of macro instructions expanded. xx=AA,AB,AC, ….. This allows 1296 macro expansions in a single program. 43. 43. GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS 44. 44. GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS 45. 45. GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS Conditional assembly depends on parameters provided Part I is expanded if condition part is true, otherwise part II is expanded Compare operator: NE, EQ, LE, GT 46. 46. GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS Begins with “&” but is not a macro instruction parameter Can be used to store working values during the macro expansion -Store the evaluation result of Boolean expression -Control the macro-time conditional structures Be initialized to a value of 0 Be set by a macro processor directive, SET Ex: &EORCK SET 1 &EORCTR SET &EORCTR + 1 47. 47. GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS 48. 48. GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS 49. 49. GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS 50. 50. GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS 51. 51. MACRO-TIME LOOPINGMACRO-TIME LOOPING WHILE ( cond ) …… ENDW Macro processor function %NITEMS: The number of members in an argument list The execution of testing of IF/WHILE, SET, - %NITEMS() occurs at macro expansion time 52. 52. USE OF MACRO-TIME LOOPINGUSE OF MACRO-TIME LOOPING STATEMENTSTATEMENT 53. 53. USE OF MACRO-TIME LOOPINGUSE OF MACRO-TIME LOOPING STATEMENTSTATEMENT 54. 54. IMPLEMENTATION-CONDITIONALIMPLEMENTATION-CONDITIONAL MACRO EXPANSIONMACRO EXPANSION IF-ELSE-ENDIF structure The macro SWAP TWO VARIABLES BY MACROSWAP TWO VARIABLES BY MACRO #define swap(i,j) { int temp; temp=i; i=j; j=temp; } main() { int i... processor must maintain a symbol table -This table contains the values of all macro-time variables used. - Entries in this table are made or modified when SET statements are processed. - This table is used to look up the current value of a macro-time variable whenever it is required. 55. 55. IMPLEMENTATION-CONDITIONALIMPLEMENTATION-CONDITIONAL MACRO EXPANSIONMACRO EXPANSION When an IF statement is encountered during the expansion of a macro, the specified Boolean expression is evaluated. TRUE The macro processor continues to process lines from DEFTAB until it encounters the next ELSE or ENDIF statement. If ELSE is encountered, then skips to END FALSE The macro processor skips ahead in DEFTAB until it finds the next ELSE or ENDIF statement. 56. 56. IMPLEMENTATION-CONDITIONALIMPLEMENTATION-CONDITIONAL MACRO EXPANSIONMACRO EXPANSION When an IF statement is encountered during the expansion of a macro, the specified Boolean expression is evaluated. -TRUE The macro processor continues to process lines from DEFTAB until it encounters the next ENDW statement. When ENDW is encountered, the macro processor returns to the preceding WHILE, re-evaluates the Boolean expression, and takes action based on the new value. 57. 57. IMPLEMENTATION-CONDITIONALIMPLEMENTATION-CONDITIONAL MACRO EXPANSIONMACRO EXPANSION FALSE -- The macro processor skips ahead in DEFTAB until it finds the next ENDW statement and then resumes normal macro expansion. 58. 58. SUMMARYSUMMARY Algorithms Nested macros Comparison of different macro design Machine-Independent macro features Implementation of conditional macros 59. 59. NEXT – AFTER A BREAKNEXT – AFTER A BREAK Keyword macro parameters Recursive Macros Line-by-Line Macros Integrated Macros 60. 60. USE OF MACRO-TIME LOOPINGUSE OF MACRO-TIME LOOPING STATEMENTSTATEMENT 61. 61. IMPLEMENTATION-CONDITIONALIMPLEMENTATION-CONDITIONAL MACRO EXPANSIONMACRO EXPANSION IF-ELSE-ENDIF structure The macro processor must maintain a symbol table Entries in this table are made or modified when SET statements are processed. This table is used to look up the current value of a macro-time variable whenever it is required. This table contains the values of all macro-time variables used. 62. 62. IMPLEMENTATION-CONDITIONALIMPLEMENTATION-CONDITIONAL MACRO EXPANSIONMACRO EXPANSION When an IF statement is encountered during the expansion of a macro, the specified Boolean expression is evaluated. TRUE The macro processor continues to process lines from DEFTAB until it encounters the next ELSE or ENDIF statement. If ELSE is encountered, then skips to ENDIF FALSE The macro processor skips ahead in DEFTAB until it finds the next ELSE or ENDIF statement. 63. 63. IMPLEMENTATION-CONDITIONALIMPLEMENTATION-CONDITIONAL MACRO EXPANSIONMACRO EXPANSION WHILE-ENDW structure When an WHILE statement is encountered during the expansion of a macro, the specified Boolean expression is evaluated. TRUE -- The macro processor continues to process lines from DEFTAB until it encounters the next ENDW statement. -- When ENDW is encountered, the macro processor returns to the preceding WHILE, re- evaluates the Boolean expression, and takes action based on the new value. 64. 64. IMPLEMENTATION-CONDITIONALIMPLEMENTATION-CONDITIONAL MACRO EXPANSIONMACRO EXPANSION FALSE -- The macro processor skips ahead in DEFTAB until it finds the next ENDW statement and then resumes normal macro expansion. 65. 65. KEYWORD MACRO PARAMETERSKEYWORD MACRO PARAMETERS Keyword macro parameters Positional parameters and arguments are associated according to their positions in the macro prototype and invocation. If an argument is to be omitted, a null argument should be used to maintain the proper order in macro invocation: Ex: XXX MACRO &P1, &P2, …., &P20, …. XXX A1, A2,,,,,,,,,,…,,A20,….. 66. 66. KEYWORD MACRO PARAMETERSKEYWORD MACRO PARAMETERS It is not suitable if a macro has a large number of parameters, and only a few of these are given values in a typical invocation. 67. 67. KEYWORD MACRO PARAMETERSKEYWORD MACRO PARAMETERS Keyword Parameters Each argument is written with the keyword that names the corresponding parameter. Argument may appear any order. Null arguments are no longer required to be used. It is easier, less error prone and readable form to have keyword parameter than positional parameter. 68. 68. KEYWORD MACRO PARAMETERSKEYWORD MACRO PARAMETERS Keyword Parameters Each argument is written with the keyword that names the corresponding parameter. Argument may appear any order. Null arguments are no longer required to be used. It is easier, less error prone and readable form to have keyword parameter than positional parameter. Ex P1=A1, P2=A2, … P20=A20 69. 69. USE OF KEYWORD MACROUSE OF KEYWORD MACRO PARAMETERSPARAMETERS 70. 70. USE OF KEYWORD PARAMETERS INUSE OF KEYWORD PARAMETERS IN MACROMACRO 71. 71. USE OF KEYWORD PARAMETERS INUSE OF KEYWORD PARAMETERS IN MACROMACRO 72. 72. RECURSIVE MACRO EXPANSIONRECURSIVE MACRO EXPANSION 73. 73. RECURSIVE MACRO EXPANSIONRECURSIVE MACRO EXPANSION 74. 74. PROBLEM OF RECURSIVE MACROPROBLEM OF RECURSIVE MACRO PARAMETERSPARAMETERS Previous Macro Design Doesn’t take care of recursive macro expansion. Problems: When procedure EXPAND is called recursively the invocation argument in the ARGTAB will be overwritten. The boolean variable Expand would set to false when the inner macro expansion is completed without having an idea that the it is part of another outer macro whose expansion is still not completed. 75. 75. PROBLEM OF RECURSIVE MACROPROBLEM OF RECURSIVE MACRO PARAMETERSPARAMETERS Previous Macro Design Doesn’t take care of recursive MACRO EXPANSIONMACRO EXPANSION Each macro invocation statement will be expanded into the statements that form the body of... macro expansion. Solutions: Write the macro processor in a programming language which automatically takes care of the recursive calls thus retaining the local variables. If written in a language without recursion support, use a stack to take care of pushing and popping the local variables and return addresses thus retaining their values. 76. 76. GENERAL PURPOSE MACROGENERAL PURPOSE MACRO PROCESSORSPROCESSORS Macro processor that do not depend on any particular language, can be used with variety of languages. Pros Programmers do not need not learn any macro language. Although its development costs is little high than those for the language specific macro processor, but these macros does not need to be repeated for every language. 77. 77. GENERAL PURPOSE MACROGENERAL PURPOSE MACRO PROCESSORSPROCESSORS Macro processor that do not depend on any particular language, can be used with variety of languages. Cons Large number of details must be dealt within a programming language. Situations in which normal macro parameter substitution should not occur, e.g., comments. Facilities for grouping together terms, expressions, or statements Tokens, e.g., identifiers, constants, operators, keywords. Syntax must be consistent with the programming language. 78. 78. MACRO PROCESSING WITHINMACRO PROCESSING WITHIN LANGUAGE TRANSLATORSLANGUAGE TRANSLATORS Macro processor discussed so far are preprocessors that Process macro definitions Expand macro invocation Produces an expanded version of the macro at the place of the call and then use it by the assembler or the compiler. Macro processing functions can be combined with the language translators. Line-by-line macro processors Integrated macro processors 79. 79. LINE-BY-LINE MACROLINE-BY-LINE MACRO PROCESSORSPROCESSORS Used as sort of input routine the assembler or compiler. Read source program. Handle macro definition and expand the invocation. Pass output lines to the assembler or compiler. Benefits Avoid making an extra pass over the source program. Data structures required by the translators and the macro processor can be kept same. Utility subroutines by the translators and the macros can be kept same. Scanning input lines, Searching tables. 80. 80. INTEGRATED MACRO PROCESSORSINTEGRATED MACRO PROCESSORS An integrated macro processor can make use of any information about the source program that is extracted by the language translators An integrated macro processor can support macro instructions that depend upon the context in which they occur. 81. 81. INTEGRATED MACRO PROCESSORSINTEGRATED MACRO PROCESSORS Definitions and invocations of macros are handled by a preprocessor, which is generally not integrated with the rest of the compiler. Example #DEFINE NULL 0 #DEFINE EOF (-1) #DEFINE EQ == #DEFINE ABSDIF (x, y) {X>Y? X-Y:Y-X} 82. 82. INTEGRATED MACRO PROCESSORSINTEGRATED MACRO PROCESSORS Parameter substitutions are not performed within quoted. #define DISPLAY( EXPR) printf(“ EXPR= %d n”, EXPR) Example DISPLAY( I* J+ 1) ==> printf(“ EXPR = %d n”, I* J+ 1) 83. 83. INTEGRATED MACRO PROCESSORSINTEGRATED MACRO PROCESSORS Recursive macro definitions or invocations After a macro is expanded, the macro processor rescans the text that has been generated, looking for more macro definitions or invocations. Macro cannot invoke or define itself recursively. Example DISPLAY( MACRO EXPANSIONMACRO EXPANSION Comment lines within the macro body will be deleted. Macro invocation statement itself ha... ABSDIFF( 3, 8)) SCANS printf(“ ABSDIFF( 3, 8)” “= %d n”, ABSDIFF( 3, 8)) RESCANS printf(“ ABSDIFF( 3, 8)” “= %d n”, ( (3)>( 8) ? (3) - (8) : (8)-( 3) )) 84. 84. ANSI C MACRO LANGUAGEANSI C MACRO LANGUAGE Conditional compilation statements Example 1 #ifndef BUFFER_ SIZE #define BUFFER_ SIZE 1024 #endif Example 2 #define DEBUG 1 : #if DEBUG == 1 printf(…) /* debugging outout */ #endif 85. 85. MACRO MACRO PROCESSORMACRO MACRO PROCESSOR ABSDIF J,K MOV AX,J SUB AX, K JNS ??0000 NEG AX ??0000: 86. 86. MACRO MACRO PROCESSORMACRO MACRO PROCESSOR ABSDIF MACRO OP1, OP2, SIZE LOCAL EXIT IFNB IFDIF ;ERR EXITM ENDIF ENDIF MOV SIZEE&AX, OP1 SUB SIZE&AX, OP2 JNS EXIT NEG SIZE&AX EXIT: ENDM 87. 87. SUMMARYSUMMARY Algorithms Nested macros Comparison of different macro design Machine-Independent macro features Implementation of conditional macros

MACRO INVOCATION: A PROGRAMMACRO INVOCATION: A PROGRAM Recommended

MACRO EXPANSION: A PROGRAMMACRO EXPANSION: A PROGRAM

Academic Research Foundations: Quantitative Online Course - LinkedIn Learning

MACRO EXPANSION: A PROGRAMMACRO EXPANSION: A PROGRAM

MACRO EXPANSION: A PROGRAMMACRO EXPANSION: A PROGRAM

Training Tips Weekly Online Course - LinkedIn Learning

NO LABEL IN MACRO BODYNO LABEL IN MACRO BODY Problem of the label in the body of macro: If the same macro is expanded m...

College Prep: Writing a Strong Essay Online Course - LinkedIn Learning

Unit 4 sp macro TWO-PASS MACRO PROCESSORTWO-PASS MACRO PROCESSOR You may design a two-pass macro processor Pass 1: Process all macro ... Deepmala Sharma

Assemblers: Ch03 desta_gebre

RECURSIVE DESCENT PARSING Jothi Lakshmi

Loader and Its types Parth Dodiya

TWO-PASS MACRO PROCESSORTWO-PASS MACRO PROCESSOR However, one-pass may be enough Because all macros would have to be de... Introduction to loaders Tech_MX

Single pass assembler amyiyer

System Programming Unit II Manoj Patil English Español Português Français Deutsch About Dev & API Blog Terms Privacy Copyright Support

LinkedIn Corporation © 2017 × Share Clipboard × Email

Enter email addresses Add a message From



Send Email sent successfully.. Facebook Twitter LinkedIn Link Public clipboards featuring this slide

×

MACRO DEFINITION: AN EXAMPLEMACRO DEFINITION: AN EXAMPLE A program that is to be run on SIC system could invoke MACROS w...

ONE-PASS MACRO PROCESSORONE-PASS MACRO PROCESSOR A one-pass macro processor that alternate between macro definition and ...

No public clipboards found for this slide ×

Save the most important slides with Clipping Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics. Start clipping No thanks. Continue to download. Select another clipboard ×

DATA STRUCTUREDATA STRUCTURE

Looks like you’ve clipped this slide to already. Search for a clipboard Create a clipboard

You just clipped your first slide! Clipping is a handy way to collect important slides you want to go back to later. Now customize the name of a clipboard to store your clips. Name* Best of Slides



Description Add a brief description so others know what your Clipboard is about. Visibility Others can see my Clipboard NEXT – AFTER A BREAKNEXT – AFTER A BREAK Algorithms Nested macros Comparison of different macro design Machine-Indepen... Cancel Save Save this presentationTap To Close

ALGORITHMALGORITHM

ALGORITHMALGORITHM

ALGORITHMALGORITHM

ALGORITHMALGORITHM

HANDLING NESTED MACROHANDLING NESTED MACRO In DEFINE procedure When a macro definition is being entered into DEFTAB, ...

HANDLING NESTED MACROHANDLING NESTED MACRO To solve this problem, a counter LEVEL is used to keep track of the level of m...

MACHINE-INDEPENDENT MACROMACHINE-INDEPENDENT MACRO PROCESSOR FEATURESPROCESSOR FEATURES

COMPARISON OF MACROCOMPARISON OF MACRO PROCESSOR DESIGNPROCESSOR DESIGN

GENERATING UNIQUE LABELSGENERATING UNIQUE LABELS Labels in the macro body may cause “duplicate labels” problem if the ma...

GENERATING UNIQUE LABELSGENERATING UNIQUE LABELS Let the macro processor generate unique labels for each macro invocat...

GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS

GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS

GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS Conditional assembly depends on parameters provided Part I is exp...

GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS Begins with “&” but is not a macro instruction parameter Can be...

GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS

GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS

GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS

GENERATION OF UNIQUE LABELSGENERATION OF UNIQUE LABELS

MACRO-TIME LOOPINGMACRO-TIME LOOPING WHILE ( cond ) …… ENDW Macro processor function %NITEMS: The number of members in...

USE OF MACRO-TIME LOOPINGUSE OF MACRO-TIME LOOPING STATEMENTSTATEMENT

USE OF MACRO-TIME LOOPINGUSE OF MACRO-TIME LOOPING STATEMENTSTATEMENT

SUMMARYSUMMARY Algorithms Nested macros Comparison of different macro design Machine-Independent macro features Imple...

NEXT – AFTER A BREAKNEXT – AFTER A BREAK Keyword macro parameters Recursive Macros Line-by-Line Macros Integrated Macr...

USE OF MACRO-TIME LOOPINGUSE OF MACRO-TIME LOOPING STATEMENTSTATEMENT

KEYWORD MACRO PARAMETERSKEYWORD MACRO PARAMETERS Keyword macro parameters Positional parameters and arguments are assoc...

KEYWORD MACRO PARAMETERSKEYWORD MACRO PARAMETERS It is not suitable if a macro has a large number of parameters, and only...

USE OF KEYWORD MACROUSE OF KEYWORD MACRO PARAMETERSPARAMETERS

USE OF KEYWORD PARAMETERS INUSE OF KEYWORD PARAMETERS IN MACROMACRO

USE OF KEYWORD PARAMETERS INUSE OF KEYWORD PARAMETERS IN MACROMACRO

RECURSIVE MACRO EXPANSIONRECURSIVE MACRO EXPANSION

RECURSIVE MACRO EXPANSIONRECURSIVE MACRO EXPANSION

LINE-BY-LINE MACROLINE-BY-LINE MACRO PROCESSORSPROCESSORS Used as sort of input routine the assembler or compiler. Rea...

INTEGRATED MACRO PROCESSORSINTEGRATED MACRO PROCESSORS An integrated macro processor can make use of any information abo...

INTEGRATED MACRO PROCESSORSINTEGRATED MACRO PROCESSORS Definitions and invocations of macros are handled by a preprocess...

INTEGRATED MACRO PROCESSORSINTEGRATED MACRO PROCESSORS Parameter substitutions are not performed within quoted. #defin...

INTEGRATED MACRO PROCESSORSINTEGRATED MACRO PROCESSORS Recursive macro definitions or invocations After a macro is expan...

ANSI C MACRO LANGUAGEANSI C MACRO LANGUAGE Conditional compilation statements Example 1 #ifndef BUFFER_ SIZE #define BUFFE...

MACRO MACRO PROCESSORMACRO MACRO PROCESSOR ABSDIF J,K MOV AX,J SUB AX, K JNS ??0000 NEG AX ??0000:

SUMMARYSUMMARY Algorithms Nested macros Comparison of different macro design Machine-Independent macro features Imple...

Upcoming SlideShare

Loading in …5

×

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.