You are on page 1of 31

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 PROGRAM Write an assembly progra m to print a single character Write an assembly program to print two messages Wr ite an assembly program to print the sum of two digits Write an assembly program to print the factorial value of a number Write an assembly program to print mul tiple digit number Write an assembly program to read a character from keyboard t hen display within parenthesis Write an assembly program to read a string & then display in reverse string Write an assembly program to print square of any give n number Write an assembly program to find out the multiplication of two single digit numbers Write an assembly program to find out the subtraction of two singl e digit numbers Write an assembly program to find out the addition of two multip le digits numbers Write an assembly program to find out the subtraction of two m ultiple digits numbers Write an assembly program to find out the multiplication of two multiple digits numbers Write an assembly program to find out the divisio n of two multiple digits numbers Write an assembly program to print A to Z Write an assembly program to calculate sum of series Write an assembly program to det ermine largest number out of 3 numbers Page No. 2 3 4 5 7 9 10 11 13 15 17 19 21 23 25 26 28 1 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 1st Program: Write an assembly program to print a single character. // an assembly program for pri nt a character. .model small .stack 100h .data msg1 db 13,10, Enter character $ ms g2 db 13,10, Entered character is $ .code mov ax, @data mov ds, ax lea dx, msg1 mo v ah, 09h int 21h mov ah, 01h int 21h mov bl, al lea dx, msg2 mov ah, 09h int 21 h 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 2 Hirdesh Singh Rajput

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 3 Hirdesh Singh Rajput

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, Ent er 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, 4 ch int 21h end Screen print of program: C:\>MASM> PROGRAM NAME Enter the 1 st valu e 2 Enter the 2 nd value 3 Sum is 6 4 Hirdesh Singh Rajput

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 pr ogram 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 j mp start next: mov cx, bx mov ax, 1 top: mul cx loop top mov bx,10d mov dx, 0 br eak: div bx push dx inc cx mov dx, 0 or ax, ax jnz break 5 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory msg2 int 21h mov dx, 0 mov ah, 4ch int 21h end er 5 Factorial value is 6 Hirdesh Singh Rajput

file of Assembly Language Programming mov ah, 09 lea dx, print: pop dx mov ah, 02 add dl, 03h int 21h loop print Screen print of program: C:\>MASM> PROGRAM NAME Enter Numb 120

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 Nu mber $ m2 db 13,10, Entered Number is $ .code mov ax, @data mov ds, ax lea dx, m1 m ov ah, 09h int 21h mov bx, 0 start: mov ah, 01 int 21h cmp al, 0dh je next mov a h, 0 sub al, 30h push ax mov ax, 10d mul bx pop bx add bx, ax jmp start1 next: p ush bx mov ah,09h lea dx, m2 int 21h pop ax mov dx,0 mov bx,10d break: div bx pu sh dx mov dx,0 or ax, ax jnz break 7 Hirdesh Singh Rajput

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 pr ogram: C:\>MASM> PROGRAM NAME Enter Number 555 Entered Number is 555 8 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 6th Program: Write an assembly program to read a character from keyboard then display within paren thesis. // an assembly program for read a character and display within parenthesis. .mod el small .stack 100h .data m1 db 13,10, Enter Character : $ m2 db 13,10, Entered Ch aracter 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 S creen print of program: C:\>MASM> PROGRAM NAME Enter Character : h Entered Chara cter is : (h) 9 Hirdesh Singh Rajput

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 as sembly 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, 0d h 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 p rogram: C:\>MASM> PROGRAM NAME Enter String : mca Reverse String is : acm 10 Hir desh Singh Rajput

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 11 Hirdesh Singh Rajput

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:\>M ASM> PROGRAM NAME Enter Number : 2 Square is : 4 12 Hirdesh Singh Rajput

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. .m odel small .stack 100h .data s1 db 13,10, Enter 1st Number : $ s2 db 13,10, Enter 2 nd 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, s 3 mov ah, 09h int 21h add bl, 30h mov dl, bl mov ah, 02h int 21h 13 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming mov ah, 4ch int 21 h end Screen print of program: C:\>MASM> PROGRAM NAME Enter 1st Number : 2 Enter 2nd Number : 3 Multiplication is : 6 14 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 10th Program: Writ e 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 .data s1 db 13,10, Enter 1st Number : $ s2 db 13,10, Enter 2nd Nu mber : $ 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 i nt 21h add bl, 30h mov dl, bl mov ah, 02h int 21h mov ah, 4ch 15 Hirdesh Singh R ajput

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 16 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 11th Program: Writ e 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 .data s1 db 13,10, Enter 1st Number : $ s2 db 13,10, Enter 2nd Nu mber : $ 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 a h,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 17 Hirdesh Singh Rajput

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 a dd ax,bx push ax lea dx,s3 mov ah,09h int 21h pop ax mov cx,0 mov dx,0 mov bx,10 d break: div bx push dx mov dx,0 inc cx or ax,ax jnz break push: pop dx add dl,3 0h 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 18 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 12th Program: Writ e 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 .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 n ext1 mov ah,0 sub al,30h push ax mov ax,10d mul bx pop bx add bx,ax jmp start1 n ext1: push bx lea dx,s2 mov ah,09h int 21h mov bx,0 start2: mov ah,01h int 21h c mp al,0dh 19 Hirdesh Singh Rajput

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 s ub ax,bx push ax lea dx,s3 mov ah,09h int 21h pop ax mov cx,0 mov dx,0 mov bx,10 d break: div bx push dx mov dx,0 inc cx or ax,ax jnz break push: pop dx add dl,3 0h 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 20 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 13th Program: Writ e an assembly program to find out the multiplication of two multiple digits numb ers. // an assembly program for print multiplication of two multiple digits numb ers. .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 i nt 21h cmp al,0dh 21 Hirdesh Singh Rajput

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 m ul bx push ax lea dx,s3 mov ah,09h int 21h pop ax mov cx,0 mov dx,0 mov bx,10d b reak: 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 22 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 14th Program: Writ e 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 .data s1 db 13,10, Enter 1st Number : $ s2 db 13,10, Enter 2nd Nu mber : $ 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 a h,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 23 Hirdesh Singh Rajput

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 d iv bx push ax lea dx,s3 mov ah,09h int 21h pop ax mov cx,0 mov dx,0 mov bx,10d b reak: 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 24 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 15th Program: Writ e 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 a gain: 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> PROG RAM NAME ABCDEFGHIJKLMNOPQRSTUVWXYZ 25 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 16th Program: Writ e an assembly program to calculate sum of series. // an assembly program for pri nt 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,30 h 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 2 1h 26 Hirdesh Singh Rajput

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 27 Hirdesh Singh Rajput

MCA (I-sem.) Laboratory file of Assembly Language Programming 17th Program: Writ e an assembly program to determine largest number out of 3 numbers. // an assemb ly program for determine largest number out of 3 numbers. .model small .stack 10 0h .data a dw ? b dw ? c dw ? l dw ? s1 db 13,10, Enter 1st no. : $ s2 db 13,10, En ter 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 28 Hirdesh Singh Rajp ut

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 su b al,30h push ax mov ax,10d 29 Hirdesh Singh Rajput

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 dis play print: mov dx,0 mov ah,02h pop dx add dl,30h int 21h loop print ret disprin t 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 30 Hirdesh Singh Rajput