The CPU RegistersThe 8086 has 3 classes of registers. They are1. General Purpose
RegistersThe
8086 has 8 general-purpose registers, each of which is 16 bits wide. They
are ax, bx, cx, dx, si, di, bp and sp.
2. Segment RegistersThe 8086 has 4 special segment registers, viz. cs, ds, es and ss. These are 16-bit registers and deal with selecting blocks (segments) of the memory.
3. Special Purpose RegistersThere are two special purpose registers on the 8086, i.e. the instruction pointer (ip) and the flag register. The ip is sometimes referred to as the pc (program counter). These registers cannot be accessed directly, rather, they are modified by the cpu during execution.The ip contains the address of the instruction being executed currently. This address is the offset within the code segment, specified by the cs register. The flag register (shown in the figure above) is a collection of 1-bit values that hold information regarding the state of the system. Though it is a 16-bit register, only 9 of those bits are used. For most practical purposes, only 4 flags are used: zero, carry, sign and overflow. SegmentationThe 8086 is a 16-bit processor, with 16-bit registers and hence the address space which can be accessed is 216 bits (i.e. 64 kilobytes). But with the clever use of segmentation, the address space can be expanded to 1 Megabyte. Though 1 Megabyte seems very small in today's context, in those days, it was a lot of memory (especially since the cost of making physical memory was exhorbitant).Before we start with segmentation, let us look at the way in which the address computation is done in the 8086: To provide flexible addressing capabilities, a data address may be formed by adding together a combination of BX or BP contents, SI or DI contents and a displacement. (This we will see in detail, when we cover addressing modes). The result of such a computation is called the offset or the effective address (EA). The final address is determined by the EA and the appropriate data segment (DS), extra segment (ES) or stack segment (SS) register. Segmentation provides a powerful mechanism to manage memory. Programmers tend to partition their program into logically independent modules. With segmentation, this logical partitioning can be extended to keep these modules in physically independent sections (called segments). Segmentation also allows two programs to share memory. The effective address is a 16-bit value. However, to address 1 MB, there are 20 bits in the physical address. Where do these extra 4 bits come from? They are obtained from the segment register (to which the EA is added). The addition is carried out by appending four 0 bits to the value of the segment register, before adding, thereby producing a 20-bit result. This is shown in the figure below. Therefore, an address on the 8086 is written as segment:offset. The size of the offset (16-bits) limits the size of each segment to 64K. The number of segments is also limited to 65,536 segments per program, but this is not a practical limitation, since there are typically only about a dozen segments in a program. The use of segmentation typically divides the memory into overlapping segments, with each segment being 64K bytes long and beginning at a 16-byte boundary. Summarizing segmentation, the advantages are:
Addressing Modes |
Contents
"Computers in the future will weigh no more than 1.5 tons." --- (Popular Mechanics, forecasting advance of science, 1949.) "I think there is a world market for maybe five computers." --- (Thomas Watson, Chairman of IBM, 1943)
--- (Bill Gates, 1981) |