You are on page 1of 21

MCA (I-sem.

) Laboratory file of Assembly Language Programming


INDEX
S.No. PROGRAM Page No.
1 Write an assembly program to print a single character 2
2 Write an assembly program to print two messages 3
3 Write an assembly program to print the sum of two digits 4
4 Write an assembly program to print the factorial value of a number 5
5 Write an assembly program to print multiple digit number 7
6 Write an assembly program to read a character from keyboardthen display withi
n parenthesis 9
7 Write an assembly program to read a string & then display inreverse string 10
8 Write an assembly program to print square of any given number 11
9 Write an assembly program to find out the multiplication of two single digit n
umbers 13
10 Write an assembly program to find out the subtraction of two single digit num
bers 15
11 Write an assembly program to find out the addition of two multiple digits num
bers 17
12 Write an assembly program to find out the subtraction of two multiple digits
numbers 19
13 Write an assembly program to find out the multiplication of two multiple digi
ts numbers 21
14 Write an assembly program to find out the division of two multiple digits num
bers 23
15 Write an assembly program to print A to Z 25
16 Write an assembly program to calculate sum of series 26
17 Write an assembly program to determine largest number out of 3 numbers 28
Hirdesh Singh Rajput
1
MCA (I-sem.) Laboratory file of Assembly Language Programming
1st Program:
Write an assembly program to print a single character.
// an assembly program for print a character.
.model small
.stack 100h
.data
msg1 db 13,10, Enter character $
msg2 db 13,10, Entered character is $
.code
mov ax, @data
mov ds, ax
lea dx, msg1
mov ah, 09h
int 21h
mov ah, 01h
int 21h
mov bl, al
lea dx, msg2
mov ah, 09h
int 21h
mov dl, bl
mov ah, 02h
int 21h
mov ah, 4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME??
Enter character G
Entered character is G
Hirdesh Singh Rajput
2
MCA (I-sem.) Laboratory file of Assembly Language Programming
2nd Program:
Write an assembly program to print two messages.
// an assembly program for print two messages.
.model small
.stack 100h
.data
msg1 db 13,10, No time for $
msg2 db 13,10, Study $
.code
mov ax, @data
mov ds, ax
lea dx, msg1
mov ah, 09h
int 21h
lea dx, msg2
mov ah, 09h
int 21h
mov ah, 4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME??
No time for
Study
Hirdesh Singh Rajput
3
MCA (I-sem.) Laboratory file of Assembly Language Programming
3rd Program:
Write an assembly program to print the sum of two digits.
// an assembly program for print the sum of two digits.
.model small
.stack 100h
.data
s1 db 13,10, Enter the 1 st value $
s2 db 13,10, Enter the 2 nd value $
s3 db 13,10, Sum is $
.code
mov ax, @data
mov ds, ax
lea dx, s1
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al,30h
mov bl, al
lea dx, s2
mov ah, 09h
int 21h
mov db, 0lh
int 21h
mov ah, 01h
int 21h
sub al, 30h
add bl, al
lea dx, s3
mov ah, 09h
int 21h
add bl, 30h
mov dl, bl
mov dh, 02h
int 21h
mov ah, 4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME??
Enter the 1 st value 2
Enter the 2 nd value 3
Sum is 6
Hirdesh Singh Rajput
4
MCA (I-sem.) Laboratory file of Assembly Language Programming
4th Program:
Write an assembly program to print the factorial value of a number.
// an assembly program for print factorial of a number.
.model small
.stack 100h
.data
msg1 db 13,10, Enter Number $
msg2 db 13,10, Factorial value is $
.code
mov ax, @data
mov ds, ax
lea dx, msg1
mov ah, 09h
int 21h
mov bx, 0
start:
mov ah, 01
int 21h
cmp al, 0dh
je next
mov ah, 0
sub al, 30h
push ax
mov ax, 10d
mul bx
pop bx
add bx, ax
jmp start
next:
mov cx, bx
mov ax, 1
top:
mul cx
loop top
mov bx,10d
mov dx, 0
break:
div bx
push dx
inc cx
mov dx, 0
or ax, ax
jnz break
Hirdesh Singh Rajput
5
MCA (I-sem.) Laboratory file of Assembly Language Programming
mov ah, 09
lea dx, msg2
int 21h
mov dx, 0
print:
pop dx
mov ah, 02
add dl, 03h
int 21h
loop print
mov ah, 4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME??
Enter Number 5
Factorial value is 120
Hirdesh Singh Rajput
6
MCA (I-sem.) Laboratory file of Assembly Language Programming
5th Program:
Write an assembly program to print multiple digit number.
// an assembly program for print multiple digit number.
.model small
.stack 100h
.data
m1 db 13,10, Enter Number $
m2 db 13,10, Entered Number is $
.code
mov ax, @data
mov ds, ax
lea dx, m1
mov ah, 09h
int 21h
mov bx, 0
start:
mov ah, 01
int 21h
cmp al, 0dh
je next
mov ah, 0
sub al, 30h
push ax
mov ax, 10d
mul bx
pop bx
add bx, ax
jmp start1
next:
push bx
mov ah,09h
lea dx, m2
int 21h
pop ax
mov dx,0
mov bx,10d
break:
div bx
push dx
mov dx,0
or ax, ax
jnz break
Hirdesh Singh Rajput
7
MCA (I-sem.) Laboratory file of Assembly Language Programming
print:
pop dx
add dl, 30h
mov ah, 02
int 21h
loop print
mov ah, 4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter Number 555
Entered Number is 555
Hirdesh Singh Rajput
8
MCA (I-sem.) Laboratory file of Assembly Language Programming
6th Program:
Write an assembly program to read a character from keyboard then display within
parenthesis.
// an assembly program for read a character and display within parenthesis.
.model small
.stack 100h
.data
m1 db 13,10, Enter Character : $
m2 db 13,10, Entered Character is : $
.code
mov ax, @data
mov ds, ax
lea dx, m1
mov ah, 09h
int 21h
mov ah,01h
int 21h
mov bl,al
lea dx,m2
mov ah,09h
int 21h
mov dl, (
mov ah,02h
int 21h
mov dl,bl
mov ah,02h
int 21h
mov dl, )
mov ah,02h
int 21h
mov ah,4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter Character : h
Entered Character is : (h)
Hirdesh Singh Rajput
9
MCA (I-sem.) Laboratory file of Assembly Language Programming
7th Program:
Write an assembly program to read a string & then display in reverse string.
// an assembly program for print reverse string.
.model small
.stack 100h
.data
m1 db 13,10, Enter String : $
m2 db 13,10, Reverse String is : $
.code
mov ax, @data
mov ds, ax
lea dx, m1
mov ah, 09h
int 21h
mov cx, 0
read:
mov ah, 01
int 21h
cmp al, 0dh
je ahead
push ax
inc cx
jmp read
ahead:
lea dx, m2
mov ah,09h
int 21h
display:mov ah,02h
pop dx
int 21h
loop display
mov ah,4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter String : mca
Reverse String is : acm
Hirdesh Singh Rajput
10
MCA (I-sem.) Laboratory file of Assembly Language Programming
8th Program:
Write an assembly program to print square of any given number.
// an assembly program for print square value
.model small
.stack 100h
.data
a dw ?
s1 db 13,10, Enter Number : $
s2 db 13,10, Square is : $
.code
mov ax, @data
mov ds,ax
mov ah,09h
lea dx,s1
int 21h
mov bx,0
read:
mov ah,01h
int 21h
cmp al,0dh
je next
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp read
next:
mov ax,bx
mov a,ax
mul a
push ax
mov cx,0
mov ah,09h
lea dx,s2
int 21h
mov dx,0
mov bx,10d
pop ax
Hirdesh Singh Rajput
11
MCA (I-sem.) Laboratory file of Assembly Language Programming
display:mov dx,0
div bx
push dx
inc cx
or ax,ax
jnz display
print:
mov dx,0
mov ah,02h
pop dx
add dl,30h
int 21h
loop print
mov ah,4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter Number : 2
Square is : 4
Hirdesh Singh Rajput
12
MCA (I-sem.) Laboratory file of Assembly Language Programming
9th Program:
Write an assembly program to find out the multiplication of two single digit num
bers.
// an assembly program for print multiplication of two single digit numbers.
.model small
.stack 100h
.data
s1 db 13,10, Enter 1st Number : $
s2 db 13,10, Enter 2nd Number : $
s3 db 13,10, Multiplication is : $
.code
mov ax, @data
mov ds, ax
lea dx, s1
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, 30h
mov bl,al
lea dx, s2
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, 30h
mul bl
mov bl, al
lea dx, s3
mov ah, 09h
int 21h
add bl, 30h
mov dl, bl
mov ah, 02h
int 21h
Hirdesh Singh Rajput
13
MCA (I-sem.) Laboratory file of Assembly Language Programming
mov ah, 4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter 1st Number : 2
Enter 2nd Number : 3
Multiplication is : 6
Hirdesh Singh Rajput
14
MCA (I-sem.) Laboratory file of Assembly Language Programming
10th Program:
Write an assembly program to find out the subtraction of two single digit number
s.
// an assembly program for print subtraction of two single digit numbers.
.model small
.stack 100h
.data
s1 db 13,10, Enter 1st Number : $
s2 db 13,10, Enter 2nd Number : $
s3 db 13,10, Subtraction is : $
.code
mov ax, @data
mov ds, ax
lea dx, s1
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, 30h
mov bl,al
lea dx, s2
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, 30h
sub bl, al
lea dx, s3
mov ah, 09h
int 21h
add bl, 30h
mov dl, bl
mov ah, 02h
int 21h
mov ah, 4ch
Hirdesh Singh Rajput
15
MCA (I-sem.) Laboratory file of Assembly Language Programming
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter 1st Number : 6
Enter 2nd Number : 3
Subtraction is : 3
Hirdesh Singh Rajput
16
MCA (I-sem.) Laboratory file of Assembly Language Programming
11th Program:
Write an assembly program to find out the addition of two multiple digits number
s.
// an assembly program for print addition of two multiple digits numbers.
.model small
.stack 100h
.data
s1 db 13,10, Enter 1st Number : $
s2 db 13,10, Enter 2nd Number : $
s3 db 13,10, Addition is : $
.code
mov ax, @data
mov ds, ax
lea dx, s1
mov ah, 09h
int 21h
mov bx, 0
start1:
mov ah, 01h
int 21h
cmp al,0dh
jz next1
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp start1
next1:
push bx
lea dx,s2
mov ah,09h
int 21h
mov bx,0
start2:
mov ah,01h
int 21h
cmp al,0dh
Hirdesh Singh Rajput
17
MCA (I-sem.) Laboratory file of Assembly Language Programming
jz next2
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp start2
next2:
pop ax
add ax,bx
push ax
lea dx,s3
mov ah,09h
int 21h
pop ax
mov cx,0
mov dx,0
mov bx,10d
break:
div bx
push dx
mov dx,0
inc cx
or ax,ax
jnz break
push:
pop dx
add dl,30h
mov ah,02h
int 21h
loop print
mov ah,4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter 1st Number : 26
Enter 2nd Number : 24
Addition is : 50
Hirdesh Singh Rajput
18
MCA (I-sem.) Laboratory file of Assembly Language Programming
12th Program:
Write an assembly program to find out the subtraction of two multiple digits num
bers.
// an assembly program for print subtraction of two multiple digits numbers.
.model small
.stack 100h
.data
s1 db 13,10, Enter 1st Number : $
s2 db 13,10, Enter 2nd Number : $
s3 db 13,10, Subtraction is : $
.code
mov ax, @data
mov ds, ax
lea dx, s1
mov ah, 09h
int 21h
mov bx, 0
start1:
mov ah, 01h
int 21h
cmp al,0dh
jz next1
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp start1
next1:
push bx
lea dx,s2
mov ah,09h
int 21h
mov bx,0
start2:
mov ah,01h
int 21h
cmp al,0dh
Hirdesh Singh Rajput
19
MCA (I-sem.) Laboratory file of Assembly Language Programming
jz next2
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp start2
next2:
pop ax
sub ax,bx
push ax
lea dx,s3
mov ah,09h
int 21h
pop ax
mov cx,0
mov dx,0
mov bx,10d
break:
div bx
push dx
mov dx,0
inc cx
or ax,ax
jnz break
push:
pop dx
add dl,30h
mov ah,02h
int 21h
loop print
mov ah,4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter 1st Number : 100 Enter 2nd Number : 40 Subtraction is : 60
Hirdesh Singh Rajput
20
MCA (I-sem.) Laboratory file of Assembly Language Programming
13th Program:
Write an assembly program to find out the multiplication of two multiple digits
numbers.
// an assembly program for print multiplication of two multiple digits numbers.
.model small
.stack 100h
.data
s1 db 13,10, Enter 1st Number : $
s2 db 13,10, Enter 2nd Number : $
s3 db 13,10, Multiplication is : $
.code
mov ax, @data
mov ds, ax
lea dx, s1
mov ah, 09h
int 21h
mov bx, 0
start1:
mov ah, 01h
int 21h
cmp al,0dh
jz next1
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp start1
next1:
push bx
lea dx,s2
mov ah,09h
int 21h
mov bx,0
start2:
mov ah,01h
int 21h
cmp al,0dh
Hirdesh Singh Rajput
21
MCA (I-sem.) Laboratory file of Assembly Language Programming
jz next2
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp start2
next2:
pop ax
mul bx
push ax
lea dx,s3
mov ah,09h
int 21h
pop ax
mov cx,0
mov dx,0
mov bx,10d
break:
div bx
push dx
mov dx,0
inc cx
or ax,ax
jnz break
push:
pop dx
add dl,30h
mov ah,02h
int 21h
loop print
mov ah,4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter 1st Number : 11
Enter 2nd Number : 11
Multiplication is : 121
Hirdesh Singh Rajput
22
MCA (I-sem.) Laboratory file of Assembly Language Programming
14th Program:
Write an assembly program to find out the division of two multiple digits number
s.
// an assembly program for print division of two multiple digits numbers.
.model small
.stack 100h
.data
s1 db 13,10, Enter 1st Number : $
s2 db 13,10, Enter 2nd Number : $
s3 db 13,10, Addition is : $
.code
mov ax, @data
mov ds, ax
lea dx, s1
mov ah, 09h
int 21h
mov bx, 0
start1:
mov ah, 01h
int 21h
cmp al,0dh
jz next1
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp start1
next1:
push bx
lea dx,s2
mov ah,09h
int 21h
mov bx,0
start2:
mov ah,01h
int 21h
cmp al,0dh
Hirdesh Singh Rajput
23
MCA (I-sem.) Laboratory file of Assembly Language Programming
jz next2
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp start2
next2:
pop ax
div bx
push ax
lea dx,s3
mov ah,09h
int 21h
pop ax
mov cx,0
mov dx,0
mov bx,10d
break:
div bx
push dx
mov dx,0
inc cx
or ax,ax
jnz break
push:
pop dx
add dl,30h
mov ah,02h
int 21h
loop print
mov ah,4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
Enter 1st Number : 500 Enter 2nd Number : 50 Division is : 10
Hirdesh Singh Rajput
24
MCA (I-sem.) Laboratory file of Assembly Language Programming
15th Program:
Write an assembly program to print A to Z.
// an assembly program for print A to Z.
.model small
.stack 100h
.data
.code
mov ax, @data
mov ds, ax
mov dl, A
mov cx,26
again:
mov ah,02h
int 21h
inc dl
mov bx,0
mov bl,dl
mov dl,
mov ah,02h
int 21h
mov dl,bl
loop again
mov ah,4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME?
AB C D E F G H I J K LM N O PQ R STUVWXYZ
Hirdesh Singh Rajput
25
MCA (I-sem.) Laboratory file of Assembly Language Programming
16th Program:
Write an assembly program to calculate sum of series.
// an assembly program for print sum of a series.
.model small
.stack 100h
.data
s1 db 13,10, Input limit : $
s2 db 13,10, Sum of series is : $
.code
mov ax, @data
mov ds,ax
mov ah,09h
lea dx,s1
int 21h
mov bx,0
read:
mov ah,01h
int 21h
cmp al,0dh
je next
mov ah,0
sub al,30h
push ax
mov ax,10d
mul bx
pop bx
add bx,ax
jmp read
next:
mov ax,bx
mov cx,ax
mov ax,0
again:
add ax,cx
loop again
push ax
mov cx,0
mov ah,09h
lea dx,s2
int 21h
Hirdesh Singh Rajput
26
MCA (I-sem.) Laboratory file of Assembly Language Programming
mov dx,0
mov bx,10d
pop ax
display:mov dx,b
div bx
push dx
inc cx
or ax,ax
jnz display
print:
mov dx,0
mov ah,02h
int 21h
pop dx
add dl,30h
int 21h
loop print
mov ah,4ch
int 21h
end
Screen print of program:
C:\>MASM> PROGRAM NAME??
Input limit : 5
Sum of series is : 15
Hirdesh Singh Rajput
27
MCA (I-sem.) Laboratory file of Assembly Language Programming
17th Program:
Write an assembly program to determine largest number out of 3 numbers.
// an assembly program for determine largest number out of 3 numbers.
.model small
.stack 100h
.data
a dw ?
b dw ?
c dw ?
l dw ?
s1 db 13,10, Enter 1st no. : $
s2 db 13,10, Enter 2nd no. : $
s3 db 13,10, Enter 3rd no. : $
s4 db 13,10, Largest no. is : $
.code
mov ax, @data
mov ds,ax
mov ah,09h
lea dx,s1
int 21h
call getint
mov a,bx
mov ax,0
mov bx,0
mov ah,09h
lea dx,s2
int 21h
call getint
mov b,dx
mov bx,0
mov ax,0
mov ah,09h
lea dx,s3
int 21h
call getint
mov c,bx
mov bx,0
Hirdesh Singh Rajput
28
MCA (I-sem.) Laboratory file of Assembly Language Programming
mov ax,0
mov ax,a
cmp ax,b
jl check_bc
cmp ax,c
jl mov_c
mov l,ax
jmp exit1
check_bc:
mov ax,b
cmp ax,c
jl mov_c
mov l,ax
jmp exit1
mov_c:mov ax,c
mov l,ax
mov ax,0
mov bx,0
mov dx,0
exit1:
mov ah,09h
lea dx,s4
int 21h
call disprint
mov ax,0
mov ah,4ch
int 21h
getint proc
mov bx,0
read:
mov ah,01h
int 21h
cmp al,0dh
je next
mov ah,0
sub al,30h
push ax
mov ax,10d
Hirdesh Singh Rajput
29
MCA (I-sem.) Laboratory file of Assembly Language Programming
mul bx
pop bx
add bx,ax
jmp read
next:
ret
getint endp
disprint proc
mov ax,l
push ax
mov dx,0
mov bx,10d
pop ax
mov cx,0
display:mov dx,0
div bx
push dx
inc cx
or ax,ax
jnz display
print:
mov dx,0
mov ah,02h
pop dx
add dl,30h
int 21h
loop print
ret
disprint endp
end
Screen print of program:
C:\>MASM> PROGRAM NAME??
Enter 1st no. : 8
Enter 2nd no. : 6
Enter 3rd no. : 4
Largest no. is : 8
Hirdesh Singh Rajput

You might also like