Professional Documents
Culture Documents
3.2 Objectives: 1. To understand macro preprocessor and data structure for macro pass 1
3.3 Software used / Programming Languages Used: Turbo C/Code block/ C Language
3.4 THEORY:
A macro is unit of specification for program generation through expansion .A macro consists of a
name , a set of formal parameter and body of code. The use of macro name with setoff actual parameter
is reported by same code generated from its body. Thus is called macro expansion. A macro definition is
enclosed in a macro header statement and macro end .State macro definition consists of:
Macro processor:
The macro processor excepts an assembly language program, containing definition and calls
translate it into an assembly language which does not contain any program which does not contain any
macro processor. The program from which output by the macro processor can now be handed over to an
assembler to contain the target language from the program.
Thus macro processor segregates macro expansion from the process of program assembly . It is
economical because it can use any existing assembler. However it is not a efficient as macro assembler
i.e. an assemble that performs macro expansion as well as assembly,
Two pass macro processor –design by listing all task involved in macro expansion:
The following four step procedure i.e. followed to arrive at a design in specification for each
table:
In two pass assembler mainly two tasks involved in design of macro processor:
Example:
START
MOVER AREG,=’1’
MEND
MACRO XYZ,&ARG1
MOVER BREG,=’20’
SUB BREG,&ARG1
MEND
ABC A
XYZ B
A DC 10
B DC 20
END
STRAT
ABC A
XYZ B
A DC 10
B DC 20
END
Data structure:
1)ALA
3)MDT
Index Instruction
1 ABC &ARG1
2 MOVER AREG,=’1’
3 ADD AREG ,#1
4 MEND
5 XYZ &ARG
6 MOVER BREG ,=’20’
7 SUD BREG,#2
8 MEND
• SSNTAB-ptr =1
PNTTB –ptr=1
a)Name=macro
• #PP=RPDTAB-ptr
c)RPD-ptr=RPDTAB-ptr
• RPDTAB-ptr++
• PNTAB-ptr++
• #RP:=#RP++
e)MDTP=MDT-ptr
f)#EV=0
2.#EV=#EV+1
1.If the table field contains a sequencing symbol : If symbol is present in SSTAB then
g=SSNTAB-ptr
SSNTAB-ptr=SSNTAB –ptr+1
1.If a set statement then search each expansion variable used in the statement in EVNTAB
and generate spec(E,#M)
2.If an AIF or AOG statement then if sequencing symbol used in the statement is present in
SSNTAB else symbol SSNTAB[SSNTAB-ptr]
q=SSNTAB-ptr
SSNTAB-ptr=SSNTAB-ptr+1
4.MDT-ptr=MDT-ptr+1
3)MEND statement
Then
SSTP=0
Else
SSTAB-ptr=SSTAB-ptr+SSNTAB-ptr_1
3.5 CONCLUSION:
• Macro pass II uses macro definition table, macro name table, and parameter table as input to
produce the target assembly language code.
• It copies the assembly instructions without macro calls as it is while perform macro expansion on
encountering with macro instructions.
Signature of staff