Sie sind auf Seite 1von 6

EXPERIMENT NO:- 5

NAME: Parth Raval.


ROLL NO: D361
SUBJECT: Microprocessor and Microcontroller(MPMC).
ClASS: BTech CS 3rd Year
DATE OF PERFORMANCE: 31.08.2015
DATE OF SUBMISSION: 31.08.2015

GRADE

SIGNAIM:

8086 assembly language program based on


1: PROCEDURE
2: MACRO.

PROCEDURE:

1] org 100h
call m1 //it calls the procedure m1
mov ax,2
ret
m1 proc
mov bx,3 //initialize bx = 3
ret //returns to mov
m1 ENDP
ret

2] org 100h
mov al,1
mov bl,2
call m2

//ends the proc

Write

call m2
call m2
call m2
ret
m2 proc
mul bl
ret
m2 endp
ret

MACRO:

It is used to automate complex or repetitive tasks. It is used to


automate complex or repetitive tasks. Reduce the time to write
the same task and Reduce the possibility of errors .
Macro can be considered to be a sequence of instructions to
which a name is assigned.
- For short sequence of instructions which are of fixed nature
Macros are used.
- They can execute faster as compared to subroutines.
- The MACRO directives are used to inform the assembler the
starting of a macro.

- In order to enclose a macro the ENDM directive is used. Macro


definition has three parts: (1) MACRO directive, Macro definition
has three parts: (1) MACRO directive, (2) ENDM directive, and (3)
body of the MACRO in (2) ENDM directive, and (3) body of the
MACRO in between MACRO and ENDM.
How to define a macro?
Create a MACRO definition with a unique name. Create a MACRO
definition with a unique name. Invoke the MACRO for its
service. Invoke the MACRO for its service.
Syntax:-

name MACRO[ param ]


{
<instruction>
}
Endm

Program:1] org 100h


Mymacro MACRO p1,p2,p3
mov ax,p1
mov bx,p2
mov cx,p3
endm //ends the macro
org 100h
Mymacro 1,2,3 //initializes ax=1,bx=2,cx=3
Mymacro 4,5,dx

//initializes ax=4 , bx=5 ,dx =00

Ret

PROCEDURE

MACRO

Procedure is a part of code that can be


called from your program in order to
make some specific task. Procedures
make program more structural and
easier
to
understand.
Generally
procedure returns to the same point
from where it was called.
This all machine code so less memory
is required

Macros are just like procedures, but


not really. Macros look like procedures,
but they exist only until your code is
compiled, after compilation all macros
are replaced with real instructions.

Due to
machine
required.

repeated generation
code more memory

of
is

When you want to use a procedure you When you want to use a macro, you can just type
should use CALL instruction, for its name. For example:
example:
MyMacro
CALL MyProc
You should use stack or any general
purpose registers to pass parameters To pass parameters to macro, you can
just type them after the macro name.
to procedure.
For example:
MyMacro 1, 2, 3
To mark the end of the macro ENDM To mark the end of the procedure, you
directive is enough.
should type the name of the procedure
before the ENDP directive.
Procedure is used for big codes.
Macro is used for small chunks of code.
Parameters can be passed in register
memory location or stack.
Procedure is located at some specific
address in memory, and if you use the
same procedure 100 times, the CPU
will transfer control to this part of the
memory.

Parameters are passed as a part of the


statement in which macro is called.
Macro
is
expanded
directly
in
program's code. So if you use the
same macro 100 times, the compiler
expands the macro 100 times

Das könnte Ihnen auch gefallen