MP Lab Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

GHARDA FOUNDATION’S

GHARDA INSTITUTE OF TECHNOLOGY


A/P:-LAVEL, TALUKA: KHED,DIST. RATNAGIRI,
STATE:MAHARASTRA, PIN:- 415 708
TELEPHONE NO:- 02356-262795/97/98 FAX NO :- 02356-262795

LABORATORY MANUAL
Department

Of

Computer Engineering

Microprocessor
Year 2016-17 TE Semester :- V

Prepared By
Prof.V. N. Rane

Page 1
Sr No. Name of Experiments

1 ALP for 8086 for 8-bit/16-bit Addition and subtraction of two number

2 ALP for 8086 for 8-bit/16-bit multiplication and division of two number

3 ALP for 8086 to generate Fibonacci series

4 ALP for 8086 to find factorial of Given numbers

5 ALP for 8086 to find largest and smallest number from given list.

6 ALP for 8086 to find average of n numbers

7 ALP for reverse the string

8 Write a program to convert string from uppercase to lower case

9 Write a program to generate different LED patterns by interfacing 8086


with 8255
10 Write a Program to display digit 0 to 9 on seven segment display module
by interfacing 8086 with 8255
11 Case Study on RISC Processor

12 Case Study on CISC Processor

Page 2
Introduction to MASM

MASM stands for Microsoft Macro Assembler. It is a command line assembler.


This means that the user needs to have already created a program in the DOS
editor, such as edit, before using the assembler. It does not have provisions to
create, edit, save and debug programs. All the commands accepted by the
assembler are entered at the DOS prompt.

Creating a program file:


Create a file with ‘.asm’ extension at the command prompt.

C:\masm611\bin>EDIT sourcefilename.asm
Loading and Linking:
Run the assembler to create the .com or .exe file by typing the command at the
command prompt:

D:\masm611\bin>ML sourcefilename.asm.

MASM Debugger: CodeView

Code View (CV) is the debugger that comes along with MASM. To launch code
view type “cv somefile.com” at the DOS prompt. The startup screen consists of
windows, each of which has its own name and purpose. The main screen of the
CodeView debugger is divided into windows. A good place to start for
debugging assembly language programs is with the following windows since
they are the ones most commonly used:
* The source text window
* The registers window
* The command window

The Source window contains the text of your program in assembly language and
the line numbers. When CodeView executes one command in your executable
module (.COM), it highlights the corresponding line in your source code in the
Source window. To execute one command, press the F8 or F10 key.

Page 3
The Register window reflects the current state of the registers and flags. The
registers are represented by name (AX, BX and so on) and their hexadecimal
values. The Register window is situated on the right side of the screen. This
window appears when you press the F2 key and disappears if you press it again.

The Command window is intended for controlling the debugging process. The
cursor is usually located in this window, indicating that you can type in
commands.

Instruction Template:

The format for an assembly instruction


[label:] Opcode [operand [, operand]] [; comment]
The contents inside [ ] is optional. Fields should be separated by space or
tabs. Comments are ignored by the assembler while assembling the
program to produce the executable code

Example:

1. Type the following program using EDIT and save it with .asm extension.
.model small
.code
.startup
mov ax,50h
mov bx,20h
mov dx,80h
mov cx,05h
loop1: dec cx
jnz loop1
.exit
end
2. Assemble the program using “ML filename.asm” at the prompt.
3. Open code view debugger using “cv filename.exe”
4. Observe the above said windows in the startup screen of code view.
5. For line by line execution of the program press <F8> key and watch the
change in the content of the registers in the registers’ window.

Page 4
EXPERIMENT NO.1 &2

Aim: Implementation of 8bit & 16 bit addition, subtraction, multiplication, and


division.
_______________________________1.Addition_______________________________
.model small
.data
.code
mov ax,@data
mov ds,ax
mov al,10h
mov bl,12h
add al,bl
mov ah,4ch
INT 21h
End
---------------------------------------OUTPUT-----------------------------------------------------
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Admin>cd..
C:\Users>cd..
C:\>cd masm611
C:\MASM611>cd bin
C:\MASM611\BIN>ml pr1.asm
Microsoft (R) Macro Assembler Version 6.11
Copyright (C) Microsoft Corp 1981-1993. All rights reserved.
Assembling: pr1.asm
Microsoft (R) Segmented Executable Linker Version 5.31.009 Jul 13 1992
Copyright (C) Microsoft Corp 1984-1992. All rights reserved.

Object Modules [.obj]: pr1.obj


Run File [pr1.exe]: "pr1.exe"
List File [nul.map]: NUL
Libraries [.lib]:
Definitions File [nul.def]:
LINK : warning L4021: no stack segment
LINK : warning L4038: program has no starting address
C:\MASM611\BIN>link pr1.obj

Page 5
C:\MASM611\BIN>debug pr1.exe
-p
AX=1426 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0003 NV UP EI PL NZ NA PO NC
1425:0003 8ED8 MOV DS,AX
-p
AX=1426 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0005 NV UP EI PL NZ NA PO NC
1425:0005 B010 MOV AL,10
-p
AX=1410 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0007 NV UP EI PL NZ NA PO NC
1425:0007 B312 MOV BL,12
-p
AX=1410 BX=0012 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0009 NV UP EI PL NZ NA PO NC
1425:0009 02C3 ADD AL,BL
-p
AX=1422 BX=0012 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000B NV UP EI PL NZ NA PE NC
1425:000B B44C MOV AH,4C
-p
AX=4C22 BX=0012 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000D NV UP EI PL NZ NA PE NC
1425:000D CD21 INT 21
-p
Program terminated normally
_____________________________2.Subtraction_______________________________
.model small
.data
.code
mov ax,@data
mov ds,ax
mov al,20h
mov bl,12h
sub al,bl
mov ah,4ch
INT 21h
End
---------------------------------------OUTPUT---------------------------------------------------------
C:\MASM611\BIN>debug pr2.exe
-p
AX=1426 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0003 NV UP EI PL NZ NA PO NC
1425:0003 8ED8 MOV DS,AX

Page 6
-p
AX=1426 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0005 NV UP EI PL NZ NA PO NC
1425:0005 B020 MOV AL,20
-p
AX=1420 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0007 NV UP EI PL NZ NA PO NC
1425:0007 B312 MOV BL,12
-p
AX=1420 BX=0012 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0009 NV UP EI PL NZ NA PO NC
1425:0009 2AC3 SUB AL,BL
-p
AX=140E BX=0012 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000B NV UP EI PL NZ AC PO NC
1425:000B B44C MOV AH,4C
-p
AX=4C0E BX=0012 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000D NV UP EI PL NZ AC PO NC
1425:000D CD21 INT 21
-p
Program terminated normally
_____________________________3.Multiplication_____________________________
.model small
.data
.code
mov ax,@data
mov ds,ax
mov al,10h
mov bl,10h
mul bl
mov ah,4ch
INT 21h
End
---------------------------------OUTPUT--------------------------------------------------------------
C:\MASM611\BIN>debug pr3.exe
-p
AX=1426 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0003 NV UP EI PL NZ NA PO NC
1425:0003 8ED8 MOV DS,AX
-p
AX=1426 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0005 NV UP EI PL NZ NA PO NC
1425:0005 B010 MOV AL,10
-p

Page 7
AX=1410 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0007 NV UP EI PL NZ NA PO NC
1425:0007 B310 MOV BL,10
-p
AX=1410 BX=0010 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0009 NV UP EI PL NZ NA PO NC
1425:0009 F6E3 MUL BL
-p
AX=0100 BX=0010 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000B OV UP EI PL NZ NA PE CY
1425:000B B44C MOV AH,4C
-p
AX=4C00 BX=0010 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000D OV UP EI PL NZ NA PE CY
1425:000D CD21 INT 21
-p
Program terminated normally
____________________________4.Divison____________________________________
.model small
.data
.code
mov ax,@data
mov ds,ax
mov ax,10h
mov bx,5h
div bx
mov ah,4ch
INT 21h
end
------------------------------------OUTPUT------------------------------------------------------------
C:\MASM611\BIN>debug pr4.exe
-p
AX=1426 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0003 NV UP EI PL NZ NA PO NC
1425:0003 8ED8 MOV DS,AX
-p
AX=1426 BX=0000 CX=000F DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0005 NV UP EI PL NZ NA PO NC
1425:0005 B81000 MOV AX,0010
-p
AX=0010 BX=0000 CX=0011 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0008 NV UP EI PL NZ NA PO NC
1425:0008 BB0500 MOV BX,0005
-p
AX=0010 BX=0005 CX=0011 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000

Page 8
DS=1426 ES=1415 SS=1425 CS=1425 IP=000B NV UP EI PL NZ NA PO NC
1425:000B F7F3 DIV BX
-p
AX=0003 BX=0005 CX=0011 DX=0001 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000D NV UP EI PL NZ NA PO NC
1425:000D B44C MOV AH,4C
-p
AX=4C03 BX=0005 CX=0011 DX=0001 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PO NC
1425:000F CD21 INT 21
-p
Program terminated normally

Conclusion : Thus we have studied ALP for Addition, substration


,multiplication & division .

Page 9
EXPERIMENT NO.3

Aim: Implementation of ALP generates Fibonacci series.

.model small
.data
.code
mov ax,@data
mov ds,ax
mov cx,0005h
mov ax,0000h
mov bx,0001h
up: add ax,bx
xchg ax,bx
dec cx
jnz up
mov ah,4ch
int 21h
end
-----------------------------------OUTPUT-----------------------------------------------------------
C:\MASM611\BIN>link pr8.obj
C:\MASM611\BIN>debug pr8.exe
-p
AX=1426 BX=0000 CX=0018 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0003 NV UP EI PL NZ NA PO NC
1425:0003 8ED8 MOV DS,AX
-p
AX=1426 BX=0000 CX=0018 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0005 NV UP EI PL NZ NA PO NC
1425:0005 B90500 MOV CX,0005
-p
AX=1426 BX=0000 CX=0005 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0008 NV UP EI PL NZ NA PO NC
1425:0008 B80000 MOV AX,0000
-p
AX=0000 BX=0000 CX=0005 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000B NV UP EI PL NZ NA PO NC
1425:000B BB0100 MOV BX,0001
-p
AX=0000 BX=0001 CX=0005 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000E NV UP EI PL NZ NA PO NC

Page 10
1425:000E 03C3 ADD AX,BX
-p
AX=0001 BX=0001 CX=0005 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0010 NV UP EI PL NZ NA PO NC
1425:0010 93 XCHG BX,AX
-p
AX=0001 BX=0001 CX=0005 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0011 NV UP EI PL NZ NA PO NC
1425:0011 49 DEC CX
-p
AX=0001 BX=0001 CX=0004 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI PL NZ NA PO NC
1425:0012 75FA JNZ 000E
-p
AX=0001 BX=0001 CX=0004 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000E NV UP EI PL NZ NA PO NC
1425:000E 03C3 ADD AX,BX
-p
AX=0002 BX=0001 CX=0004 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0010 NV UP EI PL NZ NA PO NC
1425:0010 93 XCHG BX,AX
-p
AX=0001 BX=0002 CX=0004 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0011 NV UP EI PL NZ NA PO NC
1425:0011 49 DEC CX
-p
AX=0001 BX=0002 CX=0003 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI PL NZ NA PE NC
1425:0012 75FA JNZ 000E
-p
AX=0001 BX=0002 CX=0003 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000E NV UP EI PL NZ NA PE NC
1425:000E 03C3 ADD AX,BX
-p
AX=0003 BX=0002 CX=0003 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0010 NV UP EI PL NZ NA PE NC
1425:0010 93 XCHG BX,AX
-p
AX=0002 BX=0003 CX=0003 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0011 NV UP EI PL NZ NA PE NC
1425:0011 49 DEC CX
-p
AX=0002 BX=0003 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI PL NZ NA PO NC
1425:0012 75FA JNZ 000E

Page 11
-p
AX=0002 BX=0003 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000E NV UP EI PL NZ NA PO NC
1425:000E 03C3 ADD AX,BX
-p
AX=0005 BX=0003 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0010 NV UP EI PL NZ NA PE NC
1425:0010 93 XCHG BX,AX
-p
AX=0003 BX=0005 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0011 NV UP EI PL NZ NA PE NC
1425:0011 49 DEC CX
-p
AX=0003 BX=0005 CX=0001 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI PL NZ NA PO NC
1425:0012 75FA JNZ 000E
-p
AX=0003 BX=0005 CX=0001 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=000E NV UP EI PL NZ NA PO NC
1425:000E 03C3 ADD AX,BX
-p
AX=0008 BX=0005 CX=0001 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0010 NV UP EI PL NZ NA PO NC
1425:0010 93 XCHG BX,AX
-p
AX=0005 BX=0008 CX=0001 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0011 NV UP EI PL NZ NA PO NC
1425:0011 49 DEC CX
-p
AX=0005 BX=0008 CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI PL ZR NA PE NC
1425:0012 75FA JNZ 000E
-p
AX=0005 BX=0008 CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0014 NV UP EI PL ZR NA PE NC
1425:0014 B44C MOV AH,4C
-p
AX=4C05 BX=0008 CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1426 ES=1415 SS=1425 CS=1425 IP=0016 NV UP EI PL ZR NA PE NC
1425:0016 CD21 INT 21
-p
Program terminated normally

Conclusion : Thus we have studied ALP for Fibonacci series.

Page 12
EXPERIMENT NO:-4

Aim:-Implementation of ALP to find out factorial of number.

.model small
.data
.code
mov ax,@data
mov ax,ds
mov ah,00h
mov al,01h
mov cl,04h
up:MUL cl
DEC cl
JNZ up
mov ah,4ch
INT 21h
end
---------------------------------OUTPUT------------------------------------------------
C:\MASM611\BIN>ml pr5.asm
Microsoft (R) Macro Assembler Version 6.11
Copyright (C) Microsoft Corp 1981-1993. All rights reserved.
Assembling: pr5.asm
Microsoft (R) Segmented Executable Linker Version 5.31.009 Jul 13 1992
Copyright (C) Microsoft Corp 1984-1992. All rights reserved.
Object Modules [.obj]: pr5.obj
Run File [pr5.exe]: "pr5.exe"
List File [nul.map]: NUL
Libraries [.lib]:
Definitions File [nul.def]:
LINK : warning L4021: no stack segment
LINK : warning L4038: program has no starting address
C:\MASM611\BIN>link pr5.obj
C:\MASM611\BIN>debug pr5.exe
-p
AX=1426 BX=0000 CX=0015 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0003 NV UP EI PL NZ NA PO NC
1425:0003 8CD8 MOV AX,DS

Page 13
-p
AX=1415 BX=0000 CX=0015 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0005 NV UP EI PL NZ NA PO NC
1425:0005 B400 MOV AH,00
-p
AX=0015 BX=0000 CX=0015 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0007 NV UP EI PL NZ NA PO NC
1425:0007 B001 MOV AL,01
-p
AX=0001 BX=0000 CX=0015 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0009 NV UP EI PL NZ NA PO NC
1425:0009 B104 MOV CL,04
-p
AX=0001 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000B NV UP EI PL NZ NA PO NC
1425:000B F6E1 MUL CL
-p
AX=0004 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000D NV UP EI PL NZ NA PO NC
1425:000D FEC9 DEC CL
-p
AX=0004 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PE NC
1425:000F 75FA JNZ 000B
-p
AX=0004 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000B NV UP EI PL NZ NA PE NC
1425:000B F6E1 MUL CL
-p
AX=000C BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000D NV UP EI PL NZ NA PE NC
1425:000D FEC9 DEC CL
-p
AX=000C BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PO NC
1425:000F 75FA JNZ 000B
-p
AX=000C BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000B NV UP EI PL NZ NA PO NC
1425:000B F6E1 MUL CL
-p
AX=0018 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000D NV UP EI PL NZ NA PE NC
1425:000D FEC9 DEC CL
-p

Page 14
AX=0018 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PO NC
1425:000F 75FA JNZ 000B
-p
AX=0018 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000B NV UP EI PL NZ NA PO NC
1425:000B F6E1 MUL CL
-p
AX=0018 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000D NV UP EI PL NZ NA PE NC
1425:000D FEC9 DEC CL
-p
AX=0018 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL ZR NA PE NC
1425:000F 75FA JNZ 000B
-p
AX=0018 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0011 NV UP EI PL ZR NA PE NC
1425:0011 B44C MOV AH,4C
-p
AX=4C18 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0013 NV UP EI PL ZR NA PE NC
1425:0013 CD21 INT 21
-p
Program terminated normally

Conclusion : Thus we have studied ALP for Factorial of a number.

Page 15
EXPERIMENT NO.5

Aim: Implementation of ALP to find out largest and smallest no. from given list.

____________________________1.Largest_______________________________________
.model small
.data
x dw 0010h,0020h,0030h,0040h,0050h
.code
mov ax,@data
mov ds,ax
mov cx,05h
lea si,x
mov ax,[si]
dec cx
up: cmp ax,[si+2]
ja down
mov ax,[si+2]
down: add si,02h
dec cx
jnz up
mov ah,4ch
int 21h
end
---------------------------------------OUTPUT--------------------------------------------------------
C:\MASM611\BIN>debug pr6.exe
-p
AX=1427 BX=0000 CX=002C DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0003 NV UP EI PL NZ NA PO NC
1425:0003 8ED8 MOV DS,AX
-p
AX=1427 BX=0000 CX=002C DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0005 NV UP EI PL NZ NA PO NC
1425:0005 B90500 MOV CX,0005
-p
AX=1427 BX=0000 CX=0005 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0008 NV UP EI PL NZ NA PO NC
1425:0008 8D360200 LEA SI,[0002] DS:0002=0010
-p
AX=1427 BX=0000 CX=0005 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000C NV UP EI PL NZ NA PO NC
1425:000C 8B04 MOV AX,[SI] DS:0002=0010
-p
AX=0010 BX=0000 CX=0005 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
Page 16
DS=1427 ES=1415 SS=1425 CS=1425 IP=000E NV UP EI PL NZ NA PO NC
1425:000E 49 DEC CX
-p
AX=0010 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PO NC
1425:000F 3B4402 CMP AX,[SI+02] DS:0004=0020
-p
AX=0010 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI NG NZ NA PE CY
1425:0012 7703 JA 0017
-p
AX=0010 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0014 NV UP EI NG NZ NA PE CY
1425:0014 8B4402 MOV AX,[SI+02] DS:0004=0020
-p
AX=0020 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0017 NV UP EI NG NZ NA PE CY
1425:0017 83C602 ADD SI,+02
-p
AX=0020 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001A NV UP EI PL NZ NA PO NC
1425:001A 49 DEC CX
-p
AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001B NV UP EI PL NZ NA PE NC
1425:001B 75F2 JNZ 000F
-p
AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PE NC
1425:000F 3B4402 CMP AX,[SI+02] DS:0006=0030
-p
AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI NG NZ NA PE CY
1425:0012 7703 JA 0017
-p
AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0014 NV UP EI NG NZ NA PE CY
1425:0014 8B4402 MOV AX,[SI+02] DS:0006=0030
-p
AX=0030 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0017 NV UP EI NG NZ NA PE CY
1425:0017 83C602 ADD SI,+02
-p
AX=0030 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001A NV UP EI PL NZ NA PE NC

Page 17
1425:001A 49 DEC CX
-p
AX=0030 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001B NV UP EI PL NZ NA PO NC
1425:001B 75F2 JNZ 000F
-p
AX=0030 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PO NC
1425:000F 3B4402 CMP AX,[SI+02] DS:0008=0040
-p
AX=0030 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI NG NZ NA PE CY
1425:0012 7703 JA 0017
-p
AX=0030 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0014 NV UP EI NG NZ NA PE CY
1425:0014 8B4402 MOV AX,[SI+02] DS:0008=0040
-p
AX=0040 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0017 NV UP EI NG NZ NA PE CY
1425:0017 83C602 ADD SI,+02
-p
AX=0040 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001A NV UP EI PL NZ NA PO NC
1425:001A 49 DEC CX
-p
AX=0040 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001B NV UP EI PL NZ NA PO NC
1425:001B 75F2 JNZ 000F
-p
AX=0040 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PO NC
1425:000F 3B4402 CMP AX,[SI+02] DS:000A=0050
-p
AX=0040 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI NG NZ NA PE CY
1425:0012 7703 JA 0017
-p
AX=0040 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0014 NV UP EI NG NZ NA PE CY
1425:0014 8B4402 MOV AX,[SI+02] DS:000A=0050
-p
AX=0050 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0017 NV UP EI NG NZ NA PE CY
1425:0017 83C602 ADD SI,+02

Page 18
-p
AX=0050 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=000A DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001A NV UP EI PL NZ NA PE NC
1425:001A 49 DEC CX
-p
AX=0050 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=000A DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001B NV UP EI PL ZR NA PE NC
1425:001B 75F2 JNZ 000F
-p
AX=0050 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=000A DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001D NV UP EI PL ZR NA PE NC
1425:001D B44C MOV AH,4C
-p
AX=4C50 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=000A DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001F NV UP EI PL ZR NA PE NC
1425:001F CD21 INT 21
-p
Program terminated normally
____________________________2.Smallest_____________________________________
.model small
.data
x dw 0070h,0020h,0030h,0080h,0050h
.code
mov ax,@data
mov ds,ax
mov cx,05h
lea si,x
mov ax,[si]
dec cx
up: cmp ax,[si+2]
jna down
mov ax,[si+2]
down: add si,02h
dec cx
jnz up
mov ah,4ch
int 21h
end
----------------------------------OUTPUT---------------------------------------------------------------
C:\MASM611\BIN>debug pr7.exe
-p
AX=1427 BX=0000 CX=002C DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1415 ES=1415 SS=1425 CS=1425 IP=0003 NV UP EI PL NZ NA PO NC
1425:0003 8ED8 MOV DS,AX
-p

Page 19
AX=1427 BX=0000 CX=002C DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0005 NV UP EI PL NZ NA PO NC
1425:0005 B90500 MOV CX,0005
-p
AX=1427 BX=0000 CX=0005 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0008 NV UP EI PL NZ NA PO NC
1425:0008 8D360200 LEA SI,[0002] DS:0002=0070
-p
AX=1427 BX=0000 CX=0005 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000C NV UP EI PL NZ NA PO NC
1425:000C 8B04 MOV AX,[SI] DS:0002=0070
-p
AX=0070 BX=0000 CX=0005 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000E NV UP EI PL NZ NA PO NC
1425:000E 49 DEC CX
-p
AX=0070 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PO NC
1425:000F 3B4402 CMP AX,[SI+02] DS:0004=0020
-p
AX=0070 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI PL NZ NA PE NC
1425:0012 7603 JBE 0017
-p
AX=0070 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0014 NV UP EI PL NZ NA PE NC
1425:0014 8B4402 MOV AX,[SI+02] DS:0004=0020
-p
AX=0020 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0002 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0017 NV UP EI PL NZ NA PE NC
1425:0017 83C602 ADD SI,+02
-p
AX=0020 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001A NV UP EI PL NZ NA PO NC
1425:001A 49 DEC CX
-p
AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001B NV UP EI PL NZ NA PE NC
1425:001B 75F2 JNZ 000F
-p
AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PE NC
1425:000F 3B4402 CMP AX,[SI+02] DS:0006=0030
-p
AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000

Page 20
DS=1427 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI NG NZ NA PE CY
1425:0012 7603 JBE 0017
-p
AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0017 NV UP EI NG NZ NA PE CY
1425:0017 83C602 ADD SI,+02
-p
AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001A NV UP EI PL NZ NA PE NC
1425:001A 49 DEC CX
-p
AX=0020 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001B NV UP EI PL NZ NA PO NC
1425:001B 75F2 JNZ 000F
-p
AX=0020 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PO NC
1425:000F 3B4402 CMP AX,[SI+02] DS:0008=0080
-p
AX=0020 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI NG NZ NA PE CY
1425:0012 7603 JBE 0017
-p
AX=0020 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0006 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0017 NV UP EI NG NZ NA PE CY
1425:0017 83C602 ADD SI,+02
-p
AX=0020 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001A NV UP EI PL NZ NA PO NC
1425:001A 49 DEC CX
-p
AX=0020 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001B NV UP EI PL NZ NA PO NC
1425:001B 75F2 JNZ 000F
-p
AX=0020 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=000F NV UP EI PL NZ NA PO NC
1425:000F 3B4402 CMP AX,[SI+02] DS:000A=0050
-p
AX=0020 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0012 NV UP EI NG NZ NA PO CY
1425:0012 7603 JBE 0017
-p
AX=0020 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0008 DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=0017 NV UP EI NG NZ NA PO CY

Page 21
1425:0017 83C602 ADD SI,+02
-p
AX=0020 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=000A DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001A NV UP EI PL NZ NA PE NC
1425:001A 49 DEC CX
-p
AX=0020 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=000A DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001B NV UP EI PL ZR NA PE NC
1425:001B 75F2 JNZ 000F
-p
AX=0020 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=000A DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001D NV UP EI PL ZR NA PE NC
1425:001D B44C MOV AH,4C
-p
AX=4C20 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=000A DI=0000
DS=1427 ES=1415 SS=1425 CS=1425 IP=001F NV UP EI PL ZR NA PE NC
1425:001F CD21 INT 21
-p
Program terminated normally

Conclusion : Thus we have studied ALP for largest and smallest number in the
given list.

Page 22
EXPERIMENT NO:-6

Aim:-Implimentation of ALP to find out average of N number


.model small
.data
A DB 20h,20h,20h,20h
.code
MOV ax,@data
MOV ds,ax
MOV Cx,00004h
Lea SI,A
MOV ax,0000h

B:ADD al,[SI]
INC SI
DEC Cx
JNZ B
MOV cl,04h
div cl
MOV ah,4ch
INT 21h
end

----------------------------------OUTPUT-----------------------------------------

AX=1428 BX=0000 CX=0022 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000


DS=1417 ES=1417 SS=1427 CS=1427 IP=0003 NV UP EI PL NZ NA PO NC
1427:0003 8ED8 MOV DS,AX
-t

AX=1428 BX=0000 CX=0022 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0005 NV UP EI PL NZ NA PO NC
1427:0005 B90400 MOV CX,0004
-t

AX=1428 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0008 NV UP EI PL NZ NA PO NC
1427:0008 8D360E00 LEA SI,[000E] DS:000E=2020

Page 23
-t

AX=1428 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=000E DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=000C NV UP EI PL NZ NA PO NC
1427:000C B80000 MOV AX,0000
-t

AX=0000 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=000E DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=000F NV UP EI PL NZ NA PO NC
1427:000F 0204 ADD AL,[SI] DS:000E=20
-t

AX=0020 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=000E DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0011 NV UP EI PL NZ NA PO NC
1427:0011 46 INC SI
-t

AX=0020 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=000F DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0012 NV UP EI PL NZ NA PE NC
1427:0012 49 DEC CX
-t

AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=000F DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0013 NV UP EI PL NZ NA PE NC
1427:0013 75FA JNZ 000F
-q

AX=0020 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=000F DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=000F NV UP EI PL NZ NA PE NC
1427:000F 0204 ADD AL,[SI] DS:000F=20
-t

AX=0040 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=000F DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0011 NV UP EI PL NZ NA PO NC
1427:0011 46 INC SI
-t

AX=0040 BX=0000 CX=0003 DX=0000 SP=0000 BP=0000 SI=0010 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0012 NV UP EI PL NZ AC PO NC
1427:0012 49 DEC CX
-t

AX=0040 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0010 DI=0000

Page 24
DS=1428 ES=1417 SS=1427 CS=1427 IP=0013 NV UP EI PL NZ NA PO NC
1427:0013 75FA JNZ 000F
-t

AX=0040 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0010 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=000F NV UP EI PL NZ NA PO NC
1427:000F 0204 ADD AL,[SI] DS:0010=20
-t

AX=0060 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0010 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0011 NV UP EI PL NZ NA PE NC
1427:0011 46 INC SI
-t

AX=0060 BX=0000 CX=0002 DX=0000 SP=0000 BP=0000 SI=0011 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0012 NV UP EI PL NZ NA PE NC
1427:0012 49 DEC CX
-t

AX=0060 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0011 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0013 NV UP EI PL NZ NA PO NC
1427:0013 75FA JNZ 000F
-t

AX=0060 BX=0000 CX=0001 DX=0000 SP=0000 BP=0000 SI=0011 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=000F NV UP EI PL NZ NA PO NC
1427:000F 0204 ADD AL,[SI] DS:0011=20
-t

AX=0080 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0012 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0015 NV UP EI PL ZR NA PE NC
1427:0015 B104 MOV CL,04
-t

AX=0080 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0012 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0017 NV UP EI PL ZR NA PE NC
1427:0017 F6F1 DIV CL
-t

AX=0020 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0012 DI=0000


DS=1428 ES=1417 SS=1427 CS=1427 IP=0019 NV UP EI PL ZR NA PE NC
1427:0019 B44C MOV AH,4C
-t

Page 25
AX=4C20 BX=0000 CX=0004 DX=0000 SP=0000 BP=0000 SI=0012 DI=0000
DS=1428 ES=1417 SS=1427 CS=1427 IP=001B NV UP EI PL ZR NA PE NC
1427:001B CD21 INT 21
-t

AX=4C20 BX=0000 CX=0004 DX=0000 SP=FFFA BP=0000 SI=0012 DI=0000


DS=1428 ES=1417 SS=1427 CS=00A7 IP=107C NV UP DI PL ZR NA PE NC
00A7:107C 90 NOP
-q

Conclusion : Thus we have studied ALP for finding average of N numbers.

Page 26
EXPERIMENT NO:-7

Aim: Implementation of ALP for 8086 for reverse of the string.


.model small
.data
m1 db 10,13,'Enter the string:$'
m2 db 10,13,'Reverse of string:$'
buff db 80
db 0
db 80 dup(0)
.code
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,m1
INT 21h
mov ah,0ah
lea dx,buff
INT 21h
mov ah,09h
lea dx,m2
INT 21h
lea bx,buff
Inc bx
mov ch,00h
mov cl,buff+1
mov di,cx
back:mov dl,[bx+di]
mov ah,02h
INT 21h
dec di
JNZ back
mov ah,4ch
INT 21h
end
------------------------------------OUTPUT--------------------------------------------------
C:\MASM611\BIN>ml pr12.asm
Microsoft (R) Macro Assembler Version 6.11
Copyright (C) Microsoft Corp 1981-1993. All rights reserved.
Assembling: pr12.asm
Microsoft (R) Segmented Executable Linker Version 5.31.009 Jul 13 1992

Page 27
Copyright (C) Microsoft Corp 1984-1992. All rights reserved.
Object Modules [.obj]: pr12.obj
Run File [pr12.exe]: "pr12.exe"
List File [nul.map]: NUL
Libraries [.lib]:
Definitions File [nul.def]:
LINK : warning L4021: no stack segment
LINK : warning L4038: program has no starting address
C:\MASM611\BIN>debug pr12.exe
-g

Enter the string:welcome


Reverse of string:emoclew

Conclusion : Thus we have studied ALP for reversing the string

Page 28
EXPERIMENT NO:-8

NAME : Progrm to Convert uppercase to lowercase.

TITLE : Program for upper case to lower case conversion

.model small
.data
M1 DB 10, 13, 'ENTER THE STRING : $'
M2 DB 10, 13, 'THE LOWERCASE STRING : $'
BUFF DB 80
DB 0
DB 80 DUP (0)
.code
.startup
MOV AH, 09H ; Display message1
MOV DX, OFFSET M1
INT 21H
MOV AH, 0AH ; input the string
LEA DX, BUFF
INT 21H
MOV AH, 09H
MOV DX, OFFSET M2 ; Display message M2
INT 21H
MOV CH, 00H
MOV CL, BUFF + 1 ; Take character count in DI
LEA BX, BUFF+2
MOV DI, 00H
BACK : MOV DL, [BX + DI] ; point to the first character
ADD DL, 20H ; convert to lowercase
MOV AH, 02H ;
INT 21H ; Display the character
INC DI ;
DEC CX ; Decrement character counter
JNZ BACK ; check if zero
MOV AH, 4CH ; Return to DOS
INT 21H
.exit
END
Page 29
EXPERIMENT NO:- 9&10

MICROPROCESSOR 8086 TRAINER KIT

8086 is a 16 bit third generation microprocessor and is suitable for an


Exceptionally wide spectrum of microcomputer applications.8086 has got
16 Data lines and 20 address lines.The lower 16 address lines are
multiplexed With 16 data lines.Hence it becomes necessary to latch the
address lines.This is done by using 74 LS 373.

SYSTEM SPECIFICATIONS

Central processor : 8086,16 bit Microprocessor operating in max. Mode


or 8088 8 bit Micropressor.
Co-processor : 8087 Numeric data processor
I/O : 8089 I/O processor
EPROM : 16K Bytes Eprom loaded in monitor expandable to
64k Bytes using 27C512.
RAM : 16K Bytes of CMOS RAM expandable to 64k
Byes using 6264/62256 with Battery Backup
using 3.6V NI-Cd battery.
Parallel : 72 I/O lines using three nos. of 8255.
Serial : RS-232-C Interface using 8251.
Interrpt : 8 Different level interupt using 8259.
Timer/Counter : Three 16 bit Timer/Counter using 8253.
Printer Interface : Centronix Printer Port (Optional)
Keyboard & Display : 105 IBM PC Keyboard & 20 x 2 LCD Display.
RTC : Real Time Clock (Optional)
BUS : All address, data and control signals (TTL
Compatible)
Power Supply : 5 V/2 Amps,  12V / 250ma
Physical Size : 26.5cm x 18 cm
Operating Temp. : 0 to 500

Page 30
SYSTEM CAPABILITIES

Keyboard Mode :

1. Examine/Modify the memory byte locations.


2. Examine/Modify the contents of any of internal register of 8086.
3. Move a block of Data/program from one location to another location.
4. Fill a particular memory area with a constant .
5. To execute the program in full clock speed.
6. To execute program in single instruction execution.

SYSTEM INSTALLATION

To install M86 -02 the following additional things are required.

1. Connect the AC Power supply through AC Power Chord provided to


the M86-02 kit.
2. Switch on the Power supply at the rear end.
3. A message – (M86-02 L) will come on display (PRESS RESET if you
do not get - (M86-02 L) )
4. Now M86-02 kit is ready for the user’s experiments for keyboard
Mode.

Page 31
OPERATING COMMANDS :

After power ON the system,it will display as follows :

( M86-02 L)
ENTER RETURN KEY..

After pressing Enter , the operating commands will be displayed:

(M 86-02 L) 7FFF
> A , D, F, G, I, M, P, T, U.

COMMAND DESCRIPTION
A –Assemble :
This command is used to convert the input Assemble Language to the
machine Language in the memory.Once under this command,first set the
address which is similar to the command “D” followed by an Enter or an
Arrow Down key to go to a new step.However,only a maximum of 35
words are allowed for input.
The following are some useful keys used to move the cursor around:

…………….. Move one space to the right.

SHIFT + ….Move one space to the left.

SHIFT
+ F5
…..Delete the character at the cursor.

SHIFT F6
+ …..Erase the content.

F5
…………. Leave a space at the cursor.

Page 32
[M 86-02 L].. 7FFF
> A , D, F, G, I, M, P, T, U.

[M 86-02 L] ..7FFF
A
Assembly language can be input at this time.
1. Only contains the Effective address but the Segment base in
included A 400
2. Input includes the segment base and the Effective address A
0000:400
3. Totally depends on the built in segment base and Effective address
A

If one of the above is used 0400 will appear on the screen and ready for
input data. “A” and “U” are the same command .an ARROW UP sign can
be used to check the earlier procedure.F6 is used to delete the input and
proceed to “U” Unassemble F7 is used to proceed to another command.

D - Display or modify the arm’s Hexadecimal :


A.D.U. are the important commands in the compiling.The effective
address or both the effective address and segment base can be used
during input.When the cursor is placed at the beginning ,the : Key will
immediately show “F000” as the segment base and the Effective address
Next.

Syntax as follows :

D (If no input ,press Enter key or ARROW UP/DOWN key would


allow the built –in address to be used)
D 0400 (Uses built-in segment base but specify the Effective address)
D 0:0400 (Specify both the Segment base and Effective address)

Page 33
If press the Enter or the ARROW DOWN key after specifying the
address,the memory will display the data.Press ARROW UP key will
Allowed the addrfess to subtract 8 and store in the memory as a whole

Number .Otherwise,an ARROW DOWN key indicates an addition of 8 in


the address and these changes in the memory (as a machine language).

Syntax is as followed :

Segment Base
Effective Address
Content of Address ,a
Total of 8 bytes

0000:0400 B3 C0 9A
78 F 0 00 F0 BB

If addres is not a whole number 8 ,the following will show :

0000:0400 B3 C0 9A
78 F 0 00 F0 BB

The above data shown at the location 400 are the arbitrary data’s.

The following keys can be used to change the contents of RAM

SHIFT + SHIFT + Cursor operational Keys


, ,

G , I , M , T , U , F7 , P

Command modification keys

F - Fill data into the RAM :


By setting the strarting,ending address and the details ,an Enter key will
allow the data to enter the RAM

Syntax
[ M 86 -02 L] . . 7 F F F
>A.D.F.G.I.M.P.T.U. Page 34
Once ‘F’ is entered the command can be proceeded.
[ M 86 -02 L] . . 7 F F F
F 0000:0400 0400 57

Data to be filled
Ending Position
Starting Position
Segment Base

Cursor position keys :

SHIFT SHIFT
, + , , +

The ending position has to be bigger than or equal to the starting


position,otherwise the smaller user will become the ending position and
the bigger user is the starting position.

G -Proceed to the address for execution :


The GO command ,which causes the machine language statements to be
executed .This command executes the loaded program and allows the user
to specify the addresses at which program execution will stop.The syntax
is as followed :
[ M 86 -02 L] . . 7 F F F
>A.D.F.G.I.M.P.T.U.
When the ‘G’ key has been applied ,the procedure can be taken place.
Cursor operational keys :
SHIFT SHIFT
, + + , , +

(Allow to move in the Segment and effective address area)

Command Modification Keys :

G , I , M , T , U , F , P

Page 35
Once the ‘GO’ command has been executed ,it will completely leave the
system and proceed to the user’s design.

Flowchart of G – Command

PROCEED
TO
A NEW
CS,DS,ES ADDRESS
FOLLOW REGISTERS FOR
INPUT THE INPUT HAVE THE
THE EXECUTION
OF THE STARTING BEGINS AT
START STARTING END
USER TO ADDRESS 0000:0309
ADDRESS SET THE IN THE (USER CAN
FLAGS SEGMENT SET A
BASE SEGMENT IN
THE
PROGRAM

I – Interrupt :

Three interrupts (Effective address) can be set in for the program


execution.the CPU will continuously make a single step subprogram for
checking IP values .When the IP register has the same value as the
Interrupt’s address ,it will interrupt’s address ,it will enter the Interrupt’s
Subprogram .Enter command “I ” will Interrupt the program.

I key allows interruption to be shown on the screen.

[ M 86 -02 L] . . 7 F F F
>A.D.F.G.I.M.P.T.U.

[ M 86 -02 L] . . 7 F F F
I N T P : 0 0 0 0 .0 0 0 0 . 0 0 0 0

Notes :
1.During interrupt setting ,the address alternation register has commands
like POP ,ES ,MOV DS,AS,etc. to execute with the next command.

Page 36
2.The program will be delayed for due to the fact that CPU has to send
Each command individually into the subprogram.
3.During the interruption the command GO would allow the program to
Execute until the next INTERRUPT.

M-Moving Data :
The command MOVE is used to move data in the memory from a
Specified address to another address by input the starting address ,the
ending address the desire address .A RETURN key is then used to execute
the changes.

SYNTAX :
The ‘M’ key allows the data to be moved to another address:

[ M 86 -02 L] . . 7 F F F
>A.D.F.G.I.M.P.T.U.

ENDING ADDRESS (EFFECTIVE ADDRESS)


STARTING ADDRESS(EFFECTIVE ADDRESS)
SEGMENT BASE
SOURCE

MS 0000 : 0000 8088


T 0000 : 0000

TARGET
SEGMENT BASE
DESTINATION ADDRESS

The ending address must be greater than or equal to the starting


address.The sum of the starting address in plus the corrected ending
address in the target can not exceed FFFF.Other wise it will cause an input
error and have to redo the whole procedure.

Page 37
P-Print :

This command allows the printer to print the output Connect the printer
With input/output system of 8255 (the connection is described at the back )
Before turning on the printer

[ M 86 -02 L] . . 7 F F F
>A.D.F.G.I.M.P.T.U.

By pressing ‘P’ Key will allow the following to show on the screen:

PRESS S/F FOR SPEED

Here S/F indicates “SLOW” or “FAST”.Now according to the


printer,press ‘S’ or ‘F’ key ,then following will be shown the screen

PRINTER ON !
>B . D .U.

Unaasemble
Dump
Buffer

If the printer is not connected at this time ,press key “P” so the LCD
would show
“PRINTER ERROR!” on the second line.
“D” command will allow the printer to print the machine code.
“U” command will allow the printer to print the assembly program.
“B” Command sends data of RAM directly to the printer without going
through any modification.

Page 38
T - Trace Program (an N –step designed command) :

This command is used for program execution.TRACE will enter the


INTERRUPT subprogram every time the program execute.N has a decimal
range from 1-99 with 10 as the rounding off number, and only operate
If N is not 0; otherwise it will clear the function.
SYNTAX :
T 00 - STEP
Decimal TRACE setting
Only 0-9 numerical keys are allowed to use to operate for this command
But not any other keys.

U -Unassemble :
The UNASSEMBLE command decodes the value of a group memory
location mnemonics ,and display on the displayed.Once enter this command
,input the proper design address.The following is the correct way to input
address :

[ M 86 -02 L] . . 7 F F F
>A.D.F.G.I.M.P.T.U.

[ VTS-86/88 ] . . 7 F F F
U 400

OR

U 0 : 400

Starting address

1. The content of the Unassemble 0400 will start if only the starting
address is entered .The built-in segment base is used here if it is not
entered.

Page 39
2. The content of the Unassemble 0000:0400 will start if only the
starting address is entered with segment address as 0000:0400.

Press “U” key would enter the Unassemble design:


Segment Base
Effective Address

Machine code

0000 :0400 B0 30
MOV AL,30

Assembly Language

: PROGRAM TO DISPLAY “GOOD” ON SEVEN


SEGMENT DISPLAY MODULE.

AIM : Write a program to display “GOOD” on seven segment


Display module.

APPARATUS : Microprocessor Trainer Kit 8086 (M86-02)


Seven segment display module (IC-07)

INTRODUCTION:
In most of the Microprocessor based system,certain Input
output devices are required for the man nad machine
communication.The various output devices used are
displays ,printer plotters etc.Seven segment displays are
used quite oftenly to display the information processed by
microprocessor.This Seven Segment Display Module is
based Shift Register Technique.

CIRCUIT DESCRIPTION :

This Seven Segment Disply Module is based on


Shift Register Technique using IC 74164.

Page 40
The data to be displayed is connected with PB0 bit of
8255 .To display 4 digits requires 32 bit data to end
through PB0 bit the required information will be
displayed in the Seven Segment.

HARDWARE INSTALLATION :
1.Connect IC Tester interfacing Module to 8255-I OF
8051/8085/8086 Trainer kit through 26 pin FRC Cable
2.Be sure about the direction of the cable i.e. Pin No.1
Of Module should to Pin No.1 of 8255 connector.
3.Connect +5V ,GND from the Trainer Kit (+5V & GND
Signals are available in the 25 & 26 pin of FRC 8255-I
Connector)

SOFTWARE INSTALLATION:
1.Enter the program from 2000 Location for 8085/8051
Kit/0400 for 8086 Kit/3000 for 8051 LCD kit and make
Sure that your program is entered properly before
Execution.
2.Execute your program from respective Location &
Observe the results.

PROGRAM FOR SEVEN SEGMENT DISPLAY MODULE BASED


ON M86-02 KIT :

0400 B0 80 MOV AL,80H


0402 E6 76 OUT 76H,AL
0404 B9 20 00 L22: MOV CX,0020H
0407 B0 00 L1 : MOV AL,00H
0409 E6 74 OUT 74H,AL
040B B0 FF MOV AL,0FFH
040D E6 72 OUT 72H,AL
040F B0 01 MOV AL,01H
0411 E6 76 OUT 76H,AL
0413 49 DEC CX
0414 75 F1 JNE L1
0416 BE 00 05 L2 : MOV SI,0500H
0419 B1 04 MOV CL,04H
Page 41
041B B3 08 L5: MOV BL,08H
041D 8A 3C MOV BH,[SI]
041F B0 00 L3: MOV AL,00H
0421 E6 74 OUT 74H,AL
0423 88 F8 MOV AL,BH
0425 D0 D0 RCL AL,1
0427 88 C7 MOV BH,AL
0429 D0 D0 RCL AL,1
042B E6 72 OUT 72H,AL
042D B0 01 MOV AL,01H
042F E6 74 OUT 74H,AL
0431 FE CB DEC BL
0433 75 EA JNE L3
0435 B8 00 00 MOV AX,0000H
0438 48 DEC AX
0439 75 FD JNE L4
043B 46 INC SI
043C FE C9 DEC CL
043E 75 DB JNE L5
0440 EB C2 JMP L22

0500 82 C0 C0 A1 DB 82H,0C0H,0C0H,0A1H ;GOOD Display Code

Page 42

You might also like