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

MP-lab Mannual FH24

This document contains 5 experiments on assembly language programming for the 8086 microprocessor. The experiments cover basic arithmetic operations, string instructions, sorting arrays, cursor manipulation, and finding minimum/maximum values in an array. Programs are provided with the aim, apparatus, theory, and output for each experiment.

Uploaded by

Shivanee Shukla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

MP-lab Mannual FH24

This document contains 5 experiments on assembly language programming for the 8086 microprocessor. The experiments cover basic arithmetic operations, string instructions, sorting arrays, cursor manipulation, and finding minimum/maximum values in an array. Programs are provided with the aim, apparatus, theory, and output for each experiment.

Uploaded by

Shivanee Shukla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

LAB MANUAL

Microprocessor

Semester-IV

Computer Engineering Department

Fr. C. Rodrigues Institute of Technology, Vashi


EXPERIMENT NO-1
Aim : Write ALP for 8086 to Perform basic arithmetic operations on 8bit/16 bit
data

Apparatus : PC with basic configuration loaded with Windows OS

Software: TASM

Theory:

Program:

ADDITION
.model small
.data
a db 08h SUBTRACTION
b db 02h .model small
c db 00h .data
.code a db 07h
start: b db 03h
mov ax, @data c db 00h
mov ds, ax .code
mov bh, a start:
mov ch, b mov ax, @data
add bh, ch mov ds, ax
Mov c, bh mov bh, a
mov ah ,4ch mov ch, b
int 21h sub bh, ch
End start Mov c, bh
mov ah ,4ch
int 21h
OUTPUT: End start

OUTPUT:
MULTIPLICATION DIVISION
MULTIPLICATION .model small
.model small .data
.data a dw 07h
a db 02h b db 02h
b db 03h c db 00h
c db 00h d db 00h
.code .code
start: start:
mov ax, @data mov ax,@data
mov ds, ax mov ds, ax
mov bh, a mov ax, a
mov ch, b div b
mov AL, bh mov c,al
MUL ch mov d,ah
Mov c, AL mov ah,4ch
mov ah ,4ch int 21h
int 21h End start
End start

OUTPUT:
OUTPUT:
EXPERIMENT NO-2
Aim : Assembly program based on string instructions (overlapping/non-
overlapping block Transfer/String Length)

Apparatus : PC with basic configuration loaded with Windows OS

Software: TASM

Program:

Block Transfer(Assume two arrays of 400 bytes, Array-1 stored in data segment from
2000H onwards and Array-2 stored in extra segment from 3000H onwards.)

code segment .model small


assume cs:code .code
mov ax,2000h start:mov ax,2000h
mov ds,ax mov ds,ax
mov ax,3000h
mov es,ax mov ax,3000h
mov si,0000h mov es,ax
mov di,0000h OR mov si,0000h
mov cx,0400h mov di,0000h
cld mov cx,0400h
rep movsb cld
int 3h rep movsb
code ends int 3h
end mov ah,4ch
int 21h
end start

OUTPUT:
STRING LENGTH

Program 1

.model small
.data
s1 db "Enter Input :$"
s2 db "Your input is:$"
s3 db 10,13,"$"
s4 db 20 dup ("$")
s5 db "Length is $"
.code
start:
mov ax,@data
mov ds,ax
LEA SI,s4

;print what is typed


mov ah,09h
lea dx,s1
int 21h

;output to user
mov ah,0ah
mov dx,SI
int 21h

;blank line func


mov ah,09h
lea dx,s3
int 21h

;display str
mov ah,09h
lea dx,s2
int 21h

;from 1stloc to print(s4+2 bcoz when store at 1st it calcs locns)


mov ah,09h
LEA dx,s4+2
int 21h

mov ah,09h
lea dx,s3
int 21h

;displ length
mov ah,09h
LEA dx,s5
int 21h

;s4 data to bl
;30h is added to bl
mov bl,s4+1
add bl,30h

;disp cont of rgst


;disp cont of only dl rgst
mov ah,02h
mov dl,bl
int 21h

mov ah,4ch
int 21h
end start

OUTPUT:

Program 2:

.MODEL SMALL
.STACK 100H
.DATA
STR1 DB "Atharva$"
s3 db 10,13,"$"
LEN DB 0
.CODE
MOV AX , @DATA ; Initializing Data Segment
MOV DS , AX

MOV SI , OFFSET STR1


;display str
mov ah,09h
lea dx,str1
int 21h

;blank line func


mov ah,09h
lea dx,s3
int 21h

UP:
MOV AL , [SI]
CMP AL , '$'
JZ DN ; IF DESTINATION == SOURCE THEN ZF = 1

INC LEN
INC SI
LOOP UP

DN:
; Printing length
MOV DL , LEN
ADD DL , 48
MOV AH , 2
INT 21H

MOV AH , 4CH ; Service Routine for Exit


INT 21H

END

REVERSE OF STRING

.model small
.data
s1 db "Enter your string:$"
s2 db "Your input is:$"
s3 db 10,13,"$"
s4 db 20 dup("$")
s5 db "Reverse of the String is:$"
.code
start: mov ax,@data
mov ds,ax
LEA SI,s4
mov ah,09h
lea dx,s1
int 21h
mov ah,0Ah
mov dx,SI
int 21h
mov ah,09h
lea dx,s3
int 21h
mov ah,09h
lea dx,s2
int 21h
mov ah,09h
lea dx,s4+2
int 21h
mov ah,09h
lea dx,s3
int 21h
mov ah,09h
lea dx,s5
int 21h
mov cl,s4+1
add SI,cx
back: mov dl,[SI+1]
mov ah,02h
int 21h
dec SI
loop back
mov ah,4ch
int 21h
end start
OUTPUT:
EXPERIMENT NO-3
Aim : Write ALP for 8086 to find ascending and descending of numbers

Apparatus : PC with basic configuration loaded with Windows OS

Software: TASM

Program:

ASCENDING
.model small
.data
arr db 03h,05h,08h,01h,04h,02h
.code
start: mov ax,@data
mov ds,ax
mov cl,06h
l3: LEA si,arr
mov dl,05h
l2: mov ah,[si]
cmp ah,[si+1]
jc l1
mov dh,[si+1]
mov [si+1],ah
mov [si],dh
l1: inc si
dec dl
jnz l2
dec cl
jnz l3
mov ah,4ch
int 21h
end start
DESCENDING
.model small
.data
arr db 03h,05h,08h,01h,04h,02h
.code
start: mov ax,@data
mov ds,ax
mov cl,06h
l3: LEA si,arr
mov dl,05h
l2: mov ah,[si]
cmp ah,[si+1]
jnc l1
mov dh,[si+1]
mov [si+1],ah
mov [si],dh
l1: inc si
dec dl
jnz l2
dec cl
jnz l3
mov ah,4ch
int 21h
end start
EXPERIMENT NO-4
Aim :Language program to increment, decrement the size of the cursor and also to
disable it.

Apparatus : PC with basic configuration loaded with Windows OS

Software: TASM

Program:

INCREASING/DECREASING SIZE OF CURSOR

.model small
.data
.code
start: mov ah,01h
mov cx,1015h/001h
int 10h
mov ah,4ch
int 21h
end start

OUTPUT:
EXPERIMENT NO-5
Aim : Assembly program to find minimum/ maximum no. from a given array.

Apparatus : PC with basic configuration loaded with Windows OS

Software: TASM

Program:
MINIMUM NUMBER mov al, [SI]
cmp al, bl
data segment jge nxt
STRING1 DB 08h,14h,05h,0Fh,09h mov bl, al
res db ? nxt:
data ends inc si
dec cx
jnz up
code segment
assume cs:code, ds:data
start: mov ax, data mov res,bl
mov ds, ax int 3
mov cx, 04h code ends
end start
mov bl, 79h
LEA SI, STRING1
up:

Output

AX=0B0F BX=0005 CX=0000 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000


DS=0B37 ES=0B27 SS=0B37 CS=0B38 IP=001E NV UP EI PL ZR NA PE NC
0B38:001E CC INT 3
-d 0b37:0000
0B37:0000 08 14 05 0F 09 05 00 00-00 00 00 00 00 00 00 00 ................
0B37:0010 B8 37 0B 8E D8 B9 04 00-B3 79 8D 36 00 00 8A 04 .7.......y.6....
0B37:0020 3A C3 7D 02 8A D8 46 49-75 F4 88 1E 05 00 CC FC :.}...FIu.......
0B37:0030 FE C4 9E FA FE 26 8A 47-0C 2A E4 40 50 8B C3 05 .....&.G.*.@P...
0B37:0040 0C 00 52 50 E8 19 46 83-C4 04 50 8D 86 00 FF 50 ..RP..F...P....P
0B37:0050 E8 6F 70 83 C4 06 B8 CD-05 50 8D 86 00 FF 50 E8 .op......P....P.
0B37:0060 CA 0C 83 C4 04 B8 FF FF-50 8D 86 00 FF 50 8D 46 ........P....P.F
0B37:0070 80 50 E8 4D FA 83 C4 06-0A C0 75 03 E9 7B FF 5E .P.M......u..{.^
-q
Maximum
data segment
STRING1 DB 08h,14h,05h,0Fh,09h
res db ?
data ends

code segment
assume cs:code, ds:data
start: mov ax, data
mov ds, ax
mov cx, 04h
mov bl, 00h
LEA SI, STRING1
up:
mov al, [SI]
cmp al, bl
jl nxt
mov bl, al
nxt:
inc si
dec cx
jnz up
mov res,bl
int 3
code ends
end start

AX=0B0F BX=0014 CX=0000 DX=0000 SP=0000 BP=0000 SI=0004 DI=0000


DS=0B37 ES=0B27 SS=0B37 CS=0B38 IP=001E NV UP EI PL ZR NA PE CY
0B38:001E CC INT 3
-d 0b37:0000
0B37:0000 08 14 05 0F 09 14 00 00-00 00 00 00 00 00 00 00 ................
0B37:0010 B8 37 0B 8E D8 B9 04 00-B3 00 8D 36 00 00 8A 04 .7.........6....
0B37:0020 3A C3 7C 02 8A D8 46 49-75 F4 88 1E 05 00 CC FC :.|...FIu.......
0B37:0030 FE C4 9E FA FE 26 8A 47-0C 2A E4 40 50 8B C3 05 .....&.G.*.@P...
0B37:0040 0C 00 52 50 E8 19 46 83-C4 04 50 8D 86 00 FF 50 ..RP..F...P....P
0B37:0050 E8 6F 70 83 C4 06 B8 CD-05 50 8D 86 00 FF 50 E8 .op......P....P.
0B37:0060 CA 0C 83 C4 04 B8 FF FF-50 8D 86 00 FF 50 8D 46 ........P....P.F
0B37:0070 80 50 E8 4D FA 83 C4 06-0A C0 75 03 E9 7B FF 5E .P.M......u..{.^

EXPERIMENT NO-6
Aim : Assembly program to display the contents of the flag register.
Apparatus : PC with basic configuration loaded with Windows OS

Software: TASM
.model small
.data

msg db 0dh,0ah,"-- -- -- -- OF DF IF TF SF ZF -- AF -- PF -- CF $"


newl db 0dh,0ah,"$"
flag dw ?
.code
start: mov ax,@data
mov ds,ax

mov dx,offset msg


mov ah,09h
int 21h

mov dx,offset newl


mov ah,09h
int 21h

cli
stc
std

pushf

pop bx

mov flag,bx

mov cx,16
mov bx,8000h

loops:
mov ax,flag
and ax,bx
jz zero
mov dl,31h
mov ah,02h
int 21h
jmp space

zero: mov dl,30h


mov ah,02h
int 21h

space: mov dl,' '


mov ah,02h
int 21h

mov ah,02h
int 21h
ror bx,1
loop loops

mov ah,4ch
int 21h
end start
Output:

EXPERIMENT NO-7
Aim : Assembly program to find factorial of a given number using recursive procedure
Apparatus : PC with basic configuration loaded with Windows OS
Software: TASM

Program:
.MODEL SMALL

.DATA

NUM DW 8

RESULT DW (?) ; INITIALIZE MEMORY FOR THE RESULT

.CODE

MAIN PROC

MOV AX, @DATA ; INITIALIZE DATA SEGMENT

MOV DS, AX

MOV AX, 01 ; INITIALIZE RESULT AS 01 IF THE NUMBER IS 0

MOV CX, NUM ; INITIALIZE NUMBER

CMP CX, 00 ; CHECK WHETHER NUMBER IS 0

JE LOOP1 ; YES, TERMINATE PROGRAM


MOV BX, CX ; SAVE THE NUMBER IN BX

CALL FACT ; CALL FACTORIAL PROCEDURE

LOOP1:

MOV RESULT, AX ; SAVE FACTORIAL RESULT

MOV AH, 4CH

INT 21H

MAIN ENDP ; END MAIN PROCEDURE

FACT PROC

CMP BX, 01

JZ LOOP2

PUSH BX

DEC BX

CALL FACT ; CALL FACTORIAL PROCEDURE

POP BX

MUL BX

RET ; RETURN CALLED PROGRAM

LOOP2:

MOV AX, 01 ; INITIALIZE AX REGISTER TO 01

RET ; RETURN CALLED PROGRAM

FACT ENDP ; END FACTORIAL PROCEDURE

END ; END PROGRAM


EXPERIMENT NO-8
Aim : Assembly program using macro
Apparatus : PC with basic configuration loaded with Windows OS

Software: TASM

Program:
title MACRO

deep macro msg


lea dx,msg
mov ah,9
int 21h
endm

.model small

.stack 100h

.data
msg1 db 10,"I$"
msg2 db 10,"am $"
msg3 db 10,"Agnellite.$"
.code
start:
mov ax,@data
mov ds,ax
deep msg1
deep msg2
deep msg3
;mov ax,4c00h
;int 21h
;exit
end start
end

output:
I
am
Agnellite.

EXPERIMENT NO-9
Aim : Write Mixed Language program
Apparatus : PC with basic configuration loaded with Windows OS
Software: TASM

Program:
Write Mixed Language program
#include<iostream.h>
void main()
{
int a,b,c;
cout<<"\n\nEnter two numbers: ";
cin>>a>>b;
asm{
mov ax, a;
mov bx, b;
add ax, bx;
mov c, ax;
}
cout<<"The sum is: \n"<<c;
}
Or

#include <iostream.h>
#include <conio.h>
void main(){
clrscr();

int a = 4, b = 3, c;

asm {
mov ax,a
mov bx,b
add ax,bx
mov c,ax
}

cout<<"Result="<<c;
getch();
}

Or
Calculator using mixed program

#include <iostream.h>
#include <conio.h>
void main(){
clrscr();
int a,b,result;
int ch;
cout<<"Enter two numbers:";
cin>>a>>b;
cout<<"1.Add /n 2.Sub /n 3.Mul /n 4.Div"<<endl;
cin>>ch;
switch(ch){
case 1:{
asm mov ax,a;
asm mov bx,b;
asm add ax,bx;
asm mov result,ax;
cout<<"Result:"<<result;
break;
}
case 2:{
asm mov ax,a;
asm mov bx,b;
asm sub ax,bx;
asm mov result,ax;
cout<<"Result:"<<result;
break;
}
case 3:{
asm mov ax,a;
asm mov bx,b;
asm mul bx;
asm mov result,ax;
cout<<"Result:"<<result;
break;
}
case 4:{
asm mov ax,a;
asm mov bx,b;
asm div bx;
asm mov result,ax;
cout<<"Result:"<<result;
break;
}
}
getch();
}
EXPERIMENT NO-10
Aim : Hardware Interfacing Program

Apparatus :

 8051 microcontroller kit


 Keyboard
 50 core cable
 DC motor interface board
 DC motor
 Power chord

Theory:
There are many systems to monitor various processes and give out control signals
in the from of digits but there is only one device to convert these digital pulses into
presise incremental motion and that device is stepping motor. Stepper motor is a
device which converts digital pulses into precise angular of linear steps of desired
value. Stepper Motor has two phase Bifilar form with having a Step Angle of
1.8°. Stepper Motor module can hold Motor in infinitely static condition. It can
control speed upto 0-3,000 RPM i.e. 0 to 10,000 Step per second. It can be
program in three parameters like Speed, Direction & Number of steps. The speed
of motor is generated by freqnency of switching not the supply voltage. A pulse
input to two phase clock will move the shaft of motor by one step for every
pulse. Thus number of steps can be moved and can be precisely controlled. If
there is no pulse the motor will remain lock up in the protion in which the last step
was taken. Since at any time of two winding always energized which lock
the motor electromagnetically.
STEPPER MOTOR
Stepping Motors differ from conventional Servo Motors in following respect:

1 There is no control winding in stepping motors. Both windings are Identical.

2 The stepping rate (speed of rotation) is governed by frequency of switching


and not supply voltage.

PERMANENT
MAGNET

BLK & WHIT

PA1

PA0
PA3 PA2

Q1 Q3
3 A pulse input two phase clock (instead of continuous pulses) will move the shaft of motor by
one step for every pulse, thus number of steps be moved can be precisely controlled.
When there is no pulse input, the rotor will remain locked up in the portion in which the last step
was taken since at any time two windings always energized which lock the rotor
electromagnetically.
4 Stepping motors can be programmed in three parameters namely:
a) Direction,
b) Speed and
c) Number of Steps

WORKING OF STEPPING MOTOR


The stepping action is caused by sequential switching of supply to the two phases of the motor as
described in switching diagram. All stepping motors are of bifilar type with six leads. Watch of the
two Phases of motor has double winding with a centre tap switching the supply from one side to
another of a phase causes reversal of magnetic polar without actually reversing the polarity of
supply. For step input sequence gives 1.8° (full) after and eight step input sequence give 0.9° (half)
step function.

Switching Sequence
CCW ROTATION

The above switching Sequence/Logic will move shaft in one direction. To change direction of
rotation read the sequence upward.
The specified torque of any stepping motor is the torque at stand still (holding torque). This torque
is directly portional to the current in the winding. The current in winding is governed by the D.C.
resistance of winding. As the switching sequence starts the inductive reactance of the winding
which increases with the frequency of switching opposes the rise of current to desired level within
the time given for one step depending upon the speed of stepping. This is mainly due to L/R time
constant of winding. The drop in current level causes drop in torque as the speed increases. In
order to improve torque at high speeds it is necessary to maintain current at the desired level. This
can be done by one of the following methods:
1. By increasing supply voltage and introducing current limiting resistances in each phase. Introduction
of resistances improves the time constant of winding. Seven to nine time the winding resistance
in each phase will give very good improvement in torque/speed Characteristics.
2. By using a constant current source with or without a chopper instead of
using a constant voltage source which will give even better performance.
STARTING AND STOPPING UNDER LOAD
There is a limit for every type of stepping motor as regards the speed at which it will start and
stop without loosing step. The limit is due to load torque as well as load intertie. To overcome this
acceleration and declaration techniques have to be employed. Accelera- tion means stepping rate on
switching should be very low and should increase to desired level gradually depending on inertia to
be encountered. Acceleration/deceleration may be as high as 1000 to 3000 steps/sec.
CIRCUIT DESCRIPTION
The four winding of the motor is connected with PA0 to PA3 through buffer and driving circuit. So,
the Port A of 8255 will has to initializes in output mode.
HARDWARE INSTALLATION
🢧 Connect Stepper Motor Controller Module to 8255-I of 8051/8085/8086 Trainer Kit through 26
pin FRC Cable.
🢧 Be sure about the direction of the cable i.e. Pin No. 1 of Module should be connected to Pin NO.
1 of 8255 connector.
🢧 Connect +5V, GND from the Trainer Kit (+5V & GND signals are available in the 25 & 26
pin of FRC 8255-I Connector)
🢧 Connect Motor Supply to +12V from the Trainer Kit
SOFTWARE INSTALLATION
1 Enter the program from Location 0400 8086 Kit make sure that your program is entered properly before
execution.
2 Execute your program from respective Location & observe the results.

PROGRAM FOR 8086 LCD TRAINER KIT


8255 Port Address
Port A - 70H

Port B - 72H

Port C - 74H

Control Word - 76H

Program-1 for Two Phase Full Step Operation


This program will move the motor in Anti-Clock wise direction. For Clock wise direction change F9, F5, F6,
FA in place of FA,F6,F5,F9.
Address Opcodes Mnemonics Comments
0400 B0 80 MOV AL,80H ;INIT 8255 CWR
0402 E6 76 OUT 76H,AL ;SET ALL PORTS AS
OUTPUT
0404 B0 FA START: MOV AL,FAH ;SET PA1 & PA3 COIL
HIGH
0406 E6 70 OUT 70H,AL ;OUT AT PORT-A
0408 E8 17 00 CALL DELAY1 ;CALL DELAY ROUTINE
040B B0 F6 MOV AL,F6H ;SET PA1 & PA2 COIL
HIGH
040D E6 70 OUT 70H,AL ;OUT AT PORT-A
040F E8 10 00 CALL DELAY1 ;CALL DELAY ROUTINE
0412 B0 F5 MOV AL,F5H ;SET PA0 & PA2 COIL
HIGH
0414 E6 70 OUT 70H,AL ;OUT AT PORT-A
0416 E8 09 00 CALL DELAY1 ;CALL DELAY ROUTINE
0419 B0 F9 MOV AL,F9H ;SET PA0 & PA3 COIL
HIGH
041B E6 70 OUT 70H,AL ;OUT AT PORT-A
041D E8 02 00 CALL DELAY1 ;CALL DELAY ROUTINE
0420 EB E2 JMP START
0423 B9 00 00 DELAY1: MOV CX,0000H ;DELAY ROUTINE
0426 49 LP1: DEC CX
0427 75 FD JNZ LP1
0429 C3 RET

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy