Digital Assignment - 1 Microprocessor and Interfacing
Digital Assignment - 1 Microprocessor and Interfacing
Devangshu Mazumder
Segmentation is the process in which the main memory of the computer is divided into
different segments and each segment has its own base address. It is basically used to enhance
the speed of execution of the computer system, so that processor is able to fetch and execute
the data from the memory easily and fast.
• Code segment register (CS): is used for addressing memory location in the code
segment of the memory, where the executable program is stored.
• Data segment register (DS): points to the data segment of the memory where the
data is stored.
• Extra Segment Register (ES): also refers to a segment in the memory which is
another data segment in the memory.
• Stack Segment Register (SS): is used for addressing stack segment of the memory.
The stack segment is that segment of memory which is used to store stack data.
Types Of Segmentation –
Rules of Segmentation
• The starting address of a segment should be such that it can be evenly divided by 16.
• Minimum size of a segment can be 16 bytes and the maximum can be 64 kB.
The main advantages of segmentation memory are as follows:
• It allows to extend the address ability of the processor, i.e. segmentation allows the
use of 16 bit registers to give an addressing capability of 1 Megabytes. Without
segmentation, it would require 20 bit registers.
• It is possible to enhance the memory size of code data or stack segments beyond 64
KB by allotting more than one segment for each area.
Q2. Draw the register organization of 8086 and explain typical
applications of each register.
ACCUMULATOR
AX
AH Al BASE
BX BH BL
COUNT
CH CL
CX
DH DL DATA
DX
STACK POINTER
SP
BP BASE POINTER
SI SOURCE POINTER
DI
DESTINATION POINTER
IP INSTRUCTION POINTER
CS CODE SEGMENT
DS DATA SEGMENT
SS
STACK SEGMENT
ES
EXTRA SEGMENT
The registers AX, BX, CX, and DX are the general 16-bit registers.
AX Register: Accumulator register consists of two 8-bit registers AL and AH, which
can be combined together and used as a 16- bit register AX. AL in this case contains the
low-order byte of the word, and AH contains the high-order byte. Accumulator can be
used for I/O operations, rotate and string manipulation.
BX Register: This register is mainly used as a base register. It holds the starting base
location of a memory region within a data segment. It is used as offset storage for
forming physical address in case of certain addressing mode.
CX Register: It is used as default counter or count register in case of string and loop
instructions.
DX Register: Data register can be used as a port number in I/O operations and implicit
operand or destination in case of few instructions. In integer 32-bit multiply and divide
instruction the DX register contains high-order word of the initial or resulting number.
Segment registers:
To complete 1Mbyte memory is divided into 16 logical segments. The complete
1Mbyte memory segmentation is as shown in fig 1.5. Each segment contains 64Kbyte of
memory. There are four segment registers.
Stack segment (SS) is a 16-bit register containing address of 64KB segment with
program stack. By default, the processor assumes that all data referenced by the stack
pointer (SP) and base pointer (BP) registers is located in the stack segment. SS register
can be changed directly using POP instruction. It is used for addressing stack segment of
memory. The stack segment is that segment of memory, which is used to store stack data.
Data segment (DS) is a 16-bit register containing address of 64KB segment with
program data. By default, the processor assumes that all data referenced by general
registers (AX, BX, CX, DX) and index register (SI, DI) is located in the data segment.
DS register can be changed directly using POP and LDS instructions. It points to the data
segment memory where the data is resided.
Extra segment (ES) is a 16-bit register containing address of 64KB segment, usually
with program data. By default, the processor assumes that the DI register references the ES
segment in string manipulation instructions. ES register can be changed directly using POP
and LES instructions. It also refers to segment which essentially is another data segment of
the memory. It also contains data.
Base Pointer (BP) is a 16-bit register pointing to data in stack segment. BP register is
usually used for based, based indexed or register indirect addressing.
Source Index (SI) is a 16-bit register. SI is used for indexed, based indexed and register
indirect addressing, as well as a source data addresses in string manipulation instructions.
Destination Index (DI) is a 16-bit register. DI is used for indexed, based indexed and
register indirect addressing, as well as a destination data address in string manipulation
instructions.
Conditional Flags
Conditional flags are as follows:
Carry Flag (CY): This flag indicates an overflow condition for unsigned integer
arithmetic. It is also used in multiple-precision arithmetic.
Parity Flag (PF): This flag is used to indicate the parity of result. If lower order 8-bits of
the result contains even number of 1’s, the Parity Flag is set and for odd number of 1’s,
the Parity flag is reset.
Zero Flag (ZF): It is set; if the result of arithmetic or logical operation is zero else it is
reset.
Sign Flag (SF): In sign magnitude format the sign of number is indicated by MSB bit. If
the result of operation is negative, sign flag is set.
Control Flags
Control flags are set or reset deliberately to control the operations of the execution unit.
Control flags are as follows:
Trap Flag (TF): It is used for single step control. It allows user to execute one
instruction of a program at a time for debugging. When trap flag is set, program can be
run in single step mode.
Direction Flag (DF): It is used in string operation. If it is set, string bytes are accessed
from higher memory address to lower memory address. When it is reset, the string bytes are
accessed from lower memory address to higher memory address.