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

Mp Combined

The document contains a series of assembly programming experiments aimed at various tasks such as displaying flag registers, performing arithmetic operations, sorting numbers, and string manipulation. Each experiment includes code segments with specific aims, such as finding minimum/maximum numbers, performing 16-bit arithmetic, and checking for palindromes. The document showcases practical applications of assembly language programming in a structured format.

Uploaded by

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

Mp Combined

The document contains a series of assembly programming experiments aimed at various tasks such as displaying flag registers, performing arithmetic operations, sorting numbers, and string manipulation. Each experiment includes code segments with specific aims, such as finding minimum/maximum numbers, performing 16-bit arithmetic, and checking for palindromes. The document showcases practical applications of assembly language programming in a structured format.

Uploaded by

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

Experiment-1

Aim: Introduction to assembly programming


Experiment-2
Aim: Assembly program to display the contents of the flag register.
Code:
Data SEGMENT
msg0 db 0dh,0ah,"Vedant_2303032$"
msg DB 0dh,0ah,"-- -- -- -- OF DF IF TF SF ZF -- AF -- PF -- CF $"
newl DB 0dh,0ah,"$"
flag DW ?
Data ENDS

Code SEGMENT
ASSUME CS:Code,DS:Data
start:
mov ax,Data
mov DS,ax
mov dx,OFFSET msg0
mov ah,09h
int 21h

mov dx,offset newl


mov ah,09h
int 21h

mov dx,OFFSET msg


mov ah,09h
int 21h

mov dx,offset newl


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

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

Code ENDS
END start
Experiment-3

Aim: Assembly programming for 8-bit addition, subtraction.


data segment
a db ?
msg0 db “ Vedant_2303032$”
space db 0dh,0ah, “$”
msg db “Enter the 1st No $”
msg1 db “Enter the 2nd No $”
msg2 db “The result of the addition is $”
data ends

code segment
assume cs:code, ds:data
start:
mov ax,data
mov ds,ax

mov dx,OFFSET msg0


mov ah,09h
int 21h

mov dx,OFFSET space


mov ah,09h
int 21h

mov dx, OFFSET msg


mov ah, 09h
int 21h

call input
mov a,bl

mov dx,OFFSET space


mov ah,09h
int 21h

mov dx, OFFSET msg1


mov ah,09h
int 21h

call input
mov dx,OFFSET space
mov ah,09h
int 21h

mov dx,OFFSET msg2

mov ah,09hint 21h

mov cl,00

add bl,a
JNC l3
inc cl

l3: mov dh,bl


mov bl,cl
and bl,0Fh
call convert
mov dl,bl
mov ah,02h
int 21h

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

MOV dx, offset msg0


mov ah,09h
int 21h

MOV dx,offset MSG4


mov ah,09h
int 21h

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$"

msg3 db 0DH,0AH,"Enter the choice: $"

msg db 0DH,0AH,"Enter 1st 16bit num: $"

msg1 db 0DH,0AH,"Enter 2nd 16bit num: $"


msg2 db 0DH,0AH,"Result is: $"

menu1 db 0DH,0AH,"Choices: $"

menu2 db 0DH,0AH,"1.Addition of 16bit $"

menu3 db 0DH,0AH,"2.Subtraction of 16bit $"

menu4 db 0DH,0AH,"3.Exit the program $"

newl db 0Ah,0Dh,"$"

data ends

code segment

assume cs:code,ds:data

start:

mov ax,data

mov ds,ax

mov dx,OFFSET msgnm

mov ah,09h

int 21h
mov dx,OFFSET menu1

mov ah,09h

int 21h

mov dx,OFFSET menu2

mov ah,09h

int 21h

mov dx,OFFSET menu3


mov ah,09h

int 21h

mov dx,OFFSET menu4

mov ah,09h

int 21h

mov dx,OFFSET msg3

mov ah,09h

int 21h

mov ah,01h

int 21h

call ascii2hex

mov choice,al

cmp al,03h
jnz continue
jmp exit

continue:

mov dx,OFFSET msg

mov ah,09h

int 21h

call input
mov num1,bx

mov dx,OFFSET newl

mov ah,09h

int 21h

mov dx,OFFSET msg1

mov ah,09h

int 21h

call input

mov dx,OFFSET newl

mov ah,09h

int 21h

mov dx,OFFSET msg2


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

msg1 DB 0Ah , 0Dh , "Vedant_2303032$"

msg2 DB 0Ah , 0Dh , "Enter string : $"

msg3 DB 0Ah , 0Dh , "result: $"

msg4 DB 0Ah , 0Dh , "palindrome $"

msg5 DB 0Ah , 0Dh , "Not a palindrome $"

TEMP DB ?

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE , DS: DATA

START:

MOV AX , DATA

MOV DS , AX

MOV DX , OFFSET msg1

MOV AH , 09H

INT 21H

MOV DX , OFFSET msg2


MOV AH , 09H

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 DX , OFFSET msg3

MOV AH , 09H

INT 21H

UP2:

MOV DL , [SI]

MOV AH , 02H

INT 21H

INC SI

DEC CL

CMP CL , 00H
JNZ UP2

MOV DX , OFFSET msg3

MOV AH , 09H

INT 21H

MOV CL , TEMP

MOV AL , CL

ADD AL , 30H

MOV DL , AL

MOV AH , 02H

INT 21H

MOV DX , OFFSET msg3

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 CL, TEMP

MOV CH, 00H

MOV SI , 1000h

MOV DI , 2000h

ADD DI , CX
DEC DI

MOV DX , OFFSET msg3

MOV AH , 09H

INT 21h

UP4:

MOV AL, [SI]

MOV BL, [DI]

CMP AL, BL

JNZ UP5

INC SI

DEC DI

DEC CL

CMP CL,00h

JNZ UP4

MOV DX , OFFSET msg4

MOV AH , 09H
INT 21H

JMP END

UP5:

MOV DX , OFFSET msg5

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")

printf("\nEnter number 1: ");


scanf("%d",&a);

printf("\nEnter number 2: ");

scanf("%d",&b);

asm MOV AX, a;

asm MOV BX, b;

UP1:

asm SUB BX, AX;

UP2:

asm SUB AX, BX;

asm CMP AX, BX;

asm JZ DOWN;

asm JC UP1;

asm JNC UP2;

DOWN:

asm MOV gcd, AX;

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

You might also like