Professional Documents
Culture Documents
Skip To Content Skip To Navigation Log in Contact Us Report A Bug
Skip To Content Skip To Navigation Log in Contact Us Report A Bug
3) Processor Interrupt - Traps and 10 Software Interrupts (12 to Skip to content Skip to navigation
Log In
Contact Us
Report a Bug
Top of Form
w eakAND Search
Search:
Bottom of Form
Connexions
Home
Selected: Content
Lenses
About Us
Help
MyCNX
Navigation
Recently Viewed
Download
x
Download module as:
EPUB is an electronic book format that can be read on a variety of mobile devices.
For detailed instructions on how to download this content's EPUB to your specific
device, click the "(what's this?)" link.
Reuse / Edit
Module:
If you have permission to edit this content, using the "Reuse / Edit" action will allow
you to check the content out into your Personal Workspace or a shared Workgroup
and then make your edits.
Derive a copy
If you don't have permission to edit the content, you can still use "Reuse / Edit" to
adapt the content by creating a derived copy of it and then editing and publishing
the copy.
Add to a lens
Definition of a lens
Lenses
A lens is a custom view of the content in the repository. You can think of it as a
fancy kind of list that will let you see content through the eyes of organizations and
people you trust.
What is in a lens?
Lens makers point to materials (modules and collections), creating a guide that
includes their own comments and descriptive tags about the content.
Tags are descriptors added by lens makers to help label content, attaching a
vocabulary that is meaningful in the context of the lens.
Add to Favorites
My Favorites Login
Required
(What is My Favorites?)
'My Favorites' is a special kind of lens which you can use to bookmark modules and
collections. 'My Favorites' can only be seen by you, and collections saved in 'My
Favorites' can remember the last module you were on. You need an account to use
'My Favorites'.
Microprocessor(8086) Lab
Ratings
Ratings allow you to judge the quality of modules. If other users have ranked the
module then its average rating is displayed below. Ratings are calculated on a scale
from one star (Poor) to five stars (Excellent).
Hover over the star that corresponds to the rating you wish to assign. Click on the
star to add your rating. Your rating should be based on the quality of the content.
You must have an account and be logged in to rate content.
PoorFairOKGoodExcellent
(1 ratings)(Login required)
Summary: This module contains the programs involving Data transfer instructions,
Arithmetic and logical instructions, string manipulation instructions etc
Program:
.model small
.data
Num dw 4321h
.code
Mov ax,@data
Mov ds,ax
Mov bx,1000h
Mov ah,4ch
Int 21h
End
Output:
Ax=1234h
Bx=1234h
Ax=4321h…..
overlap
.model small
.data
d1 db 1,2,3,4,5
d2 db 10 dup(0)
.code
mov ds,ax
inc si ;Increment si
inc di ;Increment di
int 21h
end
d1 d2
01
02
03
04
05
Table
1
01
02
03
04
05
Table
2
3. Program to transfer a block of data with overlap
.model small
.data
d1 db 1,2,3,4,5
d2 db 10 dup(0)
.code
mov ds,ax
inc si ;Increment si
inc di ;Increment di
INC di ;Increment di
inc si ;Increment si
int 21h
end
(with overlap)
01
02
03
04
05
Table
3
01
02
03
04
05
Table
4
01
02
01
02
03
04
05
Table
5
4. write an ALP to interchange 2 blocks of data
.model small
.data
d1 db 1,2,3,4,5
d2 db 22h,33h,44h,55h,66h
.code
mov ds,ax
mov[si],bl ;Move bl to d1
inc si ;Increment si
inc di ;Increment di
int 21h
end
01
02
03
04
05
Table
6
11
22
33
44
55
Table
7
d1 d2 d1 d2
01
02
03
04
05
Table
8
11
22
33
44
55
Table
9
Before block exchange After block exchange
.model small
.data
n1 dw 1111h,2222h,3333h,4444h,0ffffh
n2 dw 02 dup(0)
.code
mov ds,ax
int 21h
end
I/p:1111h,2222h,3333h,4444h,0ffffh
o/p:1aaa9h
numbers.
.model small
.data
d1 dd 0f2222222h
d2 dd 33333333h
d3 dd 10 dup(0)
.code
mov ds,ax
;by bx
inc si ;Increment si
inc di ;Increment di
dec bx ;decrement bx
dec cx ;Decrement cx
end
Output:125555555h
.model small
.data
d1 dq 1234567812345678h
d2 dq 1234567812345678h
res db 09 dup(0)
.code
mov ds,ax
adc al,[di] ;Add with carry to the LS byte of the ;second number
dec bx ;Decrement bx
inc si ;Increment si
inc di ;Increment di
int 21h
end
Input: 1234567812345678h,1234567812345678h
Output:2468ACF02468ACF0H
.model small
.data
num dd 12345678h
num1 dw 2345h
res dw 02 dup(0)
.code
mov ds,ax
div bx ;dx:ax/bx
int 21h
end
Output:Quotient:8422h, Remainder:134Eh
.model small
.data
array dw 1111h,2222h,8567h,4589h,5555h
res dw 02 dup(0)
.code
mov ax,@data
jnc below ;if 1st number>2nd number compare 1st with ;3rd number and so on.
mov ax,[bx+2]
below:inc bx
inc bx
dec cx
end
Input: 1111h,2222h,8567h,4589h,5555h
.model small
.data
n1 dw 0ffffh,5555h,3333h,7777h
count dw 04h
.code
mov ds,ax
dec bx
inc si
inc si
mov n1[si-2],ax
dec bx
jnz l2 ;all the iterations over?
mov ah,4ch
int 21h
end
.model small
.data
string db "bmscollege$"
enter db "j"
char db 02 dup(0)
.code
mov ds,ax
mov es,ax
dec cl
jnz up
nfound:lea dx,msg1 ;display, char not found
mov ah,09h
int 21h
jmp end1
mov ah,09h
int 21h
int 21h
end
.model small
.data
no dw 08h
res dw 02 dup(0)
.code
mov ds,ax
mov bx,no
jmp up
down:mov res,dx
mov res+2,ax
int 21h
end
I/P=08h
O/P=9D80h
12. Program to check whether the given data byte is positive or negative
.model small
.data
n1 db 09H
.code
mov ds,ax
mov al,n1
mov dx,offset n3
mov ah,09h
int 21h
jmp end1
d1:mov dx,offset n2 ;Else display the no is negative
mov ah,09h
int 21h
end1:mov ah,4ch
int 21h
end
Input:09h
Input:0ffh
.model small
.data
n1 db 0feH
n4 db 04 dup(0)
.code
mov ds,ax
mov ah,00h
mov bl,02h
div bl ;divide by 2
int 21h
mov ah,09h
int 21h
int 21h
end
Input:0feh
Input:09h
.model small
.data
num dw 4421h
.code
mov ds,ax
mov ah,09h
int 21h
jmp last
pali:mov ah,09h
int 21h
int 21h
end
15. Program to check whether the given data word is a nibble wise palindrome
.model small
.data
num dw 8448h
.code
mov ds,ax
mov ax,num ;Move number to ax
dec cl ;Decrement cl
mov ah,09h
lea dx,msg2
int 21h
lea dx,msg1
int 21h
int 21h
end
.model small
.data
;N1 db ‘9’
;N2 db ‘9’
N1 db ‘5’
N2 db ‘8’
N3 db 02 dup(0)
.code
Mov ds,ax
Push ax
Mov ah,02h
Int 21h
Pop ax
Mov ah,02h
Int 21h
Int 21h
End
Input : N1=’9’
N2=’9’
Output: 18
Input: N1 = ‘5’
N2 = ‘8’
Output: 13
.model small
.data
num db 35h
;num db 0AAh
res db 2 dup(0)
.code
Mov ax,@data
Mov cl,04h
Jc d1
D1:add al,30h
Mov [si],al
Mov al,num
D2:add al,30h
Mov [si+1],al ;store the result in memory
Int 21h
End
Input:35h
[si+1]
Input:0AAh
[si+1]
.model small
.data
D1 db 99h
;D1 db 85h
D2 db 02 dup(0)
.code
Mov ax,@data
Mov cl,04h
Mov bl,al
Mov al,0ah
Int 21h
End
Input : 99
Output: 63h
Input : 85
Output: 55h
.model small
.data
num db 0ffh
;num db 63h
res db 03 dup(0)
.code
Mov ax,@data
Mov bl,64h
Lea si,res
Mov [si],al ;move the quotient to [si]
mov bl,0ah
div bl ;divide ax by bl
int 21h
end
Input :0ffh
Input :063h
.model small
.data
n3 db 0fh
.code
mov ax,@data
mov dl,00h
mov bl,05h
mov al, n3 ;if 1st three MSBs are non-zero, move the ;number to al
mov ah,09h
int 21h
int 21h
int 21h
end
Input:0fh
Input:09h
.stack 64
.data
;num dw 05h,02h
num dw 09h,2dh
lcm dw 2 dup(0)
.code
mov ax,@data
mov num,ax
mov num+2,bx
push dx
div bx ;divide ax by bx
je store
pop dx
pop ax
add ax,num
jnc no_increment
inc dx
pop lcm
mov ah,4ch
int 21h
end
Input:05h, 02h
Output:0ah
Input:
.model small
.data
num dw 1bh,09h
Gcd dw ?
.code
Mov ax,@data
Again:cmp ax,bx ;
Je exit
Jb down
Divaxbx:mov dx,0
Div bx
Cmp dx,0
Je exit
Mov ax,dx
Jmp again
Down:xchg ax,bx
Jmp divaxbx
Exit:mov gcd,bx
Mov gcd+2,ax
Mov ah,4ch
Int 21h
End
23. Program to divide a packed bcd number by an unpacked bcd number and
display the quotient and remainder on the screen
.model small
.data
N1 db 6
N2 db 7
N3 db 02 dup(0)
.code
Mov ax,@data
Mov ds,ax
Mov ah,n1
Mov al,n2
mov ch,09h
Aad
div ch
Or ax,3030h
Push ax
Mov dl,ah
Mov ah,02h
Int 21h
mov ah,02h
int 21h
pop ax
Mov dl,al
Mov ah,02h
Int 21h
Mov ah,4ch
Int 21h
End
Input:6 and 7
24.Program to multiply two unpacked BCD numbers and display the result
.model small
.data
N1 db 9
N2 db 5
N3 db 02 dup(0)
.code
Mov ax,@data
Mov ds,ax
Mov al,n1
Mov bl,n2
mul bl
Aam
Or ax,3030h
Push ax
Mov dl,ah
Mov ah,02h
Int 21h
pop ax
Mov dl,al
Mov ah,02h
Int 21h
Mov ah,4ch
Int 21h
End
.model small
.data
num1 dd 0ff0aff0h
num2 dd 03304002h
res dq 00h
.stack 100h
.code
Mov ax,@data
Mov ds,ax
Lea si,num1
Lea di,num2
Lea bx,res
clc
mov ax,[si]
mov[bx],ax
mov cx,dx
mov ax[si+2]
add ax,cx
adc dx,00h
push dx
push ax
mov ax,[si]
pop cx
add ax,cx
adc dx,00h
mov[bx+2],ax
mov cx,dx
mov ax,[si+2]
add ax,cx
adc dx,00h
pop cx
add ax,cx
adc dx,00h
mov[bx+4],ax
mov[bx+6],dx
mov ah,4ch
int 21h
end
Input:
Num1:0ff0aff0h
Num2:03304002h
Output:32d32d18dd5fe0h
.model small
.data
num db 0ffh
res db 04 dup(0)
.code
mov ax,@data
mov ds,ax
mov ah,00h
mov al,num
mov bl,al
mul bl
lea si,res
mov[si],ah
mov[si+1],al
mov ch,02
up:mov dl,[si]
and dl,0f0h
mov cl,04h
ror dl,cl
cmp dl,0ah
jb down
add dl,07h
down:add dl,30h
mov ah,02h
int 21h
mov dl,[si]
and dl,0fh
cmp dl,0ah
jc down1
add dl,07h
down1:add dl,30h
mov ah,02h
int 21h
inc si
dec ch
jnz up
mov ah,4ch
int 21h
end
Input:04h
Input:0ffh
Output:FE01h is displayed on the screen
.model small
.data
num dw 05h
;num dw 0ffh
cube dw 02 dup(0)
.code
Mov ax,@data
Mov ds,ax
Mov dx,0h
Mov ax,num
Mul num
Mov cx,dx
Mul num
Add ax,cx
Mov cube,ax
Jnc skip
Inc dx
Skip:mov cube+2,dx
Mov ah,4ch
Int 21h
End
Input:0ffh
Input:05h
Output:7d in locations cube and cube+2
28. Program to find number of ones in a given data word and display the count on
the screen
.model small
.data
n1 dw 0fff0h
n3 db 04 dup(0)
.code
mov ax,@data
mov ds,ax
mov bx,00h
lea si,n3
clc
mov cl,10h
mov ax,n1
up:rcl ax,01
jnc d1
inc bl
d1:mov [si],bl
dec cx
jnz up
mov dl,[si]
and dl,0f0h
mov cl,04h
ror dl,cl
cmp dl,0ah
jc d11
add dl,07h
d11:add dl,30h
mov ah,02h
int 21h
mov dl,[si]
and dl,0fh
cmp dl,0ah
jc d12
add dl,07h
d12:add dl,30h
mov ah,02h
int 21h
mov ah,4ch
int 21h
end
Input:0fff0h
29.ascii multiplication
.model small
.data
N1 db 6
N2 db 7
N3 db 02 dup(0)
.code
Mov ax,@data
Mov ds,ax
Mov ah,n1
Mov al,n2
mov ch,09h
;Mov ah,00h
Aad
div ch
Or ax,3030h
Push ax
Mov dl,ah
Mov ah,02h
Int 21h
pop ax
Mov dl,al
Mov ah,02h
Int 21h
Mov ah,4ch
Int 21h
End
.model small
.data
string db 18 dup(0)
.code
mov ax,@data
mov ds,ax
mov es,ax
mov ah,09h
int 21h
add si,14h
mov dl,24h
mov [si],dl
cops:mov ah,01h
int 21h
cmp al,0dh
jz rev
dec si
mov [si],al
jmp cops
mov ah,09h
int 21h
mov ah,09h
mov dx,si
int 21h
mov ah,4ch
int 21h
end
30.Program to transfer the string
.model small
.data
dst db 25 dup(0)
.code
mov ax,@data
mov ds,ax
mov es,ax
lea si,src
lea di,dst
cld
mov cx,0fh
rep movsb
mov ah,4ch
int 21h
end
data segment
mainstr db 80 dup(0)
subst db 80 dup(0)
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov es,ax
mov ah,09h
lea dx,mes1
int 21h
mov si,00
up:mov ah,01h
int 21h
cmp al,0dh
jz acc
mov mainstr[si],al
inc si
jmp up
acc:mov mainstr[si],al
lea dx,cr
mov ah,09h
int 21h
lea dx,mes2
int 21h
mov di,00
t3:mov ah,01h
int 21h
cmp al,0dh
jz out
mov subst[di],al
inc di
jmp t3
out:mov subst[di],al
lea dx,cr
mov ah,09h
int 21h
mov si,00
mov di,00
again:mov al,mainstr[si]
cmp al,null
jz t2
cmp al,subst[di]
jz down
mov di,00
inc si
jmp again
down:inc si
inc di
mov al,subst[di]
cmp al,null
jz found
jmp again
found:mov ah,09h
lea dx,sfound
int 21h
jmp quit
t2:mov ah,09h
lea dx,nfound
int 21h
quit:mov ah,4ch
int 21h
code ends
end start
3 2. Program to multiply two data words and display the answer by calling a far
procedure
data segment
;mul1 db 12h
;mul2 db 24h
mul1 db 0ffh
mul2 db 0ffh
data ends
stack_seg segment
dw 40 dup(0)
stack_seg ends
sbrt segment public
extrn disp:far
sbrt ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov al,mul1
mul mul2
mov cx,ax
mov al,ah
call disp
mov al,cl
call disp
mov ah,4ch
int 21h
code ends
end start
public disp
assume cs:sbrt
push ax
push dx
push cx
mov dl,al
and dl,0f0h
mov cl,04h
ror dl,cl
cmp dl,0ah
jb down
add dl,07h
down:add dl,30h
push ax
mov ah,02h
int 21h
pop ax
mov dl,al
and dl,0fh
cmp dl,0ah
jc down1
add dl,07h
down1:add dl,30h
push ax
mov ah,02h
int 21h
pop ax
pop cx
pop dx
pop ax
ret
disp endp
sbrt ends
end
Input:12h 24h
Content actions
Give Feedback:
E-mail the module author | Rate module ( How does the rating system work?)
Rating system
Ratings
Ratings allow you to judge the quality of modules. If other users have ranked the
module then its average rating is displayed below. Ratings are calculated on a scale
from one star (Poor) to five stars (Excellent).
Hover over the star that corresponds to the rating you wish to assign. Click on the
star to add your rating. Your rating should be based on the quality of the content.
You must have an account and be logged in to rate content.
EPUB is an electronic book format that can be read on a variety of mobile devices.
For detailed instructions on how to download this content's EPUB to your specific
device, click the "(?)" link.
My Favorites
'My Favorites' is a special kind of lens which you can use to bookmark modules and
collections. 'My Favorites' can only be seen by you, and collections saved in 'My
Favorites' can remember the last module you were on. You need an account to use
'My Favorites'.
Definition of a lens
Lenses
A lens is a custom view of the content in the repository. You can think of it as a
fancy kind of list that will let you see content through the eyes of organizations and
people you trust.
What is in a lens?
Lens makers point to materials (modules and collections), creating a guide that
includes their own comments and descriptive tags about the content.
Tags are descriptors added by lens makers to help label content, attaching a
vocabulary that is meaningful in the context of the lens.
| External bookmarks
Reuse / Edit:
m32857 1.1 http://cnx.org/con
If you have permission to edit this content, using the "Reuse / Edit" action will allow
you to check the content out into your Personal Workspace or a shared Workgroup
and then make your edits.
Derive a copy
If you don't have permission to edit the content, you can still use "Reuse / Edit" to
adapt the content by creating a derived copy of it and then editing and publishing
the copy.
Footer
Login Required