Introduction To 8086
Introduction To 8086
access 1MB of physical memory. The complete 1MB of memory can be divided into 16 segments, each
of 64KB size and is addressed by one of the segment register. The 16-bit contents of the segment
register actually point to the starting location of a particular segment. The address of the segments may
be assigned as 0000H to F000h respectively. To address a specific memory location within a segment,
we need an offset address. The offset address values are from 0000H to FFFFH so that the physical
1. Allows the memory capacity to be 1MB although the actual addresses to be handled are of 16-bit
size.
2. Allows the placing of code, data and stack portions of the same program in different parts (segments)
3. Permits a program and/or its data to be put into different areas of memory each time the program is
In the overlapping area locations physical address = CS1+IP1 = CS2+IP2. Where ‘+’ indicates the
Data Segment
OPR-1 Equ 98H
OPR-2 Equ 49H
SUM DW 01 DUP (00)
DIFF DW 01 DUP (00)
PROD DW 01 DUP (00)
DIV DW 01 DUP (00)
Data Ends
Code Segment
Assume CS: Code, DS: Data
Start: MOV AX,Data
MOV DS,AX
MOV BL,OPR-2
XOR AL,AL
MOV AL,OPR-1
ADD AL,BL
DAA
MOV BYTE_PTR SUM,AL
JNC GO-1
INC [SUM+1]
GO-1: XOR AL,AL
MOV AL,OPR-1
SUB AL,BL
DAS
MOV BYTE_PTR DIFF,AL
JNB GO-2
INC [DIFF+1]
GO-2: XOR AL,AL
MOV AL,OPR-1
MUL BL
MOV WORD_PTR PROD,AX
XOR AX,AX
MOV AL,OPR-1
DIV BL
MOV WORD_PTR DIV,AX
MOV AH,4CH
INT 21H
Code Segment
End Start
9. It is necessary to define a block of data in 8086 assembly language program. The length of the
block is 90,000 bytes. Give the initialization of data segment for the above block of data. It is
necessary to add second element and 68,000th element of the above data. Give the sequence of
instructions to perform the above operation.
Sol: In 8086 the length of each segment is limited to 64KB (65536 bytes). Hence we cannot load
define a continous block of 90,000 bytes. For this purpose we need to define two segments. One
segment holding the first 62536 bytes of data while the other holding remaining 24464 bytes of
data.
Data Segment
Block-1 DB FFFFH DUP (0)
Data Ends
Extra Segment
Block-2 DB 24464H DUP (0)
Extra Ends
Code Segment
Assume CS:Code, DS:Data
Start: MOV AX,Data
MOV DS,AX
MOV AX,Extra
MOV ES,AX
LEA SI,Block-1
LEA DI,Block-2
MOV CX,FFFFH
INITI-1: MOV [SI],CX
INC SI
LOOP INITI-1
MOV CX,5F90H
INITI-2: MOV [DI],CX
INC DI
LOOP INITI-2
LEA SI,Block-1
LEA DI,Block-2
MOV AL,[SI+1]
ADD AL,[DI+2464]
Code Ends
End Start
10. Write an ALP to find no of +ve & -ve numbers from a given series of signed numbers
Data Segment
Data Segment
List DW 1234, 4567, 8976, 1238, 8975,
Count EQU 05h
Data Ends
Code Segment
Assume CS:Code, DS: Data
Start: MOV AX,Data
MOV DS,AX
XOR BX,BX
XOR DX,DX
MOV CL,Count
MOV SI,OFFSET List
AGAIN: MOV AX,[SI]
ROR AX,01H
JC ODD
INC BX
JMP NEXT
ODD: INC DX
NEXT: ADD SI,02H
DEC CL
JNZ AGAIN
MOV AH,4CH
INT 21H
Code Ends
End Start
14. Write an ALP to arrange the given list of numbers in ascending order using bubble sorting
Data Segment
List DB 23, 45, 56, 89, 78
Count EQU 04H
Data Ends
Code Segment
Assume CS:Code, DS:Data
Start: MOV AX,Data
MOV DS,AX
MOV DL,Count-1
AGAIN: MOV CL,DL
MOV SI,OFFSET List
BACK: MOV AL,[SI]
CMP AL,[SI+1]
JL GO
XCHG [SI+1],AL
XCHG [SI],AL
GO: INC SI
LOOP BACK
DEC DL
JNZ AGAIN
MOV AH,4CH
INT 21H
Code Ends
End Start
15. Write an ALP to find weather the given data is even or odd parity, if even parity put DL=00H,
else put DL=01H, Assuming the given data is multi byte
Data Segment
NUM DD 33 44 88 66H
BYTE_COUNT EQU 04H
Data Ends
Code Segment
Assume CS:Code,DS:Data
Start: MOV AX,Data
MOV DS,AX
MOV DH,BYTE_COUNT
XOR AL,AL
MOV CL,00H
MOV SI,OFFSET NUM
NXT-BYTE: MOV AL,[SI]
JP EVEN-PARITY
INC CL
EVEN-PARITY: INC SI
MOV AL,00H
DEC DH
JNZ NXT-BYTE
MOV DL,00H
RCR CL,01H
JNC CLEAR
INC DL
CLEAR: MOV AH,4CH
INT 21H
Code Ends
End Start