SlideShare a Scribd company logo
1 of 65
Macro and Macro processor
ο‚ž   Macro:-
    ο‚— Macro instructions are single line
     abbreviations for group of instructions.
ο‚ž   Using a macro, programmer can define
    a single β€œinstruction” to represent block
    of code.
MACRO -------- Start of definition
INCR     -------- Macro name
A 1,DATA
A 2,DATA       ------Sequence of instructions to
  be
A 3,DATA                 abbreviated
MEND         --------   End of definition
Macro Expansion
ο‚ž   Replacement of macro call by
    corresponding sequence of instructions
    is called as macro expansion
Source   Expanded source
Macro                                  :
Incr                                    :
A      1, data                          :
A      2, data                          :
A      3, data                          :
MEND                                    :
       :                           A 1, Data
       :                           A 2, Data
INCR                               A 3, Data
       :                                :
       :                                :
INCR                                    :
       :                           A 1, Data
       :                           A 2, Data
data DC          F’5’              A 3, Data
       :                          data DC F β€˜5’
       :
END
Features of macro facility
Macro instructions arguments
      :
      :
      A 1,data1
      A 2,data1
      A 3,data1
      :
      :
      A 1,data2
      A 2,data2
      A 3,data2
      :
      Data1 DC Fβ€Ÿ5β€Ÿ
      Data2 DC Fβ€Ÿ6β€Ÿ
Source                         Expanded Source
MACRO                          :
INCR &arg (Macro name with     :
A 1,&arg       one argument)   :
A 2,&arg                       :
A 3,&arg                       :
MEND                           A 1,data1
:                              A 2,data1
:                              A 3,data1
INCR data1 (use of data1 as    :
:              operand)        A 1,data2
:                              A 2,data2
INCR data 2 (use of data1 as   A 3,data2
:              operand)        :
data1 DC F’5’                  :
data2 DC F’6’                  data1 DC F’5’
:                              data2 DC F’6’
END
Example: more than one
arguments.
   A 1,data1
   A 2,data2
   A 3,data3
   :
   A 1,data3
   A 2,data2
   A 3,data1
   :
   data1 DC Fβ€Ÿ5β€Ÿ
   data2 DC Fβ€Ÿ6β€Ÿ
Source                          Expanded source
                       MACRO                 :
& lab1 INCR & arg 1, & arg 2, & arg 3        :
& lab 1 A      1, &arg1                      :
        A      2, &arg2                      :
        A      3, &arg3                      :
        MEND                                 :
        :                                    :
        :                                    :
        :                               LOOP 1 A 1, data 1
LOOP1 INCR data1, data2, data3                       A 2, data 2
        :                                            A 3, data 3
        :                                        :
        :                                        :
LOOP2 INCR data3, data2, data1          LOOP 2 A 1, data3
        :                                            A 2, data2
        :                                            A 3, data1
data1 DC       F β€˜5’                             :
data2   DC     F β€˜6’                    data1 DC F β€˜5’
data3 DC       F β€˜7’                    data2 DC F β€˜6’
                                        data3 DC F β€˜7’
Two ways of specifying
arguments to a macro call
ο‚ž A) Positional argument
Argument are matched with dummy
  arguments according to order in which
  they appear.
ο‚ž INCR A,B,C
ο‚ž    β€žAβ€Ÿ replaces first dummy argument
ο‚ž    β€žBβ€Ÿ replaces second dummy argument
ο‚ž    β€žCβ€Ÿ replaces third dummy argument
ο‚ž B) keyword arguments
ο‚ž This allows reference to dummy
  arguments by name as well as by
  position.
ο‚ž e.g.
ο‚ž INCR &arg1 = A,&arg3 = C, &arg2 =β€ŸBβ€Ÿ
ο‚ž e.g.
ο‚ž INCR &arg1 = &arg2 = A, &arg2 =β€ŸCβ€Ÿ
Conditional macro
expansion
ο‚ž   This allows conditional selection of machine
    instructions that appear in expansion of macro call.
ο‚ž   The macro processor pseudo op-codes AIF and
    AGO help to do conditional macro expansion.
ο‚ž   AIF is conditional branch pseudo op, it performs
    arithmetic test and branch only if condition is true.
ο‚ž   AGO is unconditional pseudo op or it is like go to
    statement.
ο‚ž   Both statements specify a label appearing in some
    other instruction within macro definition.
ο‚ž   These are macro processor directives and they do
    not appear in expanded source code
Source Program                           Expanded Program

:
MACRO
& arg0 INCR & count, & arg1, & arg 2, & arg3
& arg0 A     1, &arg1
        AIF (& Count EQ.1). FINAL
        A     2,& arg2                         LOOP1 A 1, data1
        AIF (&count EQ 2). FINAL                      A 2, data2
        A     3, &arg3                               A 3, data3
.FINAL MEND                                           :
        :                                             :
LOOP1 INCR 3, data1, data2, data3              LOOP2 A 1, data3
        :                                             A 2, data2
        :                                            :
LOOP2 INCR 2, data3, data2                           :
       :                                       LOOP3 A 1, data1
LOOP3 INCR 1, data1                                  :
       :                                           data1 DC β€˜5’
data1    DC β€˜5’                                    data2 DC β€˜6’
data2    DC β€˜6’                                   data3 DC β€˜7’
data3    DC β€˜7’                                        :
Macro-calls within macro
ο‚ž   Macros are abbreviations of instruction
    sequence. Such abbreviations are also
    present within other macro definition.
Macro-calls within macro
Source Code                Expanded code (level 1)   Expanded code (level 2)

       :
       :
MACRO
ADD 1, &arg
L       1, &arg
A       1, = F β€˜10’
ST 1, &arg
MEND
MACRO
ADDS &arg1, &arg2, arg3
ADD1 &arg1
ADD1 &arg2
ADD1 &arg3
MEND                       Expansion of ADDS
       :                         :
       :                         :
ADDS data1, data2, data3   ADD1 data 1
      :                    ADD1 data 2
      :                    ADD1 data 3
data 1 DC Fβ€˜5’                  :
data 2 DC Fβ€˜6’                  :
data 3 DC Fβ€˜7’                  :
END                             :
                           data DC F β€˜5’
                           data DC F β€˜6’
                           data DC F β€˜7’
                           END
Source Code                Expanded code (level 1)   Expanded code (level 2)

       :
       :
MACRO
ADD 1, &arg
L       1, &arg
A       1, = F β€˜10’
ST 1, &arg
MEND
MACRO
ADDS &arg1, &arg2, arg3
ADD1 &arg1                                           Expansion of ADD1
ADD1 &arg2
ADD1 &arg3                                           L 1, data 1
MEND                       Expansion of ADDS         A 1, = F β€ž10β€Ÿ
       :                         :                   ST 1, data 1
       :                         :
ADDS data1, data2, data3   ADD1 data 1               L 1, data 2
      :                    ADD1 data 2               A 1, = F β€ž10β€Ÿ
                           ADD1 data 3               ST 1, data 2
      :
data 1 DC Fβ€˜5’                  :
                                                     L 1, data 3
data 2 DC Fβ€˜6’                  :
                                                     A 1, = F β€ž10β€Ÿ
data 3 DC Fβ€˜7’                  :                    ST 1, data 3
END                             :
                           data DC F β€˜5’
                           data DC F β€˜6’             data1 DC Fβ€˜5’
                           data DC F β€˜7’             data2 DC Fβ€˜6’
                           END                       data3 DC Fβ€˜7’
                                                     END
Macro-instructions defining
macros
Macro-instructions defining
macros
ο‚ž   Macro-definition, which itself is a sequence of instruction,
    can be abbreviated by using macro.
ο‚ž   It is important to note that inner macro is not defined until
    the outer macro is called.
ο‚ž   The user might call the above macro with the statement-
ο‚ž   DEFINE-MACRO ADD1
ο‚ž   When this call is executed then the macro ADD1 will be
    defined. So after the above call user can call the ADD1
    macro in following way-
ο‚ž   ADD1 data1
ο‚ž   The macro processor will generate the sequence
    L 1, data1
    A 1,=Fβ€Ÿ0β€Ÿ
    ST 1,data1.
Implementation
ο‚ž   There are four basic task that a macro-processor
    must perform
    ο‚— Recognize macro definition
      A macro instruction processor must recognize macro
      definition identified by MACRO & MEND pseudo –
      operations.
    ο‚— Save the Definition
      The processor must store the macro – definitions which
      will be needed at the time of expansion of calls.
    ο‚— Recognize the Macro call
      The processor must recognize macro calls that appear as
      operation mnemonics.
    ο‚— Expand calls & substitute arguments
      The macro call is replaced by the macro definition. The
      dummy arguments are replaced by the actual data .
Two pass Macro Processor
ο‚ž General Design Steps
ο‚ž Step 1: Specification of Problem:-
ο‚ž Step 2 Specification of databases:-
ο‚ž Step 3 Specification of database
          formats
ο‚ž Step 4 : Algorithm
Specify the problem
ο‚ž In Pass-I the macro definitions are
  searched and stored in the macro
  definition table and the entry is made in
  macro name table
ο‚ž In Pass-II the macro calls are identified
  and the arguments are placed in the
  appropriate place and the macro calls
  are replaced by macro definitions.
Specification of
databases:-
Pass 1:-
ο‚ž The input macro source program.
ο‚ž The output macro source program to be used by Pass2.
ο‚ž Macro-Definition Table (MDT), to store the body of macro
  defns.
ο‚ž Macro-Definition Table Counter (MDTC), to mark next
  available entry MDT.
ο‚ž Macro- Name Table (MNT), used to store names of
  macros.
ο‚ž Macro Name Table counter (MNTC), used to indicate the
  next available entry in MNT.
ο‚ž Argument List Array (ALA), used to substitute index
  markers for dummy arguments before storing a macro-
  defns.
Specification of
databases:-
ο‚ž   Pass 2:-
ο‚ž   The copy of the input from Pass1.
ο‚ž   The output expanded source to be given to
    assembler.
ο‚ž   MDT, created by Pass1.
ο‚ž   MNT, created by Pass1.
ο‚ž   Macro-Definition Table Pointer (MDTP), used
    to indicate the next line of text to be used
    during macro-expansion.
ο‚ž   Argument List Array (ALA), used to substitute
    macro-call arguments for the index markers in
    the stored macro-defns
Specification of database
format:-
ο‚ž MDT is a table of text lines.
ο‚ž Every line of each macro definition
  except the MACRO line, is stored in the
  MDT (MACRO line is useless during
  macro-expansion)
ο‚ž MEND is kept to indicate the end of the
  depns.
ο‚ž The macro-name line is retained to
  facilitate keyword argument
  replacement.
Macro Names Table (MNT):
ο‚ž   Each MNT entry consists of

    ο‚— A character string (the macro name) &


    ο‚— A pointer (index) to the entry in MDT that
     corresponds to the beginning of the macro-
     definition.(MDT index)
Argument List Array
(ALA):
ο‚ž   ALA is used during both Pass1 & Pas2 but for some
    what reverse functions.
ο‚ž   During Pass1, in order to simplify later argument
    replacement during macro expansion, dummy
    arguments are replaced with positional indicators
    when defn is stored.
    Ex. # 1, # 2, # 3 etc.
ο‚ž   The ith dummy argument on the macro-name is
    represented in the body by #i.
ο‚ž   These symbols are used in conjunction with ALA
    prepared before expansion of a macro-call.
ο‚ž   Symbolic dummy argument are retained on macro-
    name to enable the macro processor to handle
    argument replacement byname rather by position.
During pass-I
During Pass-II
ο‚ž   During Pass2 it is necessary to substitute
    macro call arguments for the index markers
    stored in the macro.
ο‚ž      Thus upon encountering the call
    expander would prepare a ALA as shown
    below:
ο‚ž   LOOP 1NCR DATA1, DATA2, DATA3,}
ο‚ž   β†’ Call in main prog.
ο‚ž   β†’ ALA is prepare of after this call is
    encountered.
Algorithm
ο‚ž   Pass1 of macro processor makes a line-by-line scan
    over its input.
ο‚ž   Set MDTC = 1 as well as MNTC = 1.
ο‚ž   Read next line from input program.
ο‚ž   If it is a MACRO pseudo-op, the entire macro
    definition except this (MACRO) line is stored in MDT.
ο‚ž   The name is entered into Macro Name Table along
    with a pointer to the first location of MDT entry of
    the definition.
ο‚ž   When the END pseudo-op is encountered all the
    macro-defns have been processed, so control is
    transferred to pass2
MDTCοƒŸ 1
          MNTCοƒŸ 1




   Enter Macro Name and
Current value of MDTC in MNT




                               MDTCοƒŸ MDTC+1

     MDTCοƒŸ MDTC+1
Algorithm for Pass – 2
ο‚ž   This algorithm reads one line of i/p prog. at a time.
ο‚ž   for each Line it checks if op-code of that line matches any of the
    MNT entry.
ο‚ž   When match is found (i.e. when call is pointer called MDTF to
    corresponding macro defns stored in MDT.
ο‚ž         The initial value of MDTP is obtained from MDT index field
    of MNT entry.
ο‚ž   The macro expander prepares the ALA consisting of a table of
    dummy argument indices & corresponding arguments to the
    call.
ο‚ž   Reading proceeds from the MDT, as each successive line is
    read, The values form the argument list one substituted for
    dummy arguments indices in the macro defn.
ο‚ž   Reading MEND line in MDT terminates expansion of macro &
    scanning continues from the input file.
ο‚ž   When END pseudo-op encountered , the expanded source
    program is given to the assembler
MDTP οƒŸ MDTP + 1
MACROS                              PROCEDURE
1
    The corresponding machine code 1 The Corresponding m/c code is
    is written every time a macro is written only once in memory
    called in a program.
2
    Program takes up more memory 2 Program takes up comparatively
    space.                         less memory space.
3
    No transfer of program counter.   3 Transferring of program counter is
                                        required.
4
    No overhead of using stack for 4 Overhead of using stack for
    transferring control.            transferring control.
5
    Execution is fast                 5 Execution is comparatively slow.
6
    Assembly time is more.            6 Assembly time is comparatively
                                        less.
7
    More      advantageous    to the 7 More advantageous to the
    programs when repeated group of    programs when repeated group of
    instruction is too short.          instructions is quite large.
Loaders
ο‚ž   Loader is a program which accepts the
    object program decks and prepares
    these programs for execution by the
    computer and initiates the execution
The loader must perform the
following functions
1. Allocate space in memory for the
   program(Allocation)
2. Resolve symbolic references between
   object decks(Linking)
3. Adjust all address dependent locations,
   such as address constants, to
   corresponds to the allocated space
   (Relocation)
4. Physically place the machine instruction
   and data in memory(Loading)
Loader


 A


           Loader
                                   A

 B                                 B



         Data Base

                        Program Loaded in
                     memory ready for Execution
Loader Schemes
ο‚ž Compile-and-Go loader
ο‚ž General Loader Scheme
ο‚ž Absolute Loading scheme
ο‚ž Subroutine Linkages
ο‚ž Relocating Loaders
ο‚ž Direct Linking Loaders
Compile-and-Go Loader

  Source program
       deck
ο‚ž In this scheme assembler run in one
  part of memory and place object
  instructions & data, as they are
  assembled, directly into their assigned
  memory location.
ο‚ž When assembly is completed,
  assembler causes a transfer to the
  starting instruction of the program
ο‚ž   Advantages:-
ο‚ž      It is relatively easy to implement.
    Assembler simply places code into core and
    loader transfer control to starting instruction of
    newly assembled program.
ο‚ž
ο‚ž   Disadvantages:-
ο‚ž   i) A portion of memory is always occupied by
    assembler. That portion is unavailable to any
    other object program.
ο‚ž   ii) Userβ€Ÿs program have to be reassemble
    every time it is run.
ο‚ž   iii) If source program contains sub routine
    written in different languages, then different
    assemblers have to be stored in memory ( i.e.
    again wastage of memory).
General Loading Scheme
General Loader Scheme
ο‚ž   In this scheme the output of assembler is saved and
    loaded whenever code is to be executed.

ο‚ž   Assembled program could be loaded, in the same
    area into memory where assembler was stored (
    because now assembling is completed assembler is
    removed from main memory).

ο‚ž   Function of loader is to accept instruction, data and
    other information in object format and put it into
    memory in executable format.
ο‚ž   Advantages:-
    ο‚— No need to put assembler in main memory all the time it can be
      removed after assembly is completed. Assembled program is
      stored in secondary storage in object form

    ο‚— Loader is required to put object code in memory in executable
      format, which is smaller in size.

    ο‚— Every time when we run program one do not have to assembler
      it every time.

    ο‚— Even if subroutine are in different languages, their object code &
      linkage conventions will be in one language.

ο‚ž   Disadvantage:-
    Addition of a new program β€žLoaderβ€Ÿ into system.
Absolute Loader

100

      MAIN                 100

248
                Absolute              MAIN
                 Loader    248
400
      SQRT
478                         400
                                      SQRT
  Object Deck               478



                                  Main Memory
Absolute Loaders:-
ο‚ž The simplest type of loader scheme
  which fits to the general model is called
  as absolute loader.
ο‚ž Assembler produces object code, which
  is stored on secondary storage ( instead
  of directly loaded into main memory like
  in compile -&-go).
ο‚ž Loader in turn accepts this object code,
  places it into core at prescribed place by
  assembler for execution.
Advantages:-
ο‚ž This scheme makes more memory available to the
   user, an assembler is not in memory at load time.
ο‚ž Simple to implement.
Disadvantages:-
ο‚ž Programmer must specify to the assembler, the
   address of memory location where program is to be
   loaded.
ο‚ž When program contains more than one subroutines,
   then programmer must remember the address of
   each and have to user it explicitly in other
   subroutines to perform subroutine linkages.
ο‚ž Programmer must be careful not to assign same or
   overlapping locations to two subroutines.
Thus in absolute loader scheme
four loader functions are performed
by


ο‚ž   Allocation - by programmer
ο‚ž   Linking    - by programmer
ο‚ž   Relocation - by assembler
ο‚ž   Loading - by loader
Subroutine linkage
ο‚ž   The problem is:: A MAIN program A wishes to
    transfer to sub-program B. However the
    assembler does not know this symbol and
    declare it as an undefined symbol (error) unless
    a special mechanism has been provided.
ο‚ž   This mechanism has been implemented with a
    direct-linking or a relocating loader.
ο‚ž   The assembler pseudo-op EXTRN followed by a
    list of symbols indicates that these symbols are
    defined in another programs.
ο‚ž   Correspondingly if a symbol is defined in one
    program and referenced in others, we insert it
    into a symbol list following the pseudo-op
    ENTRY.
ο‚ž   The assembler will also inform the loader that
    these symbols may be referenced by other
    programs.
Subroutine linkage(Cont…1)
ο‚ž Consider the following example::
MAIN START
     EXTRN            SUBROUT
     ----------
     L                15, = A(SUBROUT)
     BALR             14,15 // reg 14 is return addr of caller.
     --------
     END
The subroutine can be defined at other location as ::
SUBROUT START
              USING         *,15
              ----------
              BR            14
              END
Relocating loaders
ο‚ž To avoid possible reassembling of all
  subroutines when a single subroutine is
  changed, and to perform the task of
  allocation and linking for programmer,
  relocating loaders are developed.
ο‚ž In this scheme, assembler assembles
  each procedure segment independently
  and passes on the text and information
  after relocation & inter segment
  references to the loader.
ο‚ž Example::        BSS(Binary        Symbolic
  Subroutines) loader used in IBM 7094, IBM
  1130, etc.
ο‚ž The o/p of a relocating assembler using a
  BSS scheme is the object program &
  information     about    all  programs    it
  references.
ο‚ž It also provides the relocating information
  that needs to be changed if it is placed in
  an arbitrary place in core.
ο‚ž BSS loader scheme is used on computers
  with a fixed length direct address
  instruction format.
5.RELOCATING LOADER(Cont…1)
SOURCE PROGRAM         REL. ADDR   RELOCATION   OBJECT CODE

MAIN     START
EXTRN    SQRT          0            00              β€žSQRTβ€Ÿ
EXTRN    ERR           4            00               β€žERRbβ€Ÿ
ST       14,SAVE       8            01            ST 14,36
L        1,=F β€ž9β€Ÿ      12           01            L 1,40
BAL      14,SQRT       16           01            BAL 14,0
C         1, = F β€ž3β€Ÿ   20            01            C 1,44
BNE      ERR           24            01            BC 7,4
L        14, SAVE      28           01            L    14,36
BR       14            32            0           BCR 15,14

SAVE     DS F          34           0 skipped for alignment
         END           36           00 temp. location
                       40           00
                       44           00
                              56
5.RELOCATING LOADER(Cont…2)
Absolute Relative
Address Address
 400         0      BC 15,448
 404         4      BC 15, 526
                    ST 14,436
 408         8      L 1,440
 412        12      BAL 14,400
                    C    1,444    LENGTH = 48 BYTES.
 416        16
 420        20      BC    7,404
                    L    4,436
 424        24      BCR 15,14
 428        28      (TEMP LOC)
 432        32           9
                         3
 436        36
 440        40
 444        44         SQRT        LENGTH = 78 BYTES.
                       ERR   57
5.RELOCATING LOADER(Cont…3)

ο‚ž  Drawbacks ::
1) The transfer vector linkage is only useful
   for transfers & is not well situated for
   loading or storing external data(data
   located in another procedure segments).
2) The transfer vector increases the size of
   the object program in memory.




                     58
6. DIRECT-LINKING LOADER(cont…1)
                                  END
                         RLD
                TXT
        ESD
FIG: - OBJECT DESK FOR A DIRECT LINKING LOADER
ο‚ž ESD – External Symbol dictionary.
ο‚ž TXT – Text (contains actual assembled program).
ο‚ž RLD - Relocation & Linkage Directory. – contains
  information about those locations in the program
  whose contents depends on the address at which
  the program is placed. These information are::
ο‚ž Location of each constant that needs to be
  changed due to relocation.
ο‚ž By what it has to be changed.
ο‚ž The operation to be performed.
                         59
DIRECT-LINKING LOADER(cont…2)
ο‚ž ADVATAGES::
 1)It allows the programmer      multiple procedure &
   data segments.
 2)Complete freedom for the programmer to refer the
   data in other segments.
 3)Provides flexibility in intersegment referencing &
   accessing ability.
 4)Allows independent translations of the programs.
ο‚ž DISADVATAGES::
 1)It is necessary to allocate, relocate, link & load all
   of the subroutines each time in order to execute a
   program.
 2)These loading are Time-consuming.
 3)Although loader is smaller than assembler,
   it occupies some memory space.
                           60
OTHER LOADING SCHEMES
ο‚ž   These includes Binders, linking loaders, Overlays &
    Dynamic loaders.
ο‚ž   Binders:: - A Binder is a program that performs the
    same functions as that of a direct-linking loader in
    binding subroutines together, but rather than placing
    the relocated & linked text directly into memory, it
    outputs the text as a file or a card deck.
ο‚ž   This o/p file to be loaded is called as β€œload-module”.
ο‚ž   The functions of binders are ::
    οƒ˜   Allocation, Relocation, Linking & Loading.
ο‚ž   There are 2 major classes of Binders::
         ο‚— Core – image module.( fast & simple)
         ο‚— Linkage Editor.(complex)
                                61
Dynamic Loading
overlays
ο‚ž   Each of the previous loader schemes
    assume that all of the subroutines are
    loaded into core at the same time. It the
    total amount of memory available is less
    than memory required by all needed
    subroutines, then there will be trouble.
Solution to above problem can
be-
ο‚ž Some hardware techniques like paging
  and segmentation are used to solve this
  problem
ο‚ž There is loading scheme called as
  dynamic loading which is also available
  to solve above problem.
ο‚ž Usually different subroutines are needed
  at different times. E.g. PASS1 & PASS2
  of assembler are mutually exclusive.
  Both can be loaded one after another,
  need not to be loaded at the same time.
ο‚ž By determining which subroutines call
  another, which are exclusive , we can
  produce an overlay structure, that will
  help to use memory economically.
Macro Processors and Their Implementation

More Related Content

What's hot

Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assemblerDeepmala Sharma
Β 
Macro Processor
Macro ProcessorMacro Processor
Macro ProcessorSaranya1702
Β 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit ISaranya1702
Β 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03desta_gebre
Β 
MACRO PROCESSOR
MACRO PROCESSORMACRO PROCESSOR
MACRO PROCESSORBhavik Vashi
Β 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming ) Adarsh Patel
Β 
Language processing activity
Language processing activityLanguage processing activity
Language processing activityDhruv Sabalpara
Β 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language ProcessingHemant Sharma
Β 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assemblerDhananjaysinh Jhala
Β 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loaderbabyparul
Β 
Unit 3
Unit 3Unit 3
Unit 3pm_ghate
Β 
Loaders
LoadersLoaders
LoadersMohd Arif
Β 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loaderMalek Sumaiya
Β 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader sonalikharade3
Β 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assemblerBansari Shah
Β 

What's hot (20)

Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
Β 
Macro Processor
Macro ProcessorMacro Processor
Macro Processor
Β 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
Β 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit I
Β 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
Β 
MACRO PROCESSOR
MACRO PROCESSORMACRO PROCESSOR
MACRO PROCESSOR
Β 
Loaders
LoadersLoaders
Loaders
Β 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
Β 
Language processing activity
Language processing activityLanguage processing activity
Language processing activity
Β 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language Processing
Β 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
Β 
Single Pass Assembler
Single Pass AssemblerSingle Pass Assembler
Single Pass Assembler
Β 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
Β 
Unit 3
Unit 3Unit 3
Unit 3
Β 
Loaders
LoadersLoaders
Loaders
Β 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
Β 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
Β 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
Β 
Loader
LoaderLoader
Loader
Β 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
Β 

Similar to Macro Processors and Their Implementation

Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01riddhi viradiya
Β 
Presentation on macros and macro processor
Presentation on macros and macro processorPresentation on macros and macro processor
Presentation on macros and macro processorKuldeep Pathak
Β 
Lineage-driven Fault Injection, SIGMOD'15
Lineage-driven Fault Injection, SIGMOD'15Lineage-driven Fault Injection, SIGMOD'15
Lineage-driven Fault Injection, SIGMOD'15palvaro
Β 
Cp0675 03 may-2012-rm04
Cp0675 03 may-2012-rm04Cp0675 03 may-2012-rm04
Cp0675 03 may-2012-rm04Parth Mudgal
Β 
LOFAR Global Sky Model database
LOFAR Global Sky Model databaseLOFAR Global Sky Model database
LOFAR Global Sky Model databaseAlexey Mints
Β 
IRJET- A Study on PRN Code Generation and Properties of C/A Code in GPS based...
IRJET- A Study on PRN Code Generation and Properties of C/A Code in GPS based...IRJET- A Study on PRN Code Generation and Properties of C/A Code in GPS based...
IRJET- A Study on PRN Code Generation and Properties of C/A Code in GPS based...IRJET Journal
Β 
Presentation about the use of R3BRoot for data analysis
Presentation about the use of R3BRoot for data analysisPresentation about the use of R3BRoot for data analysis
Presentation about the use of R3BRoot for data analysisJoseLuisRodriguezSan16
Β 
Unit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsUnit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsSreenivas Hanumandla
Β 
What is in All of Those SSTable Files Not Just the Data One but All the Rest ...
What is in All of Those SSTable Files Not Just the Data One but All the Rest ...What is in All of Those SSTable Files Not Just the Data One but All the Rest ...
What is in All of Those SSTable Files Not Just the Data One but All the Rest ...DataStax
Β 
Microcontroller architecture programming and interfacing
Microcontroller architecture programming and interfacingMicrocontroller architecture programming and interfacing
Microcontroller architecture programming and interfacingthejasmeetsingh
Β 

Similar to Macro Processors and Their Implementation (11)

Macro
MacroMacro
Macro
Β 
Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01
Β 
Presentation on macros and macro processor
Presentation on macros and macro processorPresentation on macros and macro processor
Presentation on macros and macro processor
Β 
Lineage-driven Fault Injection, SIGMOD'15
Lineage-driven Fault Injection, SIGMOD'15Lineage-driven Fault Injection, SIGMOD'15
Lineage-driven Fault Injection, SIGMOD'15
Β 
Cp0675 03 may-2012-rm04
Cp0675 03 may-2012-rm04Cp0675 03 may-2012-rm04
Cp0675 03 may-2012-rm04
Β 
LOFAR Global Sky Model database
LOFAR Global Sky Model databaseLOFAR Global Sky Model database
LOFAR Global Sky Model database
Β 
IRJET- A Study on PRN Code Generation and Properties of C/A Code in GPS based...
IRJET- A Study on PRN Code Generation and Properties of C/A Code in GPS based...IRJET- A Study on PRN Code Generation and Properties of C/A Code in GPS based...
IRJET- A Study on PRN Code Generation and Properties of C/A Code in GPS based...
Β 
Presentation about the use of R3BRoot for data analysis
Presentation about the use of R3BRoot for data analysisPresentation about the use of R3BRoot for data analysis
Presentation about the use of R3BRoot for data analysis
Β 
Unit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsUnit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller ppts
Β 
What is in All of Those SSTable Files Not Just the Data One but All the Rest ...
What is in All of Those SSTable Files Not Just the Data One but All the Rest ...What is in All of Those SSTable Files Not Just the Data One but All the Rest ...
What is in All of Those SSTable Files Not Just the Data One but All the Rest ...
Β 
Microcontroller architecture programming and interfacing
Microcontroller architecture programming and interfacingMicrocontroller architecture programming and interfacing
Microcontroller architecture programming and interfacing
Β 

More from Manoj Patil

Smqa unit ii
Smqa unit   iiSmqa unit   ii
Smqa unit iiManoj Patil
Β 
Smqa unit v
Smqa unit v Smqa unit v
Smqa unit v Manoj Patil
Β 
Smqa unit iv
Smqa unit iv Smqa unit iv
Smqa unit iv Manoj Patil
Β 
Smqa unit ii
Smqa unit iiSmqa unit ii
Smqa unit iiManoj Patil
Β 
Smqa unit i
Smqa unit iSmqa unit i
Smqa unit iManoj Patil
Β 
Smqa unit iii
Smqa unit iiiSmqa unit iii
Smqa unit iiiManoj Patil
Β 
System Programming Unit IV
System Programming Unit IVSystem Programming Unit IV
System Programming Unit IVManoj Patil
Β 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit IIManoj Patil
Β 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit IIIManoj Patil
Β 

More from Manoj Patil (9)

Smqa unit ii
Smqa unit   iiSmqa unit   ii
Smqa unit ii
Β 
Smqa unit v
Smqa unit v Smqa unit v
Smqa unit v
Β 
Smqa unit iv
Smqa unit iv Smqa unit iv
Smqa unit iv
Β 
Smqa unit ii
Smqa unit iiSmqa unit ii
Smqa unit ii
Β 
Smqa unit i
Smqa unit iSmqa unit i
Smqa unit i
Β 
Smqa unit iii
Smqa unit iiiSmqa unit iii
Smqa unit iii
Β 
System Programming Unit IV
System Programming Unit IVSystem Programming Unit IV
System Programming Unit IV
Β 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
Β 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit III
Β 

Recently uploaded

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
Β 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
Β 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
Β 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
Β 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
Β 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
Β 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
Β 
WhatsApp 9892124323 βœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 βœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 βœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 βœ“Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
Β 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
Β 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
Β 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
Β 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
Β 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
Β 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
Β 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
Β 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
Β 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
Β 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
Β 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
Β 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
Β 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Β 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Β 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Β 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Β 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Β 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Β 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
Β 
WhatsApp 9892124323 βœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 βœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 βœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 βœ“Call Girls In Kalyan ( Mumbai ) secure service
Β 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
Β 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
Β 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
Β 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
Β 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Β 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Β 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Β 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Β 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Β 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Β 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Β 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Β 

Macro Processors and Their Implementation

  • 1.
  • 2. Macro and Macro processor ο‚ž Macro:- ο‚— Macro instructions are single line abbreviations for group of instructions. ο‚ž Using a macro, programmer can define a single β€œinstruction” to represent block of code.
  • 3. MACRO -------- Start of definition INCR -------- Macro name A 1,DATA A 2,DATA ------Sequence of instructions to be A 3,DATA abbreviated MEND -------- End of definition
  • 4. Macro Expansion ο‚ž Replacement of macro call by corresponding sequence of instructions is called as macro expansion
  • 5. Source Expanded source Macro : Incr : A 1, data : A 2, data : A 3, data : MEND : : A 1, Data : A 2, Data INCR A 3, Data : : : : INCR : : A 1, Data : A 2, Data data DC F’5’ A 3, Data : data DC F β€˜5’ : END
  • 6. Features of macro facility Macro instructions arguments : : A 1,data1 A 2,data1 A 3,data1 : : A 1,data2 A 2,data2 A 3,data2 : Data1 DC Fβ€Ÿ5β€Ÿ Data2 DC Fβ€Ÿ6β€Ÿ
  • 7. Source Expanded Source MACRO : INCR &arg (Macro name with : A 1,&arg one argument) : A 2,&arg : A 3,&arg : MEND A 1,data1 : A 2,data1 : A 3,data1 INCR data1 (use of data1 as : : operand) A 1,data2 : A 2,data2 INCR data 2 (use of data1 as A 3,data2 : operand) : data1 DC F’5’ : data2 DC F’6’ data1 DC F’5’ : data2 DC F’6’ END
  • 8. Example: more than one arguments. A 1,data1 A 2,data2 A 3,data3 : A 1,data3 A 2,data2 A 3,data1 : data1 DC Fβ€Ÿ5β€Ÿ data2 DC Fβ€Ÿ6β€Ÿ
  • 9. Source Expanded source MACRO : & lab1 INCR & arg 1, & arg 2, & arg 3 : & lab 1 A 1, &arg1 : A 2, &arg2 : A 3, &arg3 : MEND : : : : : : LOOP 1 A 1, data 1 LOOP1 INCR data1, data2, data3 A 2, data 2 : A 3, data 3 : : : : LOOP2 INCR data3, data2, data1 LOOP 2 A 1, data3 : A 2, data2 : A 3, data1 data1 DC F β€˜5’ : data2 DC F β€˜6’ data1 DC F β€˜5’ data3 DC F β€˜7’ data2 DC F β€˜6’ data3 DC F β€˜7’
  • 10. Two ways of specifying arguments to a macro call ο‚ž A) Positional argument Argument are matched with dummy arguments according to order in which they appear. ο‚ž INCR A,B,C ο‚ž β€žAβ€Ÿ replaces first dummy argument ο‚ž β€žBβ€Ÿ replaces second dummy argument ο‚ž β€žCβ€Ÿ replaces third dummy argument
  • 11. ο‚ž B) keyword arguments ο‚ž This allows reference to dummy arguments by name as well as by position. ο‚ž e.g. ο‚ž INCR &arg1 = A,&arg3 = C, &arg2 =β€ŸBβ€Ÿ ο‚ž e.g. ο‚ž INCR &arg1 = &arg2 = A, &arg2 =β€ŸCβ€Ÿ
  • 12. Conditional macro expansion ο‚ž This allows conditional selection of machine instructions that appear in expansion of macro call. ο‚ž The macro processor pseudo op-codes AIF and AGO help to do conditional macro expansion. ο‚ž AIF is conditional branch pseudo op, it performs arithmetic test and branch only if condition is true. ο‚ž AGO is unconditional pseudo op or it is like go to statement. ο‚ž Both statements specify a label appearing in some other instruction within macro definition. ο‚ž These are macro processor directives and they do not appear in expanded source code
  • 13. Source Program Expanded Program : MACRO & arg0 INCR & count, & arg1, & arg 2, & arg3 & arg0 A 1, &arg1 AIF (& Count EQ.1). FINAL A 2,& arg2 LOOP1 A 1, data1 AIF (&count EQ 2). FINAL A 2, data2 A 3, &arg3 A 3, data3 .FINAL MEND : : : LOOP1 INCR 3, data1, data2, data3 LOOP2 A 1, data3 : A 2, data2 : : LOOP2 INCR 2, data3, data2 : : LOOP3 A 1, data1 LOOP3 INCR 1, data1 : : data1 DC β€˜5’ data1 DC β€˜5’ data2 DC β€˜6’ data2 DC β€˜6’ data3 DC β€˜7’ data3 DC β€˜7’ :
  • 14. Macro-calls within macro ο‚ž Macros are abbreviations of instruction sequence. Such abbreviations are also present within other macro definition.
  • 16. Source Code Expanded code (level 1) Expanded code (level 2) : : MACRO ADD 1, &arg L 1, &arg A 1, = F β€˜10’ ST 1, &arg MEND MACRO ADDS &arg1, &arg2, arg3 ADD1 &arg1 ADD1 &arg2 ADD1 &arg3 MEND Expansion of ADDS : : : : ADDS data1, data2, data3 ADD1 data 1 : ADD1 data 2 : ADD1 data 3 data 1 DC Fβ€˜5’ : data 2 DC Fβ€˜6’ : data 3 DC Fβ€˜7’ : END : data DC F β€˜5’ data DC F β€˜6’ data DC F β€˜7’ END
  • 17. Source Code Expanded code (level 1) Expanded code (level 2) : : MACRO ADD 1, &arg L 1, &arg A 1, = F β€˜10’ ST 1, &arg MEND MACRO ADDS &arg1, &arg2, arg3 ADD1 &arg1 Expansion of ADD1 ADD1 &arg2 ADD1 &arg3 L 1, data 1 MEND Expansion of ADDS A 1, = F β€ž10β€Ÿ : : ST 1, data 1 : : ADDS data1, data2, data3 ADD1 data 1 L 1, data 2 : ADD1 data 2 A 1, = F β€ž10β€Ÿ ADD1 data 3 ST 1, data 2 : data 1 DC Fβ€˜5’ : L 1, data 3 data 2 DC Fβ€˜6’ : A 1, = F β€ž10β€Ÿ data 3 DC Fβ€˜7’ : ST 1, data 3 END : data DC F β€˜5’ data DC F β€˜6’ data1 DC Fβ€˜5’ data DC F β€˜7’ data2 DC Fβ€˜6’ END data3 DC Fβ€˜7’ END
  • 19. Macro-instructions defining macros ο‚ž Macro-definition, which itself is a sequence of instruction, can be abbreviated by using macro. ο‚ž It is important to note that inner macro is not defined until the outer macro is called. ο‚ž The user might call the above macro with the statement- ο‚ž DEFINE-MACRO ADD1 ο‚ž When this call is executed then the macro ADD1 will be defined. So after the above call user can call the ADD1 macro in following way- ο‚ž ADD1 data1 ο‚ž The macro processor will generate the sequence L 1, data1 A 1,=Fβ€Ÿ0β€Ÿ ST 1,data1.
  • 20. Implementation ο‚ž There are four basic task that a macro-processor must perform ο‚— Recognize macro definition A macro instruction processor must recognize macro definition identified by MACRO & MEND pseudo – operations. ο‚— Save the Definition The processor must store the macro – definitions which will be needed at the time of expansion of calls. ο‚— Recognize the Macro call The processor must recognize macro calls that appear as operation mnemonics. ο‚— Expand calls & substitute arguments The macro call is replaced by the macro definition. The dummy arguments are replaced by the actual data .
  • 21. Two pass Macro Processor ο‚ž General Design Steps ο‚ž Step 1: Specification of Problem:- ο‚ž Step 2 Specification of databases:- ο‚ž Step 3 Specification of database formats ο‚ž Step 4 : Algorithm
  • 22. Specify the problem ο‚ž In Pass-I the macro definitions are searched and stored in the macro definition table and the entry is made in macro name table ο‚ž In Pass-II the macro calls are identified and the arguments are placed in the appropriate place and the macro calls are replaced by macro definitions.
  • 23. Specification of databases:- Pass 1:- ο‚ž The input macro source program. ο‚ž The output macro source program to be used by Pass2. ο‚ž Macro-Definition Table (MDT), to store the body of macro defns. ο‚ž Macro-Definition Table Counter (MDTC), to mark next available entry MDT. ο‚ž Macro- Name Table (MNT), used to store names of macros. ο‚ž Macro Name Table counter (MNTC), used to indicate the next available entry in MNT. ο‚ž Argument List Array (ALA), used to substitute index markers for dummy arguments before storing a macro- defns.
  • 24. Specification of databases:- ο‚ž Pass 2:- ο‚ž The copy of the input from Pass1. ο‚ž The output expanded source to be given to assembler. ο‚ž MDT, created by Pass1. ο‚ž MNT, created by Pass1. ο‚ž Macro-Definition Table Pointer (MDTP), used to indicate the next line of text to be used during macro-expansion. ο‚ž Argument List Array (ALA), used to substitute macro-call arguments for the index markers in the stored macro-defns
  • 26. ο‚ž MDT is a table of text lines. ο‚ž Every line of each macro definition except the MACRO line, is stored in the MDT (MACRO line is useless during macro-expansion) ο‚ž MEND is kept to indicate the end of the depns. ο‚ž The macro-name line is retained to facilitate keyword argument replacement.
  • 28. ο‚ž Each MNT entry consists of ο‚— A character string (the macro name) & ο‚— A pointer (index) to the entry in MDT that corresponds to the beginning of the macro- definition.(MDT index)
  • 29. Argument List Array (ALA): ο‚ž ALA is used during both Pass1 & Pas2 but for some what reverse functions. ο‚ž During Pass1, in order to simplify later argument replacement during macro expansion, dummy arguments are replaced with positional indicators when defn is stored. Ex. # 1, # 2, # 3 etc. ο‚ž The ith dummy argument on the macro-name is represented in the body by #i. ο‚ž These symbols are used in conjunction with ALA prepared before expansion of a macro-call. ο‚ž Symbolic dummy argument are retained on macro- name to enable the macro processor to handle argument replacement byname rather by position.
  • 31. During Pass-II ο‚ž During Pass2 it is necessary to substitute macro call arguments for the index markers stored in the macro. ο‚ž Thus upon encountering the call expander would prepare a ALA as shown below: ο‚ž LOOP 1NCR DATA1, DATA2, DATA3,} ο‚ž β†’ Call in main prog. ο‚ž β†’ ALA is prepare of after this call is encountered.
  • 32.
  • 33. Algorithm ο‚ž Pass1 of macro processor makes a line-by-line scan over its input. ο‚ž Set MDTC = 1 as well as MNTC = 1. ο‚ž Read next line from input program. ο‚ž If it is a MACRO pseudo-op, the entire macro definition except this (MACRO) line is stored in MDT. ο‚ž The name is entered into Macro Name Table along with a pointer to the first location of MDT entry of the definition. ο‚ž When the END pseudo-op is encountered all the macro-defns have been processed, so control is transferred to pass2
  • 34. MDTCοƒŸ 1 MNTCοƒŸ 1 Enter Macro Name and Current value of MDTC in MNT MDTCοƒŸ MDTC+1 MDTCοƒŸ MDTC+1
  • 35. Algorithm for Pass – 2 ο‚ž This algorithm reads one line of i/p prog. at a time. ο‚ž for each Line it checks if op-code of that line matches any of the MNT entry. ο‚ž When match is found (i.e. when call is pointer called MDTF to corresponding macro defns stored in MDT. ο‚ž The initial value of MDTP is obtained from MDT index field of MNT entry. ο‚ž The macro expander prepares the ALA consisting of a table of dummy argument indices & corresponding arguments to the call. ο‚ž Reading proceeds from the MDT, as each successive line is read, The values form the argument list one substituted for dummy arguments indices in the macro defn. ο‚ž Reading MEND line in MDT terminates expansion of macro & scanning continues from the input file. ο‚ž When END pseudo-op encountered , the expanded source program is given to the assembler
  • 37. MACROS PROCEDURE 1 The corresponding machine code 1 The Corresponding m/c code is is written every time a macro is written only once in memory called in a program. 2 Program takes up more memory 2 Program takes up comparatively space. less memory space. 3 No transfer of program counter. 3 Transferring of program counter is required. 4 No overhead of using stack for 4 Overhead of using stack for transferring control. transferring control. 5 Execution is fast 5 Execution is comparatively slow. 6 Assembly time is more. 6 Assembly time is comparatively less. 7 More advantageous to the 7 More advantageous to the programs when repeated group of programs when repeated group of instruction is too short. instructions is quite large.
  • 38. Loaders ο‚ž Loader is a program which accepts the object program decks and prepares these programs for execution by the computer and initiates the execution
  • 39. The loader must perform the following functions 1. Allocate space in memory for the program(Allocation) 2. Resolve symbolic references between object decks(Linking) 3. Adjust all address dependent locations, such as address constants, to corresponds to the allocated space (Relocation) 4. Physically place the machine instruction and data in memory(Loading)
  • 40. Loader A Loader A B B Data Base Program Loaded in memory ready for Execution
  • 41. Loader Schemes ο‚ž Compile-and-Go loader ο‚ž General Loader Scheme ο‚ž Absolute Loading scheme ο‚ž Subroutine Linkages ο‚ž Relocating Loaders ο‚ž Direct Linking Loaders
  • 42. Compile-and-Go Loader Source program deck
  • 43. ο‚ž In this scheme assembler run in one part of memory and place object instructions & data, as they are assembled, directly into their assigned memory location. ο‚ž When assembly is completed, assembler causes a transfer to the starting instruction of the program
  • 44. ο‚ž Advantages:- ο‚ž It is relatively easy to implement. Assembler simply places code into core and loader transfer control to starting instruction of newly assembled program. ο‚ž ο‚ž Disadvantages:- ο‚ž i) A portion of memory is always occupied by assembler. That portion is unavailable to any other object program. ο‚ž ii) Userβ€Ÿs program have to be reassemble every time it is run. ο‚ž iii) If source program contains sub routine written in different languages, then different assemblers have to be stored in memory ( i.e. again wastage of memory).
  • 46. General Loader Scheme ο‚ž In this scheme the output of assembler is saved and loaded whenever code is to be executed. ο‚ž Assembled program could be loaded, in the same area into memory where assembler was stored ( because now assembling is completed assembler is removed from main memory). ο‚ž Function of loader is to accept instruction, data and other information in object format and put it into memory in executable format.
  • 47. ο‚ž Advantages:- ο‚— No need to put assembler in main memory all the time it can be removed after assembly is completed. Assembled program is stored in secondary storage in object form ο‚— Loader is required to put object code in memory in executable format, which is smaller in size. ο‚— Every time when we run program one do not have to assembler it every time. ο‚— Even if subroutine are in different languages, their object code & linkage conventions will be in one language. ο‚ž Disadvantage:- Addition of a new program β€žLoaderβ€Ÿ into system.
  • 48. Absolute Loader 100 MAIN 100 248 Absolute MAIN Loader 248 400 SQRT 478 400 SQRT Object Deck 478 Main Memory
  • 49. Absolute Loaders:- ο‚ž The simplest type of loader scheme which fits to the general model is called as absolute loader. ο‚ž Assembler produces object code, which is stored on secondary storage ( instead of directly loaded into main memory like in compile -&-go). ο‚ž Loader in turn accepts this object code, places it into core at prescribed place by assembler for execution.
  • 50. Advantages:- ο‚ž This scheme makes more memory available to the user, an assembler is not in memory at load time. ο‚ž Simple to implement. Disadvantages:- ο‚ž Programmer must specify to the assembler, the address of memory location where program is to be loaded. ο‚ž When program contains more than one subroutines, then programmer must remember the address of each and have to user it explicitly in other subroutines to perform subroutine linkages. ο‚ž Programmer must be careful not to assign same or overlapping locations to two subroutines.
  • 51. Thus in absolute loader scheme four loader functions are performed by ο‚ž Allocation - by programmer ο‚ž Linking - by programmer ο‚ž Relocation - by assembler ο‚ž Loading - by loader
  • 52. Subroutine linkage ο‚ž The problem is:: A MAIN program A wishes to transfer to sub-program B. However the assembler does not know this symbol and declare it as an undefined symbol (error) unless a special mechanism has been provided. ο‚ž This mechanism has been implemented with a direct-linking or a relocating loader. ο‚ž The assembler pseudo-op EXTRN followed by a list of symbols indicates that these symbols are defined in another programs. ο‚ž Correspondingly if a symbol is defined in one program and referenced in others, we insert it into a symbol list following the pseudo-op ENTRY. ο‚ž The assembler will also inform the loader that these symbols may be referenced by other programs.
  • 53. Subroutine linkage(Cont…1) ο‚ž Consider the following example:: MAIN START EXTRN SUBROUT ---------- L 15, = A(SUBROUT) BALR 14,15 // reg 14 is return addr of caller. -------- END The subroutine can be defined at other location as :: SUBROUT START USING *,15 ---------- BR 14 END
  • 54. Relocating loaders ο‚ž To avoid possible reassembling of all subroutines when a single subroutine is changed, and to perform the task of allocation and linking for programmer, relocating loaders are developed. ο‚ž In this scheme, assembler assembles each procedure segment independently and passes on the text and information after relocation & inter segment references to the loader.
  • 55. ο‚ž Example:: BSS(Binary Symbolic Subroutines) loader used in IBM 7094, IBM 1130, etc. ο‚ž The o/p of a relocating assembler using a BSS scheme is the object program & information about all programs it references. ο‚ž It also provides the relocating information that needs to be changed if it is placed in an arbitrary place in core. ο‚ž BSS loader scheme is used on computers with a fixed length direct address instruction format.
  • 56. 5.RELOCATING LOADER(Cont…1) SOURCE PROGRAM REL. ADDR RELOCATION OBJECT CODE MAIN START EXTRN SQRT 0 00 β€žSQRTβ€Ÿ EXTRN ERR 4 00 β€žERRbβ€Ÿ ST 14,SAVE 8 01 ST 14,36 L 1,=F β€ž9β€Ÿ 12 01 L 1,40 BAL 14,SQRT 16 01 BAL 14,0 C 1, = F β€ž3β€Ÿ 20 01 C 1,44 BNE ERR 24 01 BC 7,4 L 14, SAVE 28 01 L 14,36 BR 14 32 0 BCR 15,14 SAVE DS F 34 0 skipped for alignment END 36 00 temp. location 40 00 44 00 56
  • 57. 5.RELOCATING LOADER(Cont…2) Absolute Relative Address Address 400 0 BC 15,448 404 4 BC 15, 526 ST 14,436 408 8 L 1,440 412 12 BAL 14,400 C 1,444 LENGTH = 48 BYTES. 416 16 420 20 BC 7,404 L 4,436 424 24 BCR 15,14 428 28 (TEMP LOC) 432 32 9 3 436 36 440 40 444 44 SQRT LENGTH = 78 BYTES. ERR 57
  • 58. 5.RELOCATING LOADER(Cont…3) ο‚ž Drawbacks :: 1) The transfer vector linkage is only useful for transfers & is not well situated for loading or storing external data(data located in another procedure segments). 2) The transfer vector increases the size of the object program in memory. 58
  • 59. 6. DIRECT-LINKING LOADER(cont…1) END RLD TXT ESD FIG: - OBJECT DESK FOR A DIRECT LINKING LOADER ο‚ž ESD – External Symbol dictionary. ο‚ž TXT – Text (contains actual assembled program). ο‚ž RLD - Relocation & Linkage Directory. – contains information about those locations in the program whose contents depends on the address at which the program is placed. These information are:: ο‚ž Location of each constant that needs to be changed due to relocation. ο‚ž By what it has to be changed. ο‚ž The operation to be performed. 59
  • 60. DIRECT-LINKING LOADER(cont…2) ο‚ž ADVATAGES:: 1)It allows the programmer multiple procedure & data segments. 2)Complete freedom for the programmer to refer the data in other segments. 3)Provides flexibility in intersegment referencing & accessing ability. 4)Allows independent translations of the programs. ο‚ž DISADVATAGES:: 1)It is necessary to allocate, relocate, link & load all of the subroutines each time in order to execute a program. 2)These loading are Time-consuming. 3)Although loader is smaller than assembler, it occupies some memory space. 60
  • 61. OTHER LOADING SCHEMES ο‚ž These includes Binders, linking loaders, Overlays & Dynamic loaders. ο‚ž Binders:: - A Binder is a program that performs the same functions as that of a direct-linking loader in binding subroutines together, but rather than placing the relocated & linked text directly into memory, it outputs the text as a file or a card deck. ο‚ž This o/p file to be loaded is called as β€œload-module”. ο‚ž The functions of binders are :: οƒ˜ Allocation, Relocation, Linking & Loading. ο‚ž There are 2 major classes of Binders:: ο‚— Core – image module.( fast & simple) ο‚— Linkage Editor.(complex) 61
  • 62. Dynamic Loading overlays ο‚ž Each of the previous loader schemes assume that all of the subroutines are loaded into core at the same time. It the total amount of memory available is less than memory required by all needed subroutines, then there will be trouble.
  • 63. Solution to above problem can be- ο‚ž Some hardware techniques like paging and segmentation are used to solve this problem ο‚ž There is loading scheme called as dynamic loading which is also available to solve above problem.
  • 64. ο‚ž Usually different subroutines are needed at different times. E.g. PASS1 & PASS2 of assembler are mutually exclusive. Both can be loaded one after another, need not to be loaded at the same time. ο‚ž By determining which subroutines call another, which are exclusive , we can produce an overlay structure, that will help to use memory economically.