0% found this document useful (0 votes)
10 views28 pages

Mpilab 17

Mpi lab file
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 views28 pages

Mpilab 17

Mpi lab file
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/ 28

S.no Name of Program Date Page No.

1. Write a Program to Print Character from A to Z. 1

2. Write a Program to Print 0 to 9. 2

Write a Program to Add two Number by taking


3. 3
input.

4. Write a Program to subtract two numbers. 4

5. Write a Program to find square of a number. 5

Write a Program to Take a input character and print


6. 6
it.

7. Write a Program to Print Strings in New Line. 6-7

Write a Program to convert a letter from lower to


8. 8-9
upper case .

9. Write a Program to reverse a string. 9-10

10. Write a Program to find factorial of a number. 11

Write a Program to determine a string is palindrome


11. 12-14
or not ..
Write a Program to display ASCII character in rows
12. 15-16
and columns for a given range .
Write a Program to store array and find the largest
13. 17-18
element in array.

14. Write a Program to print a string using iteration . 19-20

15. Write a Program to print whole string in one go. 20-21

16. Write a Program to concatenate two string. 21-23

Write a Program to find the sum of two number


17. 24-25
without using arithmetic operation.

18. Write a Program to Print Character from a to z. 26

19.

20.

0
Program 1. Write a Program to Print character A to Z
Code:
.model small
.stack 100h
.data
.code
main proc
mov cx , 26
mov dx , 65
l1:
mov ah , 2
int 21h
add dx , 1
loop l1
mov ah , 4ch
int 21h
main endp
end main

Output:

1
Program 2. Write a Program to Print 0 to 9
Code:
.model small
.stack 100h

.code
main proc

mov cx , 10
mov dx , 48

l1:
mov ah , 2
int 21h
add dx , 1
loop l1

mov ah , 4ch
int 21h
main endp
end main
Output:

2
Program 3. Write a Program to Add two Number by taking input
Code:
.model small
.stack 100h
.code
main proc
mov ah , 1
int 21h
mov bl , al
mov ah ,1
int 21h
mov cl , al
add bl , cl
sub bl , 48
mov dl , bl
mov ah , 2
int 21h

main endp
end main

Output:

3
Program 4. Write a Program to Subtract 2 Number in assembly language
Code:
.model small
.stack 100h
.data
.code
main proc
mov bl , 10
mov cl, 2
sub bl , cl
add bl , 48
mov dl , bl
mov ah , 2
int 21h
mov ah , 4ch
int 21h

main endp
end main

Output:

4
Program 5. Write a Program to find square of a number.Code:
.model small
.stack 100h
.data
a db 03h
assume CS:abc
abc segment

start:
mov ax , @data
mov ds , ax

mov al , a
mul al
add al , 30h

mov dl, al
mov ah , 02h
int 21h
mov ax , 4c00h
int 21h
abc ends
end start
end

Output:

5
Program 6. Write a Program to Take a Input Character and Print it
Code:
.model small
.stack 100h
.data
.code
main proc
mov ah , 1
int 21h
mov dl , al
mov ah , 2
int 21h
main endp
end main

Output:

Program 7. Write a Program to Print string in New Line


Code:
.model small
.stack 100h
.data
msg1 db 'hello$'

6
msg2 db 'world$'
.code
main proc
mov ax , @data
mov ds , ax
mov dx , offset msg1
mov ah , 9
int 21h
mov dx , 10
mov ah , 2
int 21h
mov dx , 13
mov ah , 2
int 21h
mov dx , offset msg2
mov ah , 9
int 21h
mov ah , 4ch
int 21h
main endp
end main

Output:

7
Program 8. Write a Program to Convert Lower Character To Capital Character
Code:
.model small
.stack 100h
.data
msg1 db "Enter any character in lower Case:$"
msg2 db "Enter any character in lower Case:$"
.code
main proc
mov ax , @data
mov ds , ax
lea dx , msg1
mov ah , 09h
int 21h
mov ah , 1
int 21h
mov cl , al
mov dx , 10
mov ah , 2
int 21h
sub cl , 20h
lea dx , msg2
mov ah , 09h
int 21h
mov dl , cl
mov ah , 2
int 21h
main endp
end main

8
Output:

Program 9. Write a Program to Reverse a String


Code:
.model small
.stack 100h
.data
msg1 db 'Hansraj'
.code
main proc
mov ax , @data
mov ds ,ax
mov si , offset msg1
mov cx , 7
l1:
mov bx , [si]
push bx
inc si
loop l1
mov cx , 7
l2:
pop dx
mov ah , 2
int 21h

9
loop l2
mov ah , 4ch
int 21h
main endp
end main

Output:

10
Program 10. Write a Program to Print Factorial of a number
Code:
.model small
.stack 100h
.data
a db 03h
assume CS:abc
abc segment
start:
mov ax , @data
mov ds , ax
mov cl , a
mov al , 0001h
back:
mul cl
loop back
add al , 30h
mov dl ,al
mov ah ,02h
int 21h
mov ax , 4c00h
int 21h
abc ends
end start
end

Output:

11
Program 11. Write a Program to Check the String is Polindrome or NOT.
Code:
.model small
.stack 100h
.data
msg1 db 'String is polindrome','$'
msg2 db 'String is not polindrome','$'
string db , "kook$" , 0

.code
assume CS:abc
abc segment

start:

mov ax , @data
mov ds , ax

mov bx , offset string


mov si , bx

mov cx , 0000h

find_len:
mov al , [si]
cmp al , '$'

je len_found
inc si

12
inc cx
jmp find_len

len_found:
dec si
mov di , bx

chk_polindrome:

cmp di, si
jge polindrome_found

mov al , [di]
mov dl , [si]

cmp al , dl
jne not_polindrome

inc di
dec si

jmp chk_polindrome

polindrome_found:
mov dx , offset msg1
mov ah , 09h

int 21h
jmp done

13
not_polindrome:
mov dx , offset mgs2
mov ah , 09h

int 21h
jmp done

done:
mov ah , 4c00h
int 21h

abc ends
end start
end

Output:

14
Program 12. Write a Program To display ASCII character in rows and columns for a
given range

Code:
.model small
.stack 100h
.code
assume CS:abc
abc segment

start:

mov ax , @data
mov ds , ax

mov dx , 0000h
mov dl , 10h

mov cx , 000fh

mov ax , 0000h
row:
mov ah , 02h
push cx
mov cx , 0010h

col:
int 21h
push dx

mov dl , 00h

15
int 21h
pop dx
inc dx
loop col
pop cx
push dx
mov dl , 0dh
int 21h
mov dl , 0ah
int 21h
pop dx
loop row

mov ax , 4c00h
int 21h
abc ends
end start
end

Output:

16
Program 13. Write a Program to store array and find the largest element in array

Code:
.model small
.stack 100h
.data
array db 1,2,7,9,6,4

.code
assume CS:abc
abc segment

start:

mov ax , @data
mov ds , ax

mov cx , 6
mov bl , 0

LEA si , array

up:
mov al , [si]
cmp al , bl
jbe nxt

mov bl , al

nxt:

17
inc si
loop up

mov dl , bl
add dl , 48

mov ah , 02h
int 21h

mov ax , 4c00h
int 21h

abc ends
end start
end

Output:

18
Program 14. Write a Program to print a string using iteration
Code:
.model small
.stack 100h
.data
msg1 db 'Hansraj_Kishore','$'
.code
assume CS:abc
abc segment
start
mov ax , @data
mov ds , ax
lea si,msg1
mov cx , 000Fh
iter:
mov dx , [si]
mov ah , 02h
int 21h
inc si
dec c
jnz iter
mov ax , 4c00h
int 21h
abc ends
end start
end

19
Output:

Program 15. Write a Program to print whole string in one go

Code:
.model small
.stack 100h
.data
msg1 db 'hello$'
msg2 db 'world$'
.code
main proc
mov ax , @data
mov ds , ax
mov dx , offset msg1
mov ah , 9
int 21h
mov dx , 10
mov ah , 2
int 21h
mov dx , 13
mov ah , 2
int 21h
mov dx , offset msg2
mov ah , 9

20
int 21h

mov ah , 4ch
int 21h

main endp
end main

Output:

Program 16. Write a Program to concatenate two string.


Code:
.model small
.stack 100h
.data
msg1 db 'Hansraj','$'
msg2 db 'Kishore','$'

.code
assume CS:abc
abc segment

21
start:

mov ax , @data
mov ds , ax

mov bx , offset msg1


mov cx , 0002h

curr:
push cx
mov cx , 0007h

nxt:
mov ah , 02h

mov dl , [bx]
int 21h

inc bx
dec cx

jnz nxt

mov dl , 00h
int 21h

pop cx

mov bx , offset msg2

22
loop curr

mov ax , 4c00h
int 21h

abc ends
end start
end

Output:

23
Program 17. Write a Program to find the sum of two number without using
arithmetic operation

Code:
.model small
.stack 100h
.data
CR EQU 0DH
LF EQU 0AH

num1 db 4
num2 db 5

.code
assume CS:abc
abc segment

start:

mov ax , @data
mov ds , ax

mov al , num1
mov bl , num2

l1:

mov dl , al
and dl , bl

xor al , bl

24
shl dl , 1

mov bl , dl
jnz l1

add al , '0'
mov dl , al

mov ah , 02h
int 21h

mov ax , 4c00h
int 21h

abc ends
end start
end

Output:

25
Program 18. Write a Program to Print Character from a to z.

Code:
.model small
.stack 100h
.data
.code
main proc

mov cx , 26
mov dx , 97

l1:
mov ah , 2
int 21h
add dx , 1
loop l1

mov ah , 4ch
int 21h
main endp
end main

Output:

26
27

You might also like