Saturday, March 29, 2014

What is Macro & Macro Processor in System Software and Compiler?

Macro & Macro Expansion
*******

  • Macro works same as subroutine or a function which is used repeatedly whenever we required. Macro definition paced at starting of the program and Macro definition is started using word MACRO and end with word MEND.
  • Each macro should have a unique name.
  • Below is an example of Macro.
           MACRO ----> From here macro has started.        
             INCR &X,&Y ----> This is the declaration of prototype statement of Macro.
             LOAD  &X   ___
             ADD    &Y          |------>
             STORE &X   ___|------> This is the Macro definition. 
        MEND                
  • Now we can use INCR macro in assembly langunage, the assembler will automatically place the LOAD, ADD & STORE opcode with its operand.
  • e.g.
         INCR A,B ---> this statement will do three things instead of INCR A,B
                                  LOAD A 
                                  ADD B
                                  STORE A   
  • The above statement is called Macro Expansion. 



No comments:

Post a Comment