Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

1.Addi on of two 8-bit nos.

.model small
.data
Num1 db 10h
Num2 db 20h
Res db ?
.code
Mov ax,@data
Mov ds,ax
Mov al,num1
Mov bl,num2
Add al,bl
Mov res,al
Int o3
Ends
End
2. Addi on of two 16-bit nos.
.model small
.data
Num1 dw 10h
Num2 dw 20h
Res db ?
.code
Mov ax,@data
Mov ds,ax
Mov ax,num1
Mov bx,num2
Add ax,bx
Mov res,ax
Int o3
Ends
End
3. Subtrac on of two 8-bit nos.
.model small

.data

num1 db 22h

num2 db 11h

res db ?

.code

mov ax,@data

mov ds,ax

mov al,num1

mov bl,num2

sub al,bl

mov res,al

int 03

ends

end

4. Subtrac on of two 16-bit nos.


.model small

.data

num1 dw 2222h

num2 dw 1111h

res dw ?

.code

mov ax,@data
mov ds,ax

mov ax,num1

mov bx,num2

sub ax,bx

mov res,ax

int 03

ends

end

5. Mul plica on of two 8-bit nos.


.model small

.data

num1 db 22h

num2 db 11h

res dw ?

.code

mov ax,@data

mov ds,ax

mov al,num1

mov bl,num2

mul bl

mov res,ax

int 03

ends

end

6. Mul plica on of two 16-bit nos.


.model small

.data

num1 dw 22h

num2 dw 11h

res dd ?

.code
mov ax,@data

mov ds,ax

mov ax,num1

mov bx,num2

mul bx

mov word ptr res,ax

mov word ptr res+2,dx

int 03

ends

end

7. Division of 16-bit by 8-bit nos.


.model small

.data

d1 dw 0428h

d2 db 0Ah

quo db ?

rem db ?

.code

mov ax,@data

mov ds,ax

mov ax,d1

mov bl,d2

div bl

mov quo,al

mov rem,ah

int 03

ends

end

8. Addi on of two 8-bit BCD nos.


.model small
.data
Num1 db 10
Num2 db 20
Res db ?
.code
Mov ax,@data
Mov ds,ax
Mov al,num1
Mov bl,num2
Add al,bl
daa
Mov res,al
Int o3
Ends
End
9. Subtrac on of two 8-bit BCD nos.
.model small
.data
Num1 db 20
Num2 db 10
Res db ?
.code
Mov ax,@data
Mov ds,ax
Mov al,num1
Mov bl,num2
sub al,bl
Das
Mov res,al
Int o3
Ends
End
10. Block transfer to five 8-bit nos.
.model small

.data

num1 db 11h,22h,33h,44h,55h

num2 db 5 dup(0)

.code

mov ax,@data

mov ds,ax

mov si,offset num1

mov di,offset num2

mov cx,05h

up:

mov al,[si]

mov [di],al

inc si

inc di

loop up

int 03

ends

end

11. Block transfer to five 16-bit nos.


.model small

.data

num1 dw 1111h,2222h,3333h,4444h,5555h
num2 dw 5 dup(0)

.code

mov ax,@data

mov ds,ax

mov si,offset num1

mov di,offset num2

mov cx,05h

up:

mov ax,[si]

mov [di],ax

inc si

inc si

inc di

inc di

loop up

int 03

ends

end

12. Sum of series of five 8-bit nos.


.model small

.data

n1 db 11h,22h,33h,44h,55h

sum db 00h

carry db 00h

.code

mov ax,@data

mov ds,ax

mov si,offset n1

mov cx,05h

up:
mov al,[si]

add sum,al

inc si

jnc exit

inc carry

exit:

loop up

int 03

ends

end

13. Sum of series of five 16-bit nos.


.model small

.data

n1 dw 1111h,2222h,3333h,4444h,5555h

sum dw 00h

carry db 00h

.code

mov ax,@data

mov ds,ax

mov si,offset n1

mov cx,05h

up:

mov ax,[si]

add sum,ax

inc si

inc si

jnc exit

inc carry

exit:

loop up

int 03
ends

end

14. Sum of series of five 8-bit BCD nos.


.model small

.data

n1 db 11,22,33,44,55

sum db 00

carry db 00h

.code

mov ax,@data

mov ds,ax

mov si,offset n1

mov cx,05h

up:

mov al,[si]

add sum,al

daa

inc si

jnc exit

inc carry

exit:

loop up

int 03

ends

end

15. Smallest no. from array.


.model small
.data
n1 db 10h,02h,33h,01h,55h
sm db 00h
.code
mov ax,@data
mov ds,ax
mov si,offset n1
mov al,[si]
mov sm,al
mov cl,05h
up:
inc si
mov al,[si]
cmp sm,al
jnc exit
mov sm,al
exit:
loop up
int 03
ends
end
16. Largest no. from array.
.model small
.data
n1 db 10h,02h,33h,01h,55h
large db 00h
.code
mov ax,@data
mov ds,ax
mov si,offset n1
mov al,[si]
mov large,al
mov cl,05h
up:
inc si
mov al,[si]
cmp large,al
jc exit
mov large,al
exit:
loop up
int 03
ends
end
17. Arrange the nos in assending order.
.model small
.data
num db 10h,01h,03h,45h,23h
.code
mov ax,@data
mov ds,ax
mov bx,04h
up:
mov si,offset num
mov cx,04h
up1:
mov al,[si]
cmp al,[si+1]
jc exit
xchg al,[si+1]
xchg al,[si]
exit:
inc si
loop up1
dec bx
jnz up
int 3
ends
end
18. 18) Arrange the nos in decending order.
.model small
.data
num db 10h,01h,03h,45h,23h
.code
mov ax,@data
mov ds,ax
mov bx,04h
up:
mov si,offset num
mov cx,04h
up1:
mov al,[si]
cmp al,[si+1]
jnc exit
xchg al,[si+1]
xchg al,[si]
exit:
inc si
loop up1
dec bx
jnz up
int 3
ends
end
19. Check the no. is posi ve or nege ve.
.model small
.data
num1 db 22h
msg1 db 'number is posi ve$'
msg2 db 'number is nega ve$'
.code
mov ax,@data
mov ds,ax
shl al,01h
jc exit
mov ah,09h
lea dx,msg1
int 21h
jmp exit1
exit:
mov ah,09h
lea dx,msg2
int 21h
exit1:
ends
end
20. Count posi ve and nege ve nos from an array.
.model small
.data
num1 db -10h,-11h,20h,33h,45h,-20h,34h,-48h,32h,-45h
p db 00h
n db 00h
.code
mov ax,@data
mov ds,ax
mov si,offset num1
mov cx,0ah
up:
mov al,[si]
shl al,01h
jc exit
inc p
jmp exit1
exit:
inc n
exit1:
inc si
loop up
int 03
ends
end
21. Check the no. is even or odd.
.model small
.data
num1 db 07h
msg1 db 'number is odd$'
msg2 db 'number is even$'
.code
mov ax,@data
mov ds,ax
mov al,num1
rcl al,1
jc exit
mov ah,09h
lea dx,msg2
int 21h
jmp exit1
exit:
mov ah,09h
lea dx,msg1
int 21h
exit1:
end
ends
22. Count even and odd nos from an array.
.model small
.data
num1 db 10h,11h,20h,33h,45h,32h,46h,29h,57,90h
o db 00h
e db 00h
.code
mov ax,@data
mov ds,ax
mov si,offset num1
mov cx,0ah
up:
mov al,[si]
shr al,01h
jc exit
inc e
jmp exit1
exit:
inc o
exit1:
inc si
loop up
int 3
ends
end
23) Count no of 1's and 0's from a 8-bit no.
.model small
.data
num1 db 0Ah
o db 00h
z db 00h
.code
mov ax,@data
mov ds,ax
mov al,num1
mov cx,08h
up:
sal al,01h
jc exit
inc z
jmp exit1
exit:
inc o
exit1:
loop up
int 3
ends
end
24) Count no of 1's and 0's from a 16-bit no.
.model small
.data
num1 dw 1010h
o db 00h
z db 00h
.code
mov ax,@data
mov ds,ax
mov ax,num1
mov cx,10h
up:
sal ax,01h
jc exit
inc z
jmp exit1
exit:
inc o
exit1:
loop up
int 3
ends
end
25) Find the length of a String.
.model small
.data
str1 db 'micro$'
str2 db 'sifgfe$'
l1 db 00h
l2 db 00h
.code
mov ax,@data
mov ds,ax
mov si,offset str1
up:
mov al,[si]
cmp al,'$'
je exit
inc l1
inc si
loop up
exit:
mov si,offset str2
up1:
mov al,[si]
cmp al,'$'
je exit1
inc l2
inc si
loop up1
exit1:
int 3
ends
end
26) Concatenate two strings.
.model small
.data
str1 db 'micro$'
str2 db 'processor$'
str3 db ?
.code
mov ax, @data
mov ds, ax
mov si, offset str1
mov di, offset str3
up:
mov al, [si]
cmp al, '$'
je exit
mov [di], al
inc si
inc di
loop up
exit:
mov si, offset str2
up1:
mov al, [si]
cmp al, '$'
je exit1
mov [di], al
inc si
inc di
loop up1
exit1:
mov al, '$'
mov [di], al
int 3
ends
end
27) Check wheather given string is a Pallindrome or not.
.model small
.data
str1 db 'racecar$'
msg1 db 'String is Palindrome$'
msg2 db 'String is not Palindrome$'
l dw 0000h
str2 db ?
.code
mov ax, @data
mov ds, ax
mov si, offset str1
up:
mov al, [si]
cmp al, '$'
je exit
inc l
inc si

loop up
exit:
dec si
mov di, offset str2
mov cx, l
up1:
mov al, [si]
mov [di], al
dec si
inc di
loop up1
mov si, offset str1
mov di, offset str2
mov cx, l
up2:
mov al, [si]
cmp al, [di]
jne exit1
loop up2
mov ah, 09h
lea dx, msg1
int 21h
jmp exit2
exit1:
mov ah, 09h
lea dx, msg2
int 21h
exit2:
end

ends

28) Compare two strings.


.model small
.data
str1 db 'micro$'
str2 db 'microprocessor$'
l1 dw 0000h

l2 dw 0000h
msg1 db 'Strings are equal$'
msg2 db 'Strings are not equal$'
.code
mov ax, @data
mov ds, ax
mov si, offset str1
up:
mov al, [si]
cmp al, '$'
je exit
inc l1
inc si
loop up
exit:
mov si, offset str2
up1:
mov al, [si]
cmp al, '$'
je exit1
inc l2
inc si

loop up1
exit1:
mov ax, l1
cmp ax, l2
jne exit2
mov si, offset str1
mov di, offset str2
mov cx, l1
up2:
mov al, [si]
cmp al, [di]
jne exit2
inc si
inc di
loop up2
mov ah, 09h
lea dx, msg1
int 21h
jmp exit3
exit2:
mov ah, 09h
lea dx, msg2
int 21h
exit3:
end
ends
29) Find Reverse of a String
.model small
.data
str1 db 'micro$'
l dw 0000h
str2 db ?
.code
mov ax, @data
mov ds, ax
mov si, offset str1
up:
mov al, [si]
cmp al, '$'
je exit
inc l
inc si
loop up
exit:
dec si
mov di, offset str2
mov cx, l
up1:
mov al, [si]
mov [di], al
dec si
inc di
loop up1
int 3
ends end

You might also like