Unit 2 Macro Processors and compilers Flashcards
What is a macro?
Unit of specification for program generation through expansion.
It defines new operation or a new method of declaring data.
Macro expansion:
Macro name with parameters is replaced by some code generated from its body.
Macro Processor tasks:
- Recognise macro definitions
- Save it.
- Recognise macro calls
- expand macro calls
Compare MAcro with
functions
Types of Macro Expansion:
- Lexical 2. Semantic
Lexical Expansion
- Replace formal args by actual args.
- Replace a char string by another char string.
Generate assembly statement from model statement.
Semantic Satiation:
Generation of instructions tailored to requirements of a specific usage.
It makes it more adaptive.
Conditional stuff.
Macro Definition:
it consists of name of macro, params (optional), body.
Definition enclosed btw macro and mend.
macro name \: body instructions \: mend
formal paramter specification:
&[] refer ppt
types of param :
- Positional (Default)
- Keyword
- default specification of param
- Macro with mixed param lists.
Macro call:
[[,..]]
refer ppt
macro name, appears in the mnemonic opcode field of the assembly statement.
check chapter 3 in tht book
for similarities in actual param specification and operand specification.
+
it’s apparently used to differentiate btw original statements and macro statements.
pata naheee
Expansion time control flow:
- If no preprocessor statements then its sequentially.
- Macro Exansion Counter (MEC) helps in implementation of flow control.
strings that Model statement has:
- Ordinary string that stand for itself.
- name formal params preceded by &.
- name of preprocessor variable preceeded by &.
Positional Param :
written as &
formal param take value of actual param at same position.
Keyword param:
for this, when calling macro, actual pram spec is written as =
refer ppt < . >
look at macro definition for them as well
&name=
Default specifications with paramenters:
assign a default value in the macro definition, usually at last.
so if when calling, no value assigned to this arg then default val is automatically assigned
more about args.. order?
Positional before keyword