Mp Combined
Mp Combined
Code SEGMENT
ASSUME CS:Code,DS:Data
start:
mov ax,Data
mov DS,ax
mov dx,OFFSET msg0
mov ah,09h
int 21h
pushf
pop bx
mov flag,bx
mov cx,10h
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
Code ENDS
END start
Experiment-3
code segment
assume cs:code, ds:data
start:
mov ax,data
mov ds,ax
call input
mov a,bl
call input
mov dx,OFFSET space
mov ah,09h
int 21h
mov cl,00
add bl,a
JNC l3
inc cl
mov bl,dh
and bl,0F0h
ror bl,04h
call convert
mov dl,bl
mov ah,02h
int 21h
mov bl,dh
and bl,0Fh
call convert
mov dl,bl
mov ah,02h
int 21h
mov ah,4ch
int 21h
input proc
mov ah,01h
int 21h
call ascii2hex
mov bl,al
rol bl,4
mov ah,01h
int 21h
call ascii2hex
add bl,al
ret
endp
ascii2hex proc
cmp al,41h
jc num
sub al, 07h
num: sub al,30h
ret
endp
convert proc
cmp bl,0Ah
jc l1
add bl,37h
jmp l2
l1: add bl, 30h
l2: ret
endp
code ends
end start
Output:
Experiment-4
Aim: Assembly program to sort numbers in ascending/ descending order.
Code:
DATA SEGMENT
msg0 db 0ah,0dh," Vedant_2303032$"
MSG1 DB 10,13,"ARRAY LIMIT IS 10: $"
MSG2 DB 10,13,"ENTER THE NUMBER: $"
MSG3 DB 10,13,"THE SORTED ARRAY IS: $"
MSG4 DB 10,13,"$"
COUNT DB ?
TEMP DB ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,09H
INT 21H
MOV SI,4000H
MOV CX,10
LABEL1:
LEA DX,MSG2
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
CALL INPUT
ROL AL,04H
MOV BL,AL
MOV AH,01H
INT 21H
CALL INPUT
MOV AH,00H
ADD BL,AL
MOV [SI],BL
INC SI
LEA DX,MSG4
MOV AH,09H
INT 21H
LOOP LABEL1
MOV CX,9
mov bx,0000h
LABEL2:
MOV SI,4000H
MOV BL,[SI]
INC SI
MOV BH,9
LABEL3:
DEC BH
CMP BL,[SI]
JC LABEL4
MOV DL,BL
MOV BL,[SI]
DEC SI
MOV [SI],BL
INC SI
MOV [SI],DL
LABEL4:
MOV BL,[SI]
INC SI
CMP BH,00H
JNZ LABEL3
LOOP LABEL2
MOV SI,4000H
MOV CX,10
d:
LEA DX,MSG3
MOV AH,09H
INT 21H
MOV BL,00H
MOV BL,[SI]
AND BL,0F0H
ROR BL,04H
CALL OUTPUT
MOV BL,[SI]
AND BL,0FH
CALL OUTPUT
INC SI
LOOP d
MOV AH,4CH
INT 21H
INPUT PROC
CMP AL,41H
JC LABEL6
SUB AL,07H
LABEL6:
SUB AL,30H
RET
ENDP
OUTPUT PROC
CMP BL,0AH
JC LABEL7
ADD BL,07H
LABEL7:
ADD BL,30H
MOV DL,BL
MOV AH,02H
INT 21H
RET
ENDP
CODE ENDS
END START
Experiment –5
Aim: Assembly program to find minimum/ maximum no. from a given array.
Code:
data segment
array db 3,9,7,8,1,0
msg db 0ah,0dh, "Vedant_2303032$"
msg1 db 0ah,0dh,"Max Number is :"
msg2 db 0ah,0dh,"Min Number is :"
space db 0ah,0dh,"$"
min db ?
max db ?
data ends
code segment
assume cs:code, ds:data
start:
mov ax,data
mov ds,ax
LEA dx,msg
mov ah,09h
int 21h
LEA dx,space
mov ah,09h
int 21h
LEA dx,msg1
mov ah,09h
int 21h
LEA SI,array
mov al,[SI]
mov min,al
mov max,al
mov cl,05
up: inc SI
mov al,[SI]
cmp min,al
JC lmax
mov min,al
lmax:
cmp max,al
JNC label1
mov max,al
label1: dec cl
JNZ up
mov bl,max
call convert
LEA dx,space
mov ah,09h
int 21h
LEA dx,msg2
mov ah,09h
int 21h
mov bl,min
call convert
mov ah,4ch
int 21h
convert proc
mov al,bl
and al,0F0h
ror al,04h
cmp al,0Ah
jc l1
add al,37h
jmp l2
l1: add al, 30h
l2: mov dl,al
mov ah,02h
int 21h
mov al,bl
and al,0Fh
cmp al,0Ah
jc l3
add al,37h
jmp l4
l3: add al, 30h
l4: mov dl,al
mov ah,02h
int 21h
ret
endp
code ends
end start
Output:
Experiment-6
Aim: Assembly programming for 16-bit addition, subtraction, multiplication and division
Code:
data segment
num1 dw ?
res dw ?
choice db ?
msgnm db 0DH,0AH,"Vedant_2303032$"
newl db 0Ah,0Dh,"$"
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ah,09h
int 21h
mov dx,OFFSET menu1
mov ah,09h
int 21h
mov ah,09h
int 21h
int 21h
mov ah,09h
int 21h
mov ah,09h
int 21h
mov ah,01h
int 21h
call ascii2hex
mov choice,al
cmp al,03h
jnz continue
jmp exit
continue:
mov ah,09h
int 21h
call input
mov num1,bx
mov ah,09h
int 21h
mov ah,09h
int 21h
call input
mov ah,09h
int 21h
mov al,choice
cmp al,01h
jnz subt
add bx,num1
jmp def
subt:
sub num1,bx
mov bx,num1
def:
mov res,bx
i3:
mov bx,res
and bx,0F000h
ror bx,12
call convert
mov dl,bl
mov ah,02h
int 21h
mov bx,res
and bx,0F00h
ror bx,8
call convert
mov dl,bl
mov ah,02h
int 21h
mov bx,res
and bx,00F0h
ror bx,4
call convert
mov dl,bl
mov ah,02h
int 21h
mov bx,res
and bx,000Fh
call convert
mov dl,bl
mov ah,02h
int 21h
exit:
mov ah,4Ch
int 21h
input proc
mov ah,01h
int 21h
call ascii2hex
mov bl,al
mov bh,00h
rol bx,12
mov ah,01h
int 21h
call ascii2hex
mov ah,00h
rol ax,8
add bx,ax
mov ah,01h
int 21h
call ascii2hex
mov ah,00h
rol ax,4
add bx,ax
mov ah,01h
int 21h
call ascii2hex
mov ah,00h
add bx,ax
ret
endp
ascii2hex proc
cmp al,41H
jc num
sub al,07h
num:
sub al,30h
ret
endp
convert proc
cmp bl,0ah
jc i1
add bl,37h
jmp i2
i1:
add bl,30h
i2:
ret
endp
code ends
end start
Output:
Experiment-7
Aim: Assembly program to accept a string, display a string, print a string, find the length
of a string, check if given string is a palindrome.(menu based)
Code:
DATA SEGMENT
TEMP DB ?
DATA ENDS
CODE SEGMENT
START:
MOV AX , DATA
MOV DS , AX
MOV AH , 09H
INT 21H
INT 21H
MOV SI , 1000h
MOV DI , 2000h
MOV CL , 00h
UP1:
MOV AH , 01H
INT 21H
MOV [SI] , AL
MOV [DI] , AL
INC SI
INC DI
INC CL
CMP AL , 0DH
JNZ UP1
DEC CL
mov TEMP , CL
MOV SI , 1000H
MOV AH , 09H
INT 21H
UP2:
MOV DL , [SI]
MOV AH , 02H
INT 21H
INC SI
DEC CL
CMP CL , 00H
JNZ UP2
MOV AH , 09H
INT 21H
MOV CL , TEMP
MOV AL , CL
ADD AL , 30H
MOV DL , AL
MOV AH , 02H
INT 21H
MOV AH , 09H
INT 21H
MOV CL , TEMP
MOV SI , 1000H
MOV CH , 00H
ADD SI , CX
DEC SI
UP3:
MOV DL , [SI]
MOV AH , 02H
INT 21H
DEC SI
DEC CL
CMP CL , 00H
JNZ UP3
MOV SI , 1000h
MOV DI , 2000h
ADD DI , CX
DEC DI
MOV AH , 09H
INT 21h
UP4:
CMP AL, BL
JNZ UP5
INC SI
DEC DI
DEC CL
CMP CL,00h
JNZ UP4
MOV AH , 09H
INT 21H
JMP END
UP5:
MOV AH , 09H
INT 21H
END:
MOV AH , 4CH
INT 21H
CODE ENDS
END START
Output:
Experiment – 8
Aim: Mixed Language program to find the GCD/LCM of two numbers.
Code:
#include<stdio.h>
#include<conio.h
void main()
int a,b,gcd;
clrscr();
printf("Vedant_2303032")
scanf("%d",&b);
UP1:
UP2:
asm JZ DOWN;
asm JC UP1;
DOWN:
printf("\nGCD: %d ",gcd);
getch();
}
Experiment-9
Aim: Mixed Language program to increment, decrement the size of the cursor and also
to disable it.
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
char count='4';
int temp=1;
int choice;
clrscr();
do {
printf("\n\nVedant_2303032");
printf("\n---- MENU ----");
printf("\n1. INCREMENT");
printf("\n2. DECREMENT");
printf("\n3. DISABLE");
printf("\n4. EXIT");
printf("\nEnter your choice: ");
scanf("%d",&choice);
switch(choice)
{
case 1:
l1:
if(count >= '4')
asm JMP msg;
asm INC count;
asm MOV CL, count;
asm MOV CH, 00H;
asm MOV AH, 01H;
asm INT 10H;
asm JMP l1;
msg:
printf("\nReached maximum limit!");
break;
case 2:
l2:
if(count <= '0')
asm JMP msg1;
asm DEC count;
temp++;
asm MOV CL, count;
asm MOV CH, 00H;
asm MOV AH, 01H;
asm INT 10H;
asm JMP l2;
msg1:
printf("\nReached minimum limit!");
break;
case 3:
asm MOV CH, 20H;
asm MOV AH, 01H;
asm INT 10H;
break;
case 4:
printf("\nEXITING....");
break;
default:
printf("\nINVALID CHOICE!!");
break;
}
}while(choice!=4);
getch();
}
Experiment-10
Aim: Assembly program to rotate a stepper motor in the clockwise direction using 8086
MP and 8255