Hardware Reference
In-Depth Information
these different purposes, the 8088 uses segments which are chunks of the memory
set apart for a certain uses. In the 8088, such a segment consists of 65,536 consec-
utive bytes. There are four segments:
1.
The code segment.
2.
The data segment.
3.
The stack segment.
4.
The extra segment.
The code segment contains the program instructions. The contents of the PC regis-
ter are always interpreted as a memory address in the code segment. A PC value of
0 refers to the lowest address in the code segment, not absolute memory address
zero. The data segment contains the initialized and uninitialized data for the pro-
gram. When BX contains a pointer, it points to this data segment. The stack seg-
ment contains local variables and intermediate results pushed on the stack.
Addresses in SP and BP are always in this stack segment. The extra segment is a
spare segment register that can be placed anywhere in memory that it is needed.
For each of the segments, there exists a corresponding segment register: the
16-bit registers CS , DS , SS , and ES . The starting address of a segment is the 20-bit
unsigned integer which is constructed by shifting the segment register by 4 bits to
the left, and putting zero's in the four right-most positions. This means that seg-
ment registers always indicate multiples of 16, in a 20-bit address space. The seg-
ment register points to the base of the segment. Addresses within the segment can
be constructed by converting the 16-bit segment register value to its true 20-bit
address by appending four zero bits to the end and adding the offset to that. In
effect, an absolute memory address is computed by multiplying the segment regis-
ter by 16 and then adding the offset to it. For example, if DS is equal to 7, and BX
is 12, then the address indicated by BX is 7
124. In other words, the
20-bit binary address implied by DS = 7 is 00000000000001110000. Adding the
16-bit offset 0000000000001100 (decimal 12) to the segment's origin gives the
20-bit address 00000000000001111100 (decimal 124).
For every memory reference, one of the segment registers is used to construct
the actual memory address. If some instruction contains a direct address without
reference to a register, then this address is automatically in the data segment, and
DS is used to determine the base of the segment. The physical address is found by
adding this bottom to the address in the instruction. The physical address in mem-
ory of the next instruction code is obtained by shifting the contents of CS by four
binary places and adding the value of the program counter. In other words, the true
20-bit address implied by the 16-bit CS register is first computed, then the 16-bit
PC is added to it to form a 20-bit absolute memory address.
×
16
+
12
=
 
Search WWH ::




Custom Search