Laboratory Manual: Cs/Eee/Instr F241 Microprocessor Programming & Interfacing - Introduction To MASM
Laboratory Manual: Cs/Eee/Instr F241 Microprocessor Programming & Interfacing - Introduction To MASM
Anupama
MANUAL Meetha.V.Shenoy
CS/EEE/INSTR F241
Microprocessor Programming &
Interfacing - Introduction to MASM
Lab2- Introduction to MASM
2.0 Introduction
Assembly language unlocks the secrets of computers hardware and software. An assembler
converts source code to machine own language. Microsoft Macro Assembler (MASM), product of
Microsoft Corporation includes several features which makes programming efficient and
productive. The following chapter will give an overview how to use MASM for assembling the
80x86 program you code.
Editor
We will use DOS text editor to type our program. Go to directory MASM611\BIN type edit
filename.asm
Use "Alt" Key to start the "Top Menus", then use "Arrow Keys" to select entries in the "Menu".
All the data and code fit in one segment Tiny programs when compiled give .COM executable -
the program must be originated at location 100H
.Model Tiny
.386 ;Assembler by default accepts only
8086/8088 instructions, unless a
program is preceded by .386/.486
directive to select the microprocessor
.data ; Data Segment
COUNT EQU 32H
VAL1 EQU 0030H
DAT1 DB 45H,67H,100,’A’
WRD DW 10H, 3500H,0910H
DAT2 DD 0902H
DAT3 DW 2 DUP(0)
DAT4 DB 56H
RES DB 10 DUP(?)
DWRD DD 01020304H
.CODE
.STARTUP
MOV SI,DAT3
MOV AL, DAT1 + 1
MOV BX,WORD PTR DAT1+4
ADD BX,20H
MOV Al,[BX]
LEA BX,DAT4
MOV AL,[BX]
MOV BX,VAL1
MOV AL,FS:[BX]
MOV EBX, DWRD
.EXIT
END
2.1 Assembling
Method 1:
Now type
Check the files created at each step and examine the content of .lst and .map file
Method 2:
To create list and map file command format is ‘ml /Fl /Fm Filename.asm
Check the files created at each step and examine the content of .lst and .map file
To check the working of the program – execute DEBUGX Filename.com and then trace or go in
DEBUGX.
Questions
(1)What are the errors if you just change Tiny to Small in the .Model Statement?
(3) Remove .386 statement. When you assemble what is the error? Why is there an error?
To check the working of the program – execute DEBUGX Filename.exe and then trace or go in
DEBUGX.
Note:
Tasks:
1. Write an ALP that finds the maximum number from a set of 32-bit numbers
2. Write an ALP to add 2 16-byte nos. using them
a. as 16-bit data
b. as 32-bit data
3. Write an ALP that will examine the contents of set of 10 bytes starting from location
‘ARRAY1’ for the presence of data ‘0AH’ and replace it with the ASCII character ‘E’.
4. Write an ALP that will count the number of negative numbers in an array of 16-bit
signed data stored from location ‘ARRAY1’. The number of elements in the array is
present in location ‘COUNT’. The count of negative numbers must be stored in
location ‘NEG1’
5. Write an ALP that will transfer data from ‘ARRAY1’ to ‘ARRAY2’. The number of
elements in the array is 10. The array is a double word array. The starting address of
ARRAY2 = starting address of ARRAY1 + 20d.