MP-lab Mannual FH24
MP-lab Mannual FH24
Microprocessor
Semester-IV
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)
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.)
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
;output to user
mov ah,0ah
mov dx,SI
int 21h
;display str
mov ah,09h
lea dx,s2
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
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
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
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
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.
Software: TASM
Program:
.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.
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
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
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
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
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
.CODE
MAIN PROC
MOV DS, AX
LOOP1:
INT 21H
FACT PROC
CMP BX, 01
JZ LOOP2
PUSH BX
DEC BX
POP BX
MUL BX
LOOP2:
Software: TASM
Program:
title MACRO
.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 :
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:
PERMANENT
MAGNET
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
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.
Port B - 72H
Port C - 74H