Professional Documents
Culture Documents
MPMC 32 Bit PDF
MPMC 32 Bit PDF
The manual is prepared with intention to cover the Laboratary Experiments according to
Jntuh Syllabus with step by step procedure.The following are the list of Experiments included in
ths Manual
I. Programs for 16 bit arithmetic operations for 8086 (using Various Addressing Modes).
II. Program for sorting an array for 8086.
III. Program for searching for a number or character in a string for 8086.
IV. Program for string manipulations for 8086.
V. Program for digital clock design using 8086.
MPMC LAB MANUAL
CONTENTS
Implementation of Programs
MPMC LAB MANUAL
3. In the New Project window, select Win32 under Visual C++ in the left panel, and
select Win32 Console Application in the middle panel. Give your project a suitable
name (near the bottom of the window):
1
MPMC LAB MANUAL
4. Click the OK button to continue. The Win32 Application Wizard window will appear.
Select Application Settings, and then select the Empty project check box.
Note: You may delete the Header Files, Resource Files, and Source Files folders if you
wish. They are not necessary.
If You want create a assembly language source file then Right –click on the
project Name in the visual studio windows, select Add, select New Item
In the Add New window, select Code under Visual C++ in the left panel,
and select C++ File (.cpp) in the middle panel. Give your file name with .asm
extension and then click on Add
2
MPMC LAB MANUAL
7. Next, right click your project name, select Build Dependencies, then select Build
Customizations from the popup menu. When you see the above window, select the
check box next to masm and click the OK button to close the dialog.
8. Right-click the project name in the Solution Explorer window and select Properties from
the popup menu. Expand the entry under Configuration Properties. Then expand the
entry named Microsoft Macro Assembler. This is what you should see:
9. Modify the Include Paths option so it equals "C:\Masm". This tells the assembler where
to find files having a filename extension of ".inc". Here is a sample:
3
MPMC LAB MANUAL
10. Next, select the Listing File entry, also in the Microsoft Macro Assembler group. Modify
the Assembled Code Listing File entry (shown below) so it contains $(ProjectName).lst.
This uses a built-in variable to identify the name of the source input file, with a file
extension of .lst. So, if your program were named main.asm, the listing file would be
named main.lst:
4
MPMC LAB MANUAL
11. Find the Linker entry under Configuration Properties. Select the Input entry, and
insert masm32.lib;at the beginning of the Additional Dependencies entry. The
filenames must be separated by semicolons.
12. Select Linker under Configuration Properties, and then select General. The Additional Library
Directories entry must contain c:\Masm32 so the linker can find the masm32.lib library file:
5
MPMC LAB MANUAL
13. Select Linker under the Configuration Properties and select Debugging. Verify that
the Generate Debug Info option is equal to either true or Optimize for debugging
(/DEBUG)
14. After Select Advanced under the Linker entry. Set the Image Has Safe Exception
Handlers option to No
6
MPMC LAB MANUAL
15. Then Click the OK button to close the Property Pages window. Verify that your project
has been created correctly by building and debugging the program as you did in an
earlier tutorial.
7
MPMC LAB MANUAL
Program No 1
Programs for 32 bit arithmetic operations for 8086 (using
Various Addressing Modes)
a) Addition:
i) 16 bit addition:
AIM: - Write an assembly language program for Addition of two 32-bit numbers.
Tool Requirement: Visual Studio 2015 with Masm
Program:
Include masm32.inc
.code
main proc
mov eax,5
add eax,6
invoke ExitProcess,0
main endp
end main
OUTPUT
8
MPMC LAB MANUAL
9
MPMC LAB MANUAL
b) Subtraction:
i) 16 bit Subtraction:
AIM: - Write an assembly language program for Subtraction of two 16-bit numbers.
Tool Requirement: Visual Studio 2015 with masm
Program TITLE (.asm)
INCLUDE masm32.inc
.data
.code
main PROC
MOV eAX, 6h
MOV eBX, 3h
SUB eAX, eBX
exit
main ENDP
END main
OUTPUT
10
MPMC LAB MANUAL
.code
main PROC
MOV eAX, 0000h
LEA eSI,str1
LEA eDI,str3
LEA eBX,str2
MOV CL, 05
UP : MOV AL, [eSI]
SUB AL, [eBX]
MOV [eDI], AL
INC eSI
INC eBX
INC eDI
DEC CL
JNZ UP
exit
main ENDP
END main
OUTPUT
11
MPMC LAB MANUAL
c) Multiplication:
i) 32 bit multiplication and imultiplication:
AIM: - Wite an assembly language program for multiplication of two 16-bit numbers.
Tool Requirement: Visual Studio 2015 with masm
Program ; This program shows examples of both signed and unsigned multiplication.
INCLUDE masm32.inc
.code
main PROC
mov ax,255
mov bx,255
imul bx
;Example 1
mov al,5h
mov bl,10h
mul bl ; CF = 0
;Example 2
.data
val1 WORD 2000h
val2 WORD 0100h
.code
mov ax,val1
mul val2 ; CF = 1
;Example 3:
mov eax,12345h
mov ebx,1000h
mul ebx ; CF = 1
; IMUL Examples:
; Example 4:
.data
val3 SDWORD ?
.code
mov eax,+4823424
mov ebx,-423
imul ebx ; EDX=FFFFFFFFh, EAX=86635D80h
mov val3,eax
exit
main ENDP
END main
12
MPMC LAB MANUAL
OUTPUT
13
MPMC LAB MANUAL
d) iDivision:
32 bit division:
AIM: - Write an assembly language program for multiplication of two 32-bit numbers.
; Example 2
.data
wordVal SWORD -5000
.code
mov ax,wordVal ; dividend, low
cwd ; extend AX into DX
mov bx,+256 ; divisor
idiv bx ; quotient AX = -19, rem DX = -136
call DumpRegs
; Example 3
.data
dwordVal SDWORD +50000
.code
mov eax,dwordVal ; dividend, low
cdq ; extend EAX into EDX
mov ebx,-256 ; divisor
idiv ebx ; quotient EAX = -195, rem EDX = +80
call DumpRegs
exit
main ENDP
END main
14
MPMC LAB MANUAL
OUTPUT
15
MPMC LAB MANUAL
Program No 2:
Program for sorting an array for 8086.
i) ASCENDING ORDER
AIM:-Program to sort the given numbers in ascending order
Tool Requirement: Visual Studio 2015 with masm
Program TITLE (.asm)
; This program
; Last update:
INCLUDE masm32.inc
.data
STRING1 DB 99H,12H,56H,45H,36H
.code
main PROC
MOV AX, 00H
MOV CH, 04H
DEC CH
UP1: MOV CL, 04h
LEA eSI,STRING1
;MOV eSI, 2000
UP: MOV AL, [eSI]
INC SI
CMP AL, [eSI]
JC DOWN
XCHG AL, [eSI]
DEC SI
MOV [eSI], AL
INC eSI
DOWN: DEC CL
JNZ UP
DEC CH
JNZ UP1
exit
main ENDP
END main
OUTPUT
16
MPMC LAB MANUAL
17
MPMC LAB MANUAL
Program No: 3
Program for searching for a number or character in a string for 8086.
AIM: Write an alp program for to search a number or character from a string
Tool Requirement: Visual Studio 2015 with masm
Program TITLE (.asm)
INCLUDE masm32.inc
MsgBox PROTO
.data
STRING1 DB 11H,22H,33H,44H,55H
MSG1 BYTE "FOUND",0
MSG2 BYTE "NOT FOUND",0
SE DB 02H
.code
main PROC
MOV AL, SE
LEA eSI, STRING1
MOV CX, 04H
UP: MOV BL,[eSI]
CMP AL, BL
JZ FO
INC eSI
DEC CX
JNZ UP
mov edx,OFFSET MSG2
call WriteString
JMP END1
18
MPMC LAB MANUAL
Program NO.4
Program for string manipulations for 8086.
1) Moving Block Of Data From One Memory Location To Another Memory Location
AIM: To write an alp for transfer block of data from one memory location to another
memory location.
Tool Requirement: Visual Studio 2015 with masm
Program
TITLE (.asm)
INCLUDE masm32.inc
.data
STRING1 DB 01H,02H,03H,04H,05H
STRING2 DB 4 DUP(0)
.code
main PROC
LEA eSI,STRING1
LEA eDI,STRING2
MOV CX,05H
CLD
REP MOVSB
exit
main ENDP
END main
OUTPUT
19
MPMC LAB MANUAL
2) Reverse of a data:
AIM: To write a alp for reverse of a given string
Tool Requirement: Visual Studio 2015 with masm
Program
TITLE (.asm)
INCLUDE masm32.inc
.data
STRING1 DB 01H,02H,03H,04H,05H
STRING2 DB 4 DUP(0)
.code
main PROC
LEA eSI,STRING1
LEA eDI,STRING2
MOV CX, 0008
ADD eSI, 07
UP: MOV AL, [eSI]
MOV [eDI], AL
DEC eSI
INC eDI
DEC CX
JNZ UP
exit
main ENDP
END main
OUTPUT
20
MPMC LAB MANUAL
21
MPMC LAB MANUAL
OUTPUT
22
MPMC LAB MANUAL
Program NO.5
Program for digital clock design using 8086.
.code
main PROC
mov ax,@data
mov ds,ax
23
MPMC LAB MANUAL
24
MPMC LAB MANUAL
25