0% found this document useful (0 votes)
7 views

Exercise-7(Searching)

The document outlines an exercise for a microprocessors and microcontroller lab at Presidency University, focusing on writing an assembly language program (ALP) to search for a key element in a list of numbers. It explains the concept of macros, their advantages, and how to define and use them in assembly code. Additionally, it provides steps for executing assembly language programs using DOSBOX and MASM.

Uploaded by

houndclegane860
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Exercise-7(Searching)

The document outlines an exercise for a microprocessors and microcontroller lab at Presidency University, focusing on writing an assembly language program (ALP) to search for a key element in a list of numbers. It explains the concept of macros, their advantages, and how to define and use them in assembly code. Additionally, it provides steps for executing assembly language programs using DOSBOX and MASM.

Uploaded by

houndclegane860
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

PRESIDENCY UNIVERISTY, BENGALURU

School of Engineering

Microprocessors and Microcontroller Lab


CSE 254

IV Semester 2018-19
Exercise-
7
Write an ALP to search a key element in a list of
numbers
Exercise Descrip-
tionof instructions to which a name is given. Each time
A macro is a group
a macro is called in a program, the assembler will replace the macro
name with the group of instructions.
Advantages:
1.Macro reduces the amount of repetitive coding
2.Program becomes more readable and simple
3.Execution time is less as compared to calling procedures
4.Reduces errors caused by repetitive coding
Defining macros:
Before using macros, we have to define them. Macros are defined be-
fore the definition of segments. Assembler provides two directives for
defining a macro: MACRO and ENDM.MACRO directive informs the
assembler the beginning of a macro. The general form is:
Macro_name MACRO argument1, argument2, …
Arguments are optional. ENDM informs the assembler the end of the
macro. Its general form is : ENDM
Exercise Description---Con-
tinued
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. If you declared a macro and never used
it in your code, compiler will simply ignore it.

DISPLAY MACRO MSG


MOV AH,9
LEA DX,MSG
INT 21H
ENDM
DISPLAY :- is the Name (Identifier) of the Macro. MACRO is the Keyword
Used. MSG is the Argument Passed.
MOV AH,9 }
LEA DX,MSG } :- /* code inside macro */
INT 21H }
ENDM :- is the end of Macro.
The code which is used most of the time is written in between the macro for
reducing the length of Code.
.MODEL SMALL
.DATA
STRING1 DB 11H,22H,33H,44H,55H
MSG1 DB "FOUND$"
MSG2 DB "NOT FOUND$" UP:
SE DB 77H MOV BL,[SI]
PRINT MACRO MSG CMP AL, BL
MOV AH, 09H JZ FO
LEA DX, MSG INC SI
DEC CX
INT 21H
JNZ UP
ENDM
PRINT MSG2
.CODE JMP END1
MOV AX, @DATA
MOV DS, AX FO:
MOV AL, SE PRINT MSG1
LEA SI, STRING1
END1:
MOV CX, 05H
MOV AH,4CH
INT 21H
END
Steps to Execute Assembly Language programs
1) Install DOSBOX 0.74

2) Launch DOSBOX, By default it will be in Z drive <Z:\>


3) Change the drive to that, in which MASM is installed
mount c c:\masm
4) C:
5) C:\> Edit filename.asm
6) C:\> Masm filename.asm;
7) C:\> Link filename.obj;
8) Filename (Enter Key)
THANK YOU

You might also like