BIRLA INSTITUE OF TECHNOLOGY,MESRA
JAIPUR CAMPUS
TOPIC : MACRO ASSEMBLER
BY
MEGHAJ KUMAR MALLICK
(MCA/25017/18)
MCA 2ND YEAR, 4TH SEMESTER
Design of a Macro Assembler
Design of Macro Assembler
• 3 passes in macro Assembler.
Pass 1:
– Macro definition processing.
– SYMTAB construction.
Pass 2:
– Macro expansion.
– Memory allocation & LC processing.
– Processing of Literals.
– Intermediate Code Generation.
pass 3:
– Target code Generation.
– Macro processor can be added asa
processor to an assembler.
– It is implemented in pass 1 of the
assembler.
Design of Macro AssembleR
Advantages:
– Many functions don’t have to be
implemented twice.
– Less overhead during processing.(by
removing intermediate code)
– More flexibility is available to the
programmer.
Design of Macro AssembleR
Disadvantages:
• Combined pass 1 of the assembler &
macro processor may be too large for a
program to fit into core of some
machine.
• Complexity of such program maybe
overwhelming.
Design of Macro AssembleR
PAPASSSPASS 1
R
SeSeararcchh
ppsseeuuddoo-o-oppTTablabl
Search
pseudo-op Table
SeSeararcchh
MMacacrroonnamamee TTaablbl
Search
Macro name Table
SeSeararcchh
mmaacchihinnee-o-opp TTbllee
Search
machine-op Table
GGoo ttoo
PAPASSS
S22
Go to
PASS 2Type ?
Process
Process
Pseudo-ops
Process
Machine instruction
Setup macro
stack frame ,etc.
READ
R
R
R
Maccro definition
Found, macro
calls R
Found
Not
Not
End
pseudo-op
Others
Macro
pseudo-op
Microsoft Macro Assembler
 MASM is an assembler for the x86 family of microprocessors,
originally produced MS-DOS operating system. The MASM is the
example of high level assembler. It supports following main
features-
i) A wide variety of macro facilities
ii) Structure programming idioms
iii)High level constructions for looping, procedure calls , and
alteration
The later versions of MASM added the capability of producing
program for the windows operating system. The example of this
type is MASM – 32 which work on the program which already
written API based code in windows .
Comparison of Macro Processors
Design
Single pass
 every macro must be defined before it is called
 one-pass processor can alternate between macro definition and
macro expansion
 nested macro definitions may be allowed but nested calls are
not
 Two pass
 Pass1: Recognize macro definitions
 Pass2: Recognize macro calls
 nested macro definitions are not allowed
Tables generated while macro
processing
The macro processing leads to generation of three
types of tables –
1. DEFTAB – the definition of the macro is stored in
this table.
2. NAMTAB – the name of the macro is stored in
this table.
3. ARGTAB – all the arguments of macro is stored
in this table.
MACRO ASSEBLER

MACRO ASSEBLER

  • 1.
    BIRLA INSTITUE OFTECHNOLOGY,MESRA JAIPUR CAMPUS TOPIC : MACRO ASSEMBLER BY MEGHAJ KUMAR MALLICK (MCA/25017/18) MCA 2ND YEAR, 4TH SEMESTER
  • 2.
    Design of aMacro Assembler
  • 3.
    Design of MacroAssembler • 3 passes in macro Assembler. Pass 1: – Macro definition processing. – SYMTAB construction. Pass 2: – Macro expansion. – Memory allocation & LC processing. – Processing of Literals. – Intermediate Code Generation.
  • 4.
    pass 3: – Targetcode Generation. – Macro processor can be added asa processor to an assembler. – It is implemented in pass 1 of the assembler. Design of Macro AssembleR
  • 5.
    Advantages: – Many functionsdon’t have to be implemented twice. – Less overhead during processing.(by removing intermediate code) – More flexibility is available to the programmer. Design of Macro AssembleR
  • 6.
    Disadvantages: • Combined pass1 of the assembler & macro processor may be too large for a program to fit into core of some machine. • Complexity of such program maybe overwhelming. Design of Macro AssembleR
  • 7.
    PAPASSSPASS 1 R SeSeararcchh ppsseeuuddoo-o-oppTTablabl Search pseudo-op Table SeSeararcchh MMacacrroonnamameeTTaablbl Search Macro name Table SeSeararcchh mmaacchihinnee-o-opp TTbllee Search machine-op Table GGoo ttoo PAPASSS S22 Go to PASS 2Type ? Process Process Pseudo-ops Process Machine instruction Setup macro stack frame ,etc. READ R R R Maccro definition Found, macro calls R Found Not Not End pseudo-op Others Macro pseudo-op
  • 8.
    Microsoft Macro Assembler MASM is an assembler for the x86 family of microprocessors, originally produced MS-DOS operating system. The MASM is the example of high level assembler. It supports following main features- i) A wide variety of macro facilities ii) Structure programming idioms iii)High level constructions for looping, procedure calls , and alteration The later versions of MASM added the capability of producing program for the windows operating system. The example of this type is MASM – 32 which work on the program which already written API based code in windows .
  • 9.
    Comparison of MacroProcessors Design Single pass  every macro must be defined before it is called  one-pass processor can alternate between macro definition and macro expansion  nested macro definitions may be allowed but nested calls are not  Two pass  Pass1: Recognize macro definitions  Pass2: Recognize macro calls  nested macro definitions are not allowed
  • 10.
    Tables generated whilemacro processing The macro processing leads to generation of three types of tables – 1. DEFTAB – the definition of the macro is stored in this table. 2. NAMTAB – the name of the macro is stored in this table. 3. ARGTAB – all the arguments of macro is stored in this table.