36
MCA (I-sem.) Laboratory file of Assembly Language Programming I N D E X 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 keyboard then display within parenthesis 9 7 Write an assembly program to read a string & then display in reverse 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 numbers 13 10 Write an assembly program to find out the subtraction of two single digit numbers 15 11 Write an assembly program to find out the addition of two multiple digits numbers 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 digits numbers 21 14 Write an assembly program to find out the 23 Hirdesh Singh Rajput 1

Assembly Program's File

  • Upload
    hirdesh

  • View
    9.568

  • Download
    0

Embed Size (px)

DESCRIPTION

This is the program file for Gyan Ganga's student

Citation preview

Page 1: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

I N D E X

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 keyboard then display within parenthesis

9

7 Write an assembly program to read a string & then display in reverse 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 numbers

13

10 Write an assembly program to find out the subtraction of two single digit numbers

15

11 Write an assembly program to find out the addition of two multiple digits numbers

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 digits numbers

21

14 Write an assembly program to find out the division of two multiple digits numbers

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 Rajput1

Page 2: Assembly Program's File

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

.datamsg1 db 13,10, “Enter character $”msg2 db 13,10, “Entered character is $”

.codemov ax, @datamov ds, axlea dx, msg1mov ah, 09hint 21hmov ah, 01hint 21hmov bl, allea dx, msg2mov ah, 09hint 21hmov dl, blmov ah, 02hint 21hmov ah, 4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter character GEntered character is G

Hirdesh Singh Rajput2

Page 3: Assembly Program's File

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

.datamsg1 db 13,10, “No time for $”msg2 db 13,10, “Study $”

.codemov ax, @datamov ds, axlea dx, msg1mov ah, 09hint 21hlea dx, msg2mov ah, 09hint 21hmov ah, 4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

No time forStudy

Hirdesh Singh Rajput3

Page 4: Assembly Program's File

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

.datas1 db 13,10, “Enter the 1 st value $”s2 db 13,10, “Enter the 2 nd value $”s3 db 13,10, “Sum is $”

.codemov ax, @datamov ds, axlea dx, s1mov ah, 09hint 21hmov ah, 01hint 21hsub al,30hmov bl, allea dx, s2mov ah, 09hint 21hmov db, 0lhint 21hmov ah, 01hint 21hsub al, 30hadd bl, allea dx, s3mov ah, 09hint 21hadd bl, 30hmov dl, blmov dh, 02hint 21hmov ah, 4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter the 1 st value 2Enter the 2 nd value 3Sum is 6

Hirdesh Singh Rajput4

Page 5: Assembly Program's File

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

.datamsg1 db 13,10, “Enter Number $”msg2 db 13,10, “Factorial value is $”

.codemov ax, @datamov ds, axlea dx, msg1mov ah, 09hint 21hmov bx, 0

start:mov ah, 01int 21hcmp al, 0dhje nextmov ah, 0sub al, 30hpush axmov ax, 10dmul bxpop bxadd bx, axjmp start

next:mov cx, bxmov ax, 1

top:mul cxloop topmov bx,10dmov dx, 0

break:div bxpush dxinc cxmov dx, 0or ax, axjnz break

Hirdesh Singh Rajput5

Page 6: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

mov ah, 09lea dx, msg2int 21hmov dx, 0

print:pop dxmov ah, 02add dl, 03hint 21hloop printmov ah, 4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter Number 5Factorial value is 120

Hirdesh Singh Rajput6

Page 7: Assembly Program's File

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

.datam1 db 13,10, “Enter Number $”m2 db 13,10, “Entered Number is $”

.codemov ax, @datamov ds, axlea dx, m1mov ah, 09hint 21hmov bx, 0

start:mov ah, 01int 21hcmp al, 0dhje nextmov ah, 0sub al, 30hpush axmov ax, 10dmul bxpop bxadd bx, axjmp start1

next:push bxmov ah,09hlea dx, m2int 21hpop axmov dx,0mov bx,10d

break:div bxpush dxmov dx,0or ax, axjnz break

Hirdesh Singh Rajput7

Page 8: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

print:pop dxadd dl, 30hmov ah, 02int 21hloop printmov ah, 4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter Number 555Entered Number is 555

Hirdesh Singh Rajput8

Page 9: Assembly Program's File

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

.datam1 db 13,10, “Enter Character : $”m2 db 13,10, “Entered Character is : $”

.codemov ax, @datamov ds, ax

lea dx, m1mov ah, 09hint 21h

mov ah,01hint 21h

mov bl,al

lea dx,m2mov ah,09hint 21h

mov dl,”(”mov ah,02hint 21h

mov dl,blmov ah,02hint 21h

mov dl,”)mov ah,02hint 21h

mov ah,4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME Enter Character : hEntered Character is : (h)

Hirdesh Singh Rajput9

Page 10: Assembly Program's File

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

.datam1 db 13,10, “Enter String : $”m2 db 13,10, “Reverse String is : $”

.codemov ax, @datamov ds, axlea dx, m1mov ah, 09hint 21hmov cx, 0

read:mov ah, 01int 21hcmp al, 0dhje aheadpush axinc cxjmp read

ahead:lea dx, m2mov ah,09hint 21h

display:mov ah,02hpop dxint 21hloop display

mov ah,4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter String : mcaReverse String is : acm

Hirdesh Singh Rajput10

Page 11: Assembly Program's File

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 : $”

.codemov ax, @datamov ds,axmov ah,09hlea dx,s1int 21hmov bx,0

read:mov ah,01hint 21hcmp al,0dhje nextmov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp read

next:mov ax,bxmov a,axmul apush axmov cx,0

mov ah,09hlea dx,s2int 21h

mov dx,0mov bx,10dpop ax

Hirdesh Singh Rajput11

Page 12: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

display:mov dx,0div bxpush dxinc cxor ax,axjnz display

print:mov dx,0mov ah,02hpop dxadd dl,30hint 21hloop printmov ah,4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter Number : 2Square is : 4

Hirdesh Singh Rajput12

Page 13: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

9th Program:

Write an assembly program to find out the multiplication of two single digit numbers.

// an assembly program for print multiplication of two single digit numbers.

.model small

.stack 100h

.datas1 db 13,10, “Enter 1st Number : $”s2 db 13,10, “Enter 2nd Number : $”s3 db 13,10, ”Multiplication is : $”

.codemov ax, @datamov ds, ax

lea dx, s1mov ah, 09hint 21h

mov ah, 01hint 21h

sub al, 30hmov bl,al

lea dx, s2mov ah, 09hint 21h

mov ah, 01hint 21h

sub al, 30hmul blmov bl, al

lea dx, s3mov ah, 09hint 21h

add bl, 30hmov dl, blmov ah, 02hint 21h

Hirdesh Singh Rajput13

Page 14: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

mov ah, 4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter 1st Number : 2Enter 2nd Number : 3Multiplication is : 6

Hirdesh Singh Rajput14

Page 15: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

10th Program:

Write an assembly program to find out the subtraction of two single digit numbers.

// an assembly program for print subtraction of two single digit numbers.

.model small

.stack 100h

.datas1 db 13,10, “Enter 1st Number : $”s2 db 13,10, “Enter 2nd Number : $”s3 db 13,10, ”Subtraction is : $”

.codemov ax, @datamov ds, ax

lea dx, s1mov ah, 09hint 21h

mov ah, 01hint 21h

sub al, 30hmov bl,al

lea dx, s2mov ah, 09hint 21h

mov ah, 01hint 21h

sub al, 30hsub bl, al

lea dx, s3mov ah, 09hint 21h

add bl, 30hmov dl, blmov ah, 02hint 21h

mov ah, 4ch

Hirdesh Singh Rajput15

Page 16: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

int 21hend

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter 1st Number : 6Enter 2nd Number : 3Subtraction is : 3

Hirdesh Singh Rajput16

Page 17: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

11th Program:

Write an assembly program to find out the addition of two multiple digits numbers.

// an assembly program for print addition of two multiple digits numbers.

.model small

.stack 100h

.datas1 db 13,10, “Enter 1st Number : $”s2 db 13,10, “Enter 2nd Number : $”s3 db 13,10, ”Addition is : $”

.codemov ax, @datamov ds, ax

lea dx, s1mov ah, 09hint 21h

mov bx, 0start1:

mov ah, 01hint 21hcmp al,0dhjz next1

mov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp start1

next1:push bxlea dx,s2mov ah,09hint 21h

mov bx,0start2:

mov ah,01hint 21hcmp al,0dh

Hirdesh Singh Rajput17

Page 18: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

jz next2mov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp start2

next2:pop axadd ax,bxpush ax

lea dx,s3mov ah,09hint 21hpop axmov cx,0mov dx,0mov bx,10d

break:div bxpush dxmov dx,0inc cxor ax,axjnz break

push:pop dxadd dl,30hmov ah,02hint 21hloop printmov ah,4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter 1st Number : 26Enter 2nd Number : 24Addition is : 50

Hirdesh Singh Rajput18

Page 19: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

12th Program:

Write an assembly program to find out the subtraction of two multiple digits numbers.

// an assembly program for print subtraction of two multiple digits numbers.

.model small

.stack 100h

.datas1 db 13,10, “Enter 1st Number : $”s2 db 13,10, “Enter 2nd Number : $”s3 db 13,10, ” Subtraction is : $”

.codemov ax, @datamov ds, ax

lea dx, s1mov ah, 09hint 21h

mov bx, 0start1:

mov ah, 01hint 21hcmp al,0dhjz next1

mov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp start1

next1:push bxlea dx,s2mov ah,09hint 21h

mov bx,0start2:

mov ah,01hint 21hcmp al,0dh

Hirdesh Singh Rajput19

Page 20: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

jz next2mov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp start2

next2:pop axsub ax,bxpush ax

lea dx,s3mov ah,09hint 21hpop axmov cx,0mov dx,0mov bx,10d

break:div bxpush dxmov dx,0inc cxor ax,axjnz break

push:pop dxadd dl,30hmov ah,02hint 21hloop printmov ah,4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter 1st Number : 100Enter 2nd Number : 40Subtraction is : 60

Hirdesh Singh Rajput20

Page 21: Assembly Program's File

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

.datas1 db 13,10, “Enter 1st Number : $”s2 db 13,10, “Enter 2nd Number : $”s3 db 13,10, ”Multiplication is : $”

.codemov ax, @datamov ds, ax

lea dx, s1mov ah, 09hint 21h

mov bx, 0start1:

mov ah, 01hint 21hcmp al,0dhjz next1

mov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp start1

next1:push bxlea dx,s2mov ah,09hint 21h

mov bx,0start2:

mov ah,01hint 21hcmp al,0dh

Hirdesh Singh Rajput21

Page 22: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

jz next2mov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp start2

next2:pop axmul bxpush ax

lea dx,s3mov ah,09hint 21hpop axmov cx,0mov dx,0mov bx,10d

break:div bxpush dxmov dx,0inc cxor ax,axjnz break

push:pop dxadd dl,30hmov ah,02hint 21hloop printmov ah,4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter 1st Number : 11Enter 2nd Number : 11Multiplication is : 121

Hirdesh Singh Rajput22

Page 23: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

14th Program:

Write an assembly program to find out the division of two multiple digits numbers.

// an assembly program for print division of two multiple digits numbers.

.model small

.stack 100h

.datas1 db 13,10, “Enter 1st Number : $”s2 db 13,10, “Enter 2nd Number : $”s3 db 13,10, ”Addition is : $”

.codemov ax, @datamov ds, ax

lea dx, s1mov ah, 09hint 21h

mov bx, 0start1:

mov ah, 01hint 21hcmp al,0dhjz next1

mov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp start1

next1:push bxlea dx,s2mov ah,09hint 21h

mov bx,0start2:

mov ah,01hint 21hcmp al,0dh

Hirdesh Singh Rajput23

Page 24: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

jz next2mov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp start2

next2:pop axdiv bxpush ax

lea dx,s3mov ah,09hint 21hpop axmov cx,0mov dx,0mov bx,10d

break:div bxpush dxmov dx,0inc cxor ax,axjnz break

push:pop dxadd dl,30hmov ah,02hint 21hloop printmov ah,4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter 1st Number : 500Enter 2nd Number : 50Division is : 10

Hirdesh Singh Rajput24

Page 25: Assembly Program's File

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

.codemov ax, @datamov ds, ax

mov dl,”A”mov cx,26

again:mov ah,02hint 21h

inc dlmov bx,0mov bl,dl

mov dl,” ”mov ah,02hint 21h

mov dl,blloop again

mov ah,4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Hirdesh Singh Rajput25

Page 26: Assembly Program's File

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

.datas1 db 13,10, “Input limit : $”s2 db 13,10, “Sum of series is : $”

.codemov ax, @datamov ds,ax

mov ah,09hlea dx,s1int 21h

mov bx,0read:

mov ah,01hint 21hcmp al,0dhje next

mov ah,0sub al,30hpush axmov ax,10dmul bxpop bxadd bx,axjmp read

next:mov ax,bxmov cx,axmov ax,0

again:add ax,cxloop againpush axmov cx,0mov ah,09hlea dx,s2int 21h

Hirdesh Singh Rajput26

Page 27: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

mov dx,0mov bx,10dpop ax

display:mov dx,bdiv bxpush dxinc cxor ax,axjnz display

print:mov dx,0mov ah,02hint 21hpop dxadd dl,30hint 21hloop printmov ah,4chint 21h

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Input limit : 5Sum of series is : 15

Hirdesh Singh Rajput27

Page 28: Assembly Program's File

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

.dataa 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 : $”

.codemov ax, @datamov ds,ax

mov ah,09hlea dx,s1int 21h

call getintmov a,bxmov ax,0mov bx,0

mov ah,09hlea dx,s2int 21h

call getintmov b,dxmov bx,0mov ax,0

mov ah,09hlea dx,s3int 21h

call getintmov c,bxmov bx,0

Hirdesh Singh Rajput28

Page 29: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

mov ax,0

mov ax,acmp ax,bjl check_bc

cmp ax,cjl mov_c

mov l,axjmp exit1

check_bc:mov ax,bcmp ax,cjl mov_c

mov l,axjmp exit1

mov_c:mov ax,cmov l,axmov ax,0mov bx,0mov dx,0

exit1:mov ah,09hlea dx,s4int 21h

call disprintmov ax,0mov ah,4chint 21h

getint procmov bx,0

read:mov ah,01hint 21hcmp al,0dh

je nextmov ah,0sub al,30hpush axmov ax,10d

Hirdesh Singh Rajput29

Page 30: Assembly Program's File

MCA (I-sem.) Laboratory file of Assembly Language Programming

mul bxpop bxadd bx,axjmp read

next:retgetint endpdisprint proc

mov ax,lpush axmov dx,0mov bx,10dpop axmov cx,0

display:mov dx,0div bxpush dxinc cxor ax,axjnz display

print:mov dx,0mov ah,02hpop dxadd dl,30hint 21hloop printretdisprint endp

end

Screen print of program:

C:\>MASM> PROGRAM NAME

Enter 1st no. : 8Enter 2nd no. : 6Enter 3rd no. : 4Largest no. is : 8

Hirdesh Singh Rajput30