0% found this document useful (0 votes)
4 views7 pages

Macro

Macros in the 8086 microprocessor are sets of instructions grouped under a single unit, allowing for modular programming. Unlike procedures, macros generate code each time they are called, leading to faster execution but increased memory usage due to macro expansion. They are defined using the MACRO and ENDM directives and can optionally accept parameters.

Uploaded by

Taveed Ghazarian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

Macro

Macros in the 8086 microprocessor are sets of instructions grouped under a single unit, allowing for modular programming. Unlike procedures, macros generate code each time they are called, leading to faster execution but increased memory usage due to macro expansion. They are defined using the MACRO and ENDM directives and can optionally accept parameters.

Uploaded by

Taveed Ghazarian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Macros in the 8086 Microprocessor

03/28/2023 1
Macros in the 8086 Microprocessor

A Macro is a set of instructions grouped under a single unit. It is
another method for implementing modular programming in the
8086 microprocessors (The first one was using Procedures).


The Macro is different from the Procedure in a way that unlike
calling and returning the control as in procedures, the processor
generates the code in the program every time whenever and
wherever a call to the Macro is made.

03/28/2023 2
Macros in the 8086 Microprocessor

A Macro can be defined in a program using the following
assembler directives: MACRO (used after the name of Macro
before starting the body of the Macro) and ENDM (at the end of
the Macro). All the instructions that belong to the Macro lie within
these two assembler directives. The following is the syntax for
defining a Macro in the 8086 Microprocessor:

03/28/2023 3
Macros in the 8086 Microprocessor

Macro_name MACRO [ list of parameters ]

Instruction 1

Instruction 2

-----------

-----------

-----------

Instruction n

ENDM

03/28/2023 4
Macros in the 8086 Microprocessor

And a call to Macro is made just by mentioning the name of the
Macro:


Macro_name [ list of parameters]


It is optional to pass the parameters in the Macro. If you want to
pass them to your macros, you can simply mention them all in the
very first statement of the Macro just after the directive: MACRO.

03/28/2023 5
Macros in the 8086 Microprocessor

The advantage of using Macro is that it avoids the overhead time
involved in calling and returning (as in the procedures). Therefore,
the execution of Macros is faster as compared to procedures.
Another advantage is that there is no need for accessing stack or
providing any separate memory to it for storing and returning the
address locations while shifting the processor controls in the
program.

03/28/2023 6
Macros in the 8086 Microprocessor

But it should be noted that every time you call a macro, the
assembler of the microprocessor places the entire set of Macro
instructions in the mainline program from where the call to Macro
is being made. This is known as Macro expansion. Due to this,
the program code (which uses Macros) takes more memory
space than the code which uses procedures for implementing the
same task using the same set of instructions.

Hence, it is better to use Macros where we have small instruction
sets containing less number of instructions to execute.

03/28/2023 7

You might also like