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

Masm All Programes

Uploaded by

Sarthak Dhumal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Masm All Programes

Uploaded by

Sarthak Dhumal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 38

1.ADD.

ASM
data segment
num1 dd 12345678h
num2 dd 22221111h
num3 dw ?
data ends
code segment
assume cs:code ,ds:data
start:
mov ax,data
mov ds,ax
mov ax, word ptr[num1]
mov bx, word ptr[num1+2]
mov cx, word ptr[num2]
mov dx, word ptr[num2+2]
add ax,cx
add bx,dx
mov num3,ax
mov num3+2,bx
mov ah,4ch
int 21h
code ends
end start

2.ASM
data segment
num1 dw 0400h
num2 db 05h
qut db ?
rem db ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,num1
mov bl,num2
idiv bl
mov qut,al
mov rem,ah
mov ah,4ch
int 21h
code ends
end start
3.ASM
data segment
arr db 02h,01h,03h,02h,01h
res db ?
data ends
code segment
assume cs:code, ds:data
start:
mov dx,data
mov ds,dx
mov cl,04h
lea si,[arr]
lea bx,res

back: mov al,[si]


inc si
add al,[si]
mov [bx],al
inc si
inc bx
dec cl
jnz back

mov ah,4ch
int 21h
code ends
end start

ADD 8.ASM
Data segment
no1 db 25h
no2 db 23h
res dw 00h
Data ends
code segment
assume cs:code, ds:Data
Start:
Mov ax,Data
Mov ds,ax

mov al,no1
mov bl,no2
mov ah,00h

add al,bl
jnc skip
inc ah
skip:mov res,ax

And al,0f0h
mov cl,04h
ror al,cl
Add al,30h
mov ah,02h
mov dl,al
int 21h

mov al,byte ptr[res]


And al,0fH
Add al,30h

mov ah,02h
mov dl,al
int 21h

mov ah,4ch
int 21h

code ends
end start

ADD8s.ASM
data segment
num1 db 24h
num2 db 11h
num3 db ?
data ends
code segment
assume cs:code,ds:data
start:
mov dx,data
mov ds,dx
mov al,num1
mov bl,num2
add al,bl
mov num3,al
mov ah,4ch
int 21h
code ends
end start

ADD16.ASM
data segment
num1 dw 0025h
num2 dw 0050h
num3 dw ?
data ends
code segment
assume cs:code , ds:data
start:
mov cx , data
mov ds , cx
mov ax , word ptr [num1]
mov bx , word ptr [num2]
add ax , bx
mov word ptr [num3] , ax
mov ah , 4ch
int 21h
code ends
end start

ADD16.ASM
Data Segment
No1 DB 25h
No2 DB 35h
res DB 00h
Data ENDS

Code segment
Assume CS:Code, DS:Data
Start:
Mov AX,Data Data=0b60h
Mov DS,AX DS=0b60H

Mov AL,No1
Mov BL,No2

Add AL,BL
Mov res,AL

mov ah,4ch
int 21h
code ends
end start

ADD 32.ASM
data segment

num1 dd 23h
num2 dd 27h
num3 dd ?

data ends

code segment

assume cs:code,ds:data

start:

mov dx,data

mov ds,dx

mov ax,word ptr[num1]

mov bx,word ptr[num1+2]

mov cx,word ptr[num2]

mov dx,word ptr[num2+2]

add ax,cx

add bx,dx

mov word ptr[num3],ax

mov word ptr[num3+2],bx

mov ah,4ch

int 21h
code ends

end start

ADD88.ASM
data segment
num1 db 11h
num2 db 33h
num3 db ?

data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds, ax
mov al,num1
mov bl,num2
add al,bl
mov num3,al
mov ah,4ch
int 21h
code ends
end start
ADDI.ASM
data segment

num1 dw 0025h
num2 dw 0050h
num3 dw ?

data ends

code segment

assume cs:code,ds:data

start:

mov cx,data
mov ds,cx
mov ax,word ptr[num1]
mov bx,word ptr[num2]
add ax,bx
mov word ptr[num3],ax
mov ah,4ch
int 21h

code ends
end start

ARR12.ASM
DATA SEGMENT
str1 DB 'HEllo$'
str2 db 10 dup('$')
newline db 10,13, '$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

LEA DX, str1 ; load and print PROMPT


MOV AH, 09h
INT 21H

LEA DX, newline ; load and print PROMPT


MOV AH, 09h
INT 21H

MOV CX, 00H ; initialize CX


lea si,str1
lea di,str2

back:
mov al,[si]
cmp al,'$'
je next
inc cl
inc si
jmp back
next:
lea si,str1
Back1:
mov al,[si]
mov [di],al
inc si
inc di
dec cl
jnz Back1

LEA DX, str2 ; load and print PROMPT


MOV AH, 09h
INT 21H

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START

ASC.ASM
Data Segment
No2 DB 35h
No1 DB 22h
res DB 00h
Data ENDS

Code segment
Assume CS:Code, DS:Data
Start:
Mov AX,Data
Mov DS,AX
Mov AL,No1
Mov BL,No2

Add AL,BL

mov res,al

Mov ah,02h
Mov Dl,al
int 21h

mov ah,4ch
int 21h
code ends
end start

ASS12.ASM
DATA SEGMENT
DEC DB 99H
HEX DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV DX,DATA
MOV DS,DX
MOV AL,DEC
MOV AL,0FH
MOV DL,AL
MOV AL,DEC
AND AL,0F0H
MOV CL,04H
ROL AL,CL
MOV BL,0AH
MUL BL
ADD AL,DL
MOV HEX,AL
MOV AL,4CH
INT 21H
CODE ENDS
END START

BCDADD.ASM
data segment
num1 db 06H
num2 db 08H
res dw ?

data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds, ax
MOV AH,00h
mov al,num1
mov bl,num2
ADD al,bl
DAA
JNC Skip
INC AH
SKIP :MOV res, ax

mov ah,4ch
int 21h
code ends
end start

BCDSUB.ASM
data segment
num1 db 06H
num2 db 08H
res dw ?

data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds, ax
MOV AH,00h
mov al,num1
mov bl,num2
sub al,bl
DAS
SKIP :MOV res, ax

mov ah,4ch
int 21h
code ends
end start

BLCKWITHOUTSTR.ASM
;Write and execute Assembly language program for block tranfer without using string instruction.

Data segment
Arr1 DB 24h,25H,26H,27H,28H
Arr2 DB 11h,12H,13H,14H,15H
Data end

code segment
assume cs:code,ds:Data
start:
mov DX,Data
mov DS,DX
MOV ES,DX
LEA SI,Arr1
LEA DI,Arr2
Mov CL,05h

Back: mov al,[si]


mov [di],al
inc si
inc di
dec cl
jnz back

mov ah,4ch
int 21
code ends
end start
D001.ASM
DATA SEGMENT
NUM1 DW 1234H
NUM2 DW 5678H
RES DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV DX,DATA
MOV DS,DX
MOV AX,NUM1
MOV BX,NUM2
ADD AX,BX
MOV RES ,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
DEC.ASM
.MODEL SMALL
.STACK 100H

.DATA
PROMPT DB 'Enter a HEX digit : $\'
DECIMAL DB 'The equivalent Decimal digit is : $\'
CONTINUE DB 'Do you want to do it again : $\'
ILLEGAL DB 'Illegal Character - Enter 0..9 or A..F : $\'
NEXT_LINE DB 0DH,0AH,\"$\"

.CODE
MAIN PROC
MOV AX, @DATA ; initialize DS
MOV DS, AX

@START_1: ; jump label


MOV AH, 9 ; set string output function
LEA DX, PROMPT ; load and display the string PROMPT
INT 21H

@START_2: ; jump label


MOV AH, 1 ; read a character
INT 21H

MOV BL, AL ; save the character into BL

CMP BL, \"A\" ; compare BL with \"A\"


JB @SINGAL_DIGIT ; jump to label @SINGAL_DIGIT if BL<A
CMP BL, \"F\" ; compare BL with \"F\"
JA @ILLEGAL_CHARACTER ; jump to label @ILLEGAL_CHARACTER if BL>F

JMP @GREATER_THAN_NINE ; jump to label @GREATER_THAN_NINE

@SINGAL_DIGIT: ; jump label


CMP BL, \"0\" ; comapre BL with \"0\"
JB @ILLEGAL_CHARACTER ; jump to label @ILLEGAL_CHARACTER if BL<0

CMP BL, \"9\" ; compare BL with \"9\"


JA @ILLEGAL_CHARACTER ; jump to label #ILLEGAL_CHARACTER if BL>9

JMP @LESS_THAN_TEN ; jump to label @LESS_THAN_TEN

@ILLEGAL_CHARACTER: ; jump label


MOV AH, 9 ; set string output function

LEA DX, NEXT_LINE ; load and display the string NEXT_LINE


INT 21H

LEA DX, ILLEGAL ; load and display the string ILLEGAL


INT 21H

JMP @START_2 ; jump to label @START_2

@LESS_THAN_TEN: ; jump label


MOV AH, 9 ; set string output function

LEA DX, NEXT_LINE ; load and display the string NEXT_LINE


INT 21H

LEA DX, DECIMAL ; load and display the string DECIMAL


INT 21H

MOV AH, 2 ; print the contents of BL


MOV DL, BL
INT 21H

JMP @CONTINUE ; jump to label @CONTINUE

@GREATER_THAN_NINE: ; jump label


MOV AH, 9 ; set string output function

LEA DX, NEXT_LINE ; load and display the string NEXT_LINE


INT 21H

LEA DX, DECIMAL ; load and display the string DECIMAL


INT 21H

MOV AH, 2 ; display the digit 1


MOV DL, 31H
INT 21H

SUB BL, 11H ; subtract 11H from BL to find 2nd digit

MOV DL, BL ; display the 2nd digit


INT 21H

@CONTINUE: ; jump label


MOV AH, 9 ; set string output function

LEA DX, NEXT_LINE ; load and display the string NEXT_LINE


INT 21H
INT 21H

LEA DX, CONTINUE ; load and display the string CONTINUE


INT 21H

MOV AH, 1 ; read a character


INT 21H

CMP AL, \"y\" ; compare AL with \"y\"


JE @JUMP ; jump to label @JUMP if AL=y

CMP AL, \"Y\" ; compare AL with \"Y\"


JE @JUMP ; jump to label @JUMP if AL=Y

JMP @END ; jump to label @END

@JUMP: ; jump label


LEA DX, NEXT_LINE ; load and display the string NEXT_LINE
MOV AH, 9
INT 21H
INT 21H

JMP @START_1 ; jump to label @START_1

@END: ; jump label

MOV AH, 4CH ; return control to DOS


INT 21H
MAIN ENDP
END MAIN

DISP.ASM
DATA SEGMENT
str1 DB 'HEllo$'
str2 db 10 dup('$')
newline db 10,13, '$'
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

LEA DX, str1 ; load and print PROMPT


MOV AH, 09h
INT 21H

LEA DX, newline ; load and print PROMPT


MOV AH, 09h
INT 21H

MOV CX, 00H ; initialize CX


lea si,str1
lea di,str2

back:
mov al,[si]
cmp al,'$'
je next
inc cl
inc si
jmp back
next:
lea si,str1
Back1:
mov al,[si]
mov [di],al
inc si
inc di
dec cl
jnz Back1

LEA DX, str2 ; load and print PROMPT


MOV AH, 09h
INT 21H

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START
DIV16.ASM
;Write and execute Assembly language program for unsigned division of two 16/8 bit nos.

Data segment
no1 dw 2500h
no2 db 23h
que db 00h
rem db 00h
Data ends

code segment
assume cs:code, ds:Data
Start:
Mov ax,Data
Mov ds,ax

mov ax,no1
mov bl,no2

div bl
mov que,al
mov rem,ah

mov ah,4ch
int 21h

code ends
end start

DIV32.ASM
Data segment
no1 dd 2500h
no2 dw 0300h
que dw 00h
rem dw 00h
Data ends

code segment
assume cs:code, ds:Data
Start:
Mov ax,Data
Mov ds,ax

mov ax,word ptr [no1]


mov dx,word ptr [no1+2]
mov bx,no2

div bx
mov que,ax
mov rem,dx

mov ah,4ch
int 21h

code ends
end start

EVEN.ASM
;Write and execute Assembly language program for finding no of Even numbers from the given array.

DATA SEGMENT
arr1 DB 25h,20h,27h,21h,19h
msg1 db "The total Even Nos are:$"
even1 db 00H

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

MOV Cx, 05H ; initialize CX


mov bl,00h
lea si,arr1

back:mov al,[si]
ror al,01h
jc skip
inc bl
skip:inc si
loop back

mov ah,09h
lea dx,msg1
int 21h

mov even1,bl
mov dl,bl
and dl,0f0H
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h

mov dl,even1
and dl,0fH
add dl,30h
mov ah,02h
int 21h

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START
EVEN.ASM
;Write and execute Assembly language program for find whether the given no is Even or Odd .

DATA SEGMENT
no1 DB 36h
msg1 db "The given no is Even:$"
msg2 db "The given no is Odd:$"
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

back:mov al,no1
ror al,01h
jc skip
mov ah,09h
lea dx,msg1
int 21h
jmp exit
skip:mov ah,09h
lea dx,msg2
int 21h
exit:MOV AH, 4CH ; return control to DOS
INT 21H
CODE ENDS

END START
FNEG.ASM
;Write and execute Assembly language program for finding whether the -neg or +ve.

DATA SEGMENT
no1 DB -36h
msg1 db "The given no is -ve:$"
msg2 db "The given no is +ve:$"
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

back:mov al,no1
rol al,01h
jnc skip
mov ah,09h
lea dx,msg1
int 21h
jmp exit
skip:mov ah,09h
lea dx,msg2
int 21h

exit:MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START

ADD.ASM
data segment
arr1 db 10h,54h,87h,78h,43h,98h,34h,12h,87h,34h
arr2 db 54h,87h,98h,32h,09h,87h,54h,34h,98h,76h
arr3 db ?
data ends
code segment
assume cs:code,ds:data
start:
mov dx,data
mov ds,dx
mov cl,05h
lea si,arr1
lea di,arr2
lea bx,arr3

up:mov al,[si]
mov dl,[di]
add al,dl
mov[bx],al
inc si
inc di
inc bx
dec cl
jnz up
mov ah,4ch
int 21h
code ends
end start

LARGEST.ASM
;Write and execute Assembly language program for sort the given array.

DATA SEGMENT
arr1 DB 25h,20h,27h,21h,19h
msg1 db "The sorted array is:$"
msg2 db 10,13,"$"

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

MOV Cl, 05H ; initialize Cl


up1:lea si,arr1

mov ch,04H
up:mov al,[si]
inc si
cmp al,[si]
jnc skip
mov dl,[si]
mov [si],al
dec si
mov [si],dl
inc si
skip:dec ch
jnz up
dec cl
jnz up1

mov ah,09h
lea dx,msg1
int 21h

mov ah,09h
lea dx,msg2
int 21h

mov bx,05h
lea si,arr1
back:mov dl,[si]

and dl,0f0H
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h

mov dl,[si]
and dl,0fH
add dl,30h
mov ah,02h
int 21h

mov ah,09h
lea dx,msg2
int 21h
inc si
dec bx
jnz back

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START
MUL8.ASM
Data Segment
No1 Db 25h
No2 Db 05h
res Dw 0000h
Data ENDS

Code segment
Assume CS:Code, DS:Data
Start:
Mov AX,Data Data=0b60h
Mov DS,AX DS=0b60H

Mov AL,No1
mov bl,No2
mul bl
mov res,ax

mov ah,4ch
int 21h
code ends
end start
NEG.ASM
;Write and execute Assembly language program for finding no of -ve numbers from the given array.

DATA SEGMENT
arr1 DB 25h,-20h,27h,-21h,19h
msg1 db "The total +ve Nos are:$"
neg1 db 00H

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

MOV Cx, 05H ; initialize CX


mov bl,00h
lea si,arr1

back:mov al,[si]
rol al,01h
jc skip
inc bl
skip:inc si
loop back

mov ah,09h
lea dx,msg1
int 21h

mov neg1,bl
mov dl,bl
and dl,0f0H
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h

mov dl,neg1
and dl,0fH
add dl,30h
mov ah,02h
int 21h

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START
NUMONES.ASM
;Write and execute Assembly language program for finding whether the -neg or +ve.

DATA SEGMENT
no1 DB 37h
msg1 db 10,13,"The number of ones are:$"
msg2 db 10,13,"The number of zeross are:$"
ones db 00h
zeros db 00h
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

mov cx,08h
mov bl,00h ;for ones
mov bh,00h ;for zeros
mov al,no1

back:rol al,01h
jnc skip
inc bl
jmp next
skip:inc bh
next:loop back

mov ah,09h
lea dx,msg1
int 21h

mov ones,bl
mov dl,bl
and dl,0f0h
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h

mov dl,ones
and dl,0fh
add dl,30h
mov ah,02h
int 21h

mov ah,09h
lea dx,msg2
int 21h

mov zeros,bh
mov dl,bl
and dl,0f0h
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h
mov dl,zeros
and dl,0fh
add dl,30h
mov ah,02h
int 21h

exit:MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START
ODD.ASM
;Write and execute Assembly language program for finding no of oddn numbers from the given array.

DATA SEGMENT
arr1 DB 25h,20h,27h,21h,19h
msg1 db "The total Even Nos are:$"
odd1 db 00H

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

MOV Cx, 05H ; initialize CX


mov bl,00h
lea si,arr1

back:mov al,[si]
ror al,01h
jnc skip
inc bl
skip:inc si
loop back

mov ah,09h
lea dx,msg1
int 21h

mov odd1,bl
mov dl,bl
and dl,0f0H
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h

mov dl,odd1
and dl,0fH
add dl,30h
mov ah,02h
int 21h

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START
PR11.ASM
data segment
srcstr db 'computer$'
strrev db 50 dup(0)
len db ?
counts db 'src string :'s',10,13
data ends
code segment
assume cs:code,ds:data
mov dx,data
mov ds,data
back:lea si,srcstr
mov al,[si]
cmp al $

je exit
inc si
inc counts
jmp back
exit:

back2:lea di,strrev
dec counts
jz back1
mov al,[si]
mov [di],al
jmp back2

back1:
mov ah,09h
mov dx,meg1
int 21h

mov ah 09h
mov dx,meg2
int 21h

mov ah 09h
mov dx,strrev
int 21h

end data

WRITE A PROGRAMME DIVISION OF


32/16 BIT UNSIGNED NO
***********************************************
PRACTICAL NAME= WRITE A PROGRAMME DIVISION OF
32/16 BIT UNSIGNED NO

ROLL NO = 07

BATCH =A

*****************************************

DATA SEGMENT
NO1 DD 00000020H
NO2 DW 0010H

QUE DW ?
REM DW ?
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA

START:

MOV DX,DATA

MOV DS,DX

MOV BX,NO2

MOV AX,WORD PTR[NO1]

MOV DX,WORD PTR[NO1+2]

DIV BX

MOV QUE,AX

MOV REM,DX

MOV AH,4CH

INT 21H

CODE ENDS

END START

**********************************************

Program terminated normally


-e 0006
0B44:0006 02.
-e 0008
0B44:0008 00.

*********************************************
PST2.ASM
data segment
num1 dw -0300h
num2 db 10h
qut db ?
rem db ?

data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,num1
mov bl,num2
idiv bl
mov qut,al
mov rem,ah
mov ah,4ch
int 21h

code ends

end start

Title-A prgram to add 2 32-bit numbers.


Title-A prgram to add 2 32-bit numbers.
Class-SYCM , Batch-A
Roll No.5
Date-15/3/2011
-----------------------------------------------------------------------------------------
Input
-----------------------------------------------------------------------------------------
Data Segment
No1 DD 12345678H
No2 DD 10000000H
Res DD ?
Data Ends
Code Segment
Assume CS:Code,DS:Data
Start:
MOV AX,Data
MOV DS,AX
MOV AX,word ptr[No1]
MOV BX,word ptr[No1+2]
MOV CX,word ptr[No2]
MOV DX,word ptr[No2+2]
ADD AX,CX
ADD BX,DX
MOV word ptr[res],AX
MOV word ptr[res+2],BX

MOV AH,4CH
INT 21H
Code Ends
End Start
REVSTR.ASM
DATA SEGMENT
str1 DB "String$"
rev dB 10 dup('$')
msg1 db "The revers String is:$"
msg2 db 10,13,"$"
len1 db 00h

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX
mov es,ax

MOV Cl, 00H ; initialize CX


lea si,str1
lea di,rev

call len11

mov len1,cl
up:dec si
MOV al,[si]
mov [di],al
inc di
dec cl
jnz up

lea dx,str1
Mov ah,09h
int 21h

lea dx,msg2
Mov ah,09h
int 21h

lea dx,msg1
Mov ah,09h
int 21h

lea dx,rev
Mov ah,09h
int 21h

MOV AH, 4CH ; return control to DOS


INT 21H

len11 proc
back:
mov al,[si]
cmp al,'$'
je next
inc si
inc cl
jmp back
next:ret
len11 endp

CODE ENDS

END START

;cm1:1,11,12,15,23,28,29,35,43,44,45,55
;cm2:1,2,3,4,6,7,13,15,17,20,25,27,28,31,37,44,50,51,54,56,61,66,69,71,73,74

DAA.ASM
data segment
no1 dd 20,34h
no2 dd 47h,56h
res dd ?
data ends
code segment
assume cs:code,ds:data
start:
mov dx,data
mov ds,dx
mov ax,no1
mov bx,no2
add ax,bx
daa
mov result,ax
mov ah,4ch
int 21h
ends data
start end

SIGNED MUL 16.ASM


;Write and execute Assembly language program for signed multiplication of two 16 bit nos.
Data Segment
No1 Dw -25h
No2 Dw -05h
res DD 0000h
Data ENDS

Code segment
Assume CS:Code, DS:Data
Start:
Mov AX,Data
Mov DS,AX

Mov Ax,No1
mov bx,No2
imul bx

mov word ptr[res],ax


mov word ptr[res+2],dx

mov ah,4ch
int 21h
code ends
end start

SMALL NO.ASM
;Write and execute Assembly language program for finding small number from the given array.

DATA SEGMENT
arr1 DB 25h,20h,27h,21h,19h
small db 00H

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

MOV Cx, 04H ; initialize CX


lea si,arr1
mov al,[si]

back:
inc si
cmp al,[si]
jc skip
mov al,[si]
skip:loop back

mov small,al
mov dl,al
and dl,0f0H
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h

mov dl,small
and dl,0fH
add dl,30h
mov ah,02h
int 21h

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START
SORT.ASM
;Write and execute Assembly language program for finding large number from the given array.

DATA SEGMENT
arr1 DB 25h,20h,27h,21h,19h
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

MOV Cx, 04H ; initialize CX


lea si,arr1
mov al,[si]

back:
inc si
cmp al,[si]
jnc skip
mov al,[si]
skip:loop back

mov ah,09h
lea dx,msg1
int 21h
mov large,al
mov dl,al
and dl,0f0H
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h

mov dl,large
and dl,0fH
add dl,30h
mov ah,02h
int 21h

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START
SORTING.ASM
;Write and execute Assembly language program for sort the given array in descending order .

DATA SEGMENT
arr1 DB 25h,20h,27h,21h,19h
msg1 db "The sorted array is:$"
msg2 db 10,13,"$"

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

MOV Cl, 05H ; initialize Cl

up1:lea si,arr1

mov ch,04H

up:mov al,[si]
inc si
cmp al,[si]
jnc skip
mov dl,[si]
mov [si],al
dec si
mov [si],dl
inc si
skip:dec ch
jnz up
dec cl
jnz up1

mov ah,09h
lea dx,msg1
int 21h

mov ah,09h
lea dx,msg2
int 21h

mov bx,05h
lea si,arr1
back:mov dl,[si]

and dl,0f0H
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h

mov dl,[si]
and dl,0fH
add dl,30h
mov ah,02h
int 21h

mov ah,09h
lea dx,msg2
int 21h
inc si
dec bx
jnz back

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS
END START
SORTING ASC.ASM
;Write and execute Assembly language program for sort the given array in ascending order .

DATA SEGMENT
arr1 DB 25h,20h,27h,21h,19h
msg1 db "The sorted array is:$"
msg2 db 10,13,"$"

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX

MOV Cl, 05H ; initialize Cl

up1:lea si,arr1

mov ch,04H

up:mov al,[si]
inc si
cmp al,[si]
jnc skip
mov dl,[si]
mov [si],al
dec si
mov [si],dl
inc si
skip:dec ch
jnz up
dec cl
jnz up1

mov ah,09h
lea dx,msg1
int 21h

mov ah,09h
lea dx,msg2
int 21h

mov bx,05h
lea si,arr1
back:mov dl,[si]

and dl,0f0H
mov cl,04h
ror dl,cl
add dl,30h
mov ah,02h
int 21h

mov dl,[si]
and dl,0fH
add dl,30h
mov ah,02h
int 21h

mov ah,09h
lea dx,msg2
int 21h
inc si
dec bx
jnz back

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START
STR.ASM
DATA SEGMENT
STR1 DB "ENTER FIRST STRING HERE ->$"
STR2 DB "ENTER SECOND STRING HERE ->$"
STR11 DB "FIRST STRING : ->$"
STR22 DB "SECOND STRING: ->$"

INSTR1 DB 20 DUP("$")
INSTR2 DB 20 DUP("$")
NEWLINE DB 10,13,"$"
N DB ?
S DB ?
MSG1 DB "BOTH STRING ARE SAME$"
MSG2 DB "BOTH STRING ARE DIFFERENT$"

DATA ENDS

CODE SEGMENT

ASSUME DS:DATA,CS:CODE
START:

MOV AX,DATA
MOV DS,AX

LEA SI,INSTR1
LEA DI,INSTR2

;GET STRING
MOV AH,09H
LEA DX,STR1
INT 21H

MOV AH,0AH
MOV DX,SI
INT 21H

MOV AH,09H
LEA DX,NEWLINE
INT 21H
MOV AH,09H
LEA DX,STR2
INT 21H

MOV AH,0AH
MOV DX,DI
INT 21H

MOV AH,09H
LEA DX,NEWLINE
INT 21H

;PRINT THE STRING

MOV AH,09H
LEA DX,STR11
INT 21H

MOV AH,09H
LEA DX,INSTR1+2
INT 21H

MOV AH,09H
LEA DX,NEWLINE
INT 21H

MOV AH,09H
LEA DX,STR22
INT 21H

MOV AH,09H
LEA DX,INSTR2+2
INT 21H

MOV AH,09H
LEA DX,NEWLINE
INT 21H

;STRING COMPARISION
MOV BX,00

MOV BL,INSTR1+1
MOV BH,INSTR2+1

CMP BL,BH
JNE L1

ADD SI,2
ADD DI,2

L2:MOV BL,BYTE PTR[SI]


CMP BYTE PTR[DI],BL
JNE L1
INC SI
INC DI
CMP BYTE PTR[DI],"$"
JNE L2

MOV AH,09H
LEA DX,MSG1
INT 21H

JMP L5

L1:MOV AH,09H
LEA DX,MSG2
INT 21H

L5:
MOV AH,09H
LEA DX,NEWLINE
INT 21H

MOV AH,4CH
INT 21H

CODE ENDS
END START
STR COMPARE.ASM
;Write and execute Assembly language program for compare two string using string instruction.

DATA SEGMENT
str1 DB "Hello$"
str2 dB "Welcome$"
msg1 db 10,13, "Strings are Equal:$"
msg2 db 10,13,"Strings are not equal:$"
len1 db 00h
len2 db 00h
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX
mov ES,AX ; initialize ES

MOV cx, 00H ; initialize CX=0000


lea si,str1 ;load the Effective address of 1st character of str1 into SI
lea di,str2 ;load the Effective address of 1st character of str2 into DI

back:
mov al,[si]
cmp al,'$'
je next
inc si
inc cl
jmp back

next:mov len1,cl
lea si, str1
cld
repe cmpsb
jne next1
lea dx,msg1
Mov ah,09h
int 21h
jmp exit

next1:lea dx,msg2
Mov ah,09h
int 21h

exit:MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START

STR COMPARE1.ASM
;Write and execute Assembly language program for compare two string using string instruction.

Data Segment
str1 db "Hello$"
str2 db "Hello$"
msg1 db 10,13,"Strings are Equal:$"
msg2 db 10,13,"Strings are not Equal:$"

Data Ends
Code segment
assume cs:code, Ds:Data
Start:
Mov dx,Data
mov ds,dx
mov es,dx

lea si,str1
lea di,str2
mov cx,00h

back: mov al,[si]


cmp al,'$'
je next
inc si
inc cx
jmp back

next:lea si,str1
cld
repe cmpsb
jne next1
mov ah,09h
lea dx,msg1
int 21h
jmp exit
next1:
mov ah,09h
lea dx,msg2
int 21h
exit:mov ah,4ch
int 21h
code ends
end start

STR CON.ASM
DATA SEGMENT
str1 DB "String$"
str2 dB "Hello$"
Cont db 25 dup('$')
msg1 db 10,13, "$"

len1 db 00h

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX
mov es,ax

MOV Cl, 00H ; initialize CX


lea si,str1
lea di,str2
lea bx,cont
back:
mov al,[si]
cmp al,'$'
je next
mov al,[si]
mov [bx],al
inc bx
inc si
jmp back

next:mov al,[di]
cmp al,'$'
je next1
mov al,[di]
mov [bx],al
inc bx
inc di
jmp next

next1:
lea dx,str1
Mov ah,09h
int 21h

lea dx,msg1
Mov ah,09h
int 21h

lea dx,str2
Mov ah,09h
int 21h

lea dx,msg1
Mov ah,09h
int 21h

lea dx,cont
Mov ah,09h
int 21h

exit:MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START

STRCPYT.ASM
DATA SEGMENT
str1 DB "String$"
str2 dB 10 dup('$')
msg1 db "String is coppied:$"
msg2 db 10,13,"$"
len1 db 00h

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX
mov es,ax

MOV Cl, 00H ; initialize CX


lea si,str1
lea di,str2

back:
mov al,[si]
cmp al,'$'
je next
inc si
inc cl
jmp back

next:mov len1,cl
mov si, offset str1
cld
rep movsb

lea dx,str1
Mov ah,09h
int 21h

lea dx,msg2
Mov ah,09h
int 21h

lea dx,msg1
Mov ah,09h
int 21h

lea dx,str2
Mov ah,09h
int 21h

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START

SRE LEN.ASM
DATA SEGMENT
str1 DB "String$"
str2 dB 10 dup('$')
msg1 db "String is coppied:$"
msg2 db 10,13,"$"
len1 db 00h

DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA ; initialize DS
MOV DS, AX
mov es,ax

MOV Cl, 00H ; initialize CX


lea si,str1
lea di,str2

back:
mov al,[si]
cmp al,'$'
je next
inc si
inc cl
jmp back

next:mov len1,cl
mov si, offset str1
back1:
mov al,[si]
mov [di],al
inc si
inc di
dec cl
jnz back1

lea dx,str1
Mov ah,09h
int 21h

lea dx,msg2
Mov ah,09h
int 21h

lea dx,msg1
Mov ah,09h
int 21h

lea dx,str2
Mov ah,09h
int 21h

MOV AH, 4CH ; return control to DOS


INT 21H
CODE ENDS

END START

BCD.ASM
data segment
num1 db 0012h
num2 db 0013h
res db ?
data ends

code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov al,num1
mov bl,num2
add al,bl
daa
mov res,al
mov ah,4ch
int 21h
code ends
end start
PTR
data segment
num1 dd 11253467h
num2 dd 00130000h
res dd ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,word ptr[num1]
mov bx,word ptr[num1+2]
mov cx,word ptr[num2]
mov dx,word ptr[num2+2]
add ax,cx
add bx,dx
mov word ptr[res],ax
mov word ptr[res+2],bx
mov ah,4ch
int 21h
code ends
end start

You might also like