Chapter2 86
Chapter2 86
Chapter2 86
Introduction
This chapter presents the microprocessor as a programmable device by first looking at its internal programming model and then how its memory space is addressed. The architecture of Intel microprocessors is presented, as are the ways that the family members address the memory system. Addressing modes for this powerful family of microprocessors are described for the real, protected, and flat modes of operation.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Chapter Objectives
Upon completion of this chapter, you will be able to:
Describe function and purpose of each program-visible register in the 8086-Core2 microprocessors, including 64-bit extensions. Detail the flag register and the purpose of each flag bit. Describe how memory is accessed using real mode memory-addressing techniques.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Chapter Objectives
Upon completion of this chapter, you will be able to:
(cont.)
Describe how memory is accessed using protected mode memory-addressing techniques. Describe how memory is accessed using the 64-bit flat memory model. Describe program-invisible registers found in the 80286 through Core2 microprocessors. Detail the operation of the memory-paging mechanism.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
A thread consists of a program counter, a register set, and a stack space. A task shares with peer threads its code section, data section, and operating system resources
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
80286 and above contain program-invisible registers to control and operate protected memory.
and other features of the microprocessor
80386 through Core2 microprocessors contain full 32-bit internal architectures. 8086 through the 80286 are fully upwardcompatible to the 80386 through Core2. Figure 21 illustrates the programming model 8086 through Core2 microprocessor.
including the 64-bit extensions
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 21 The programming model of the 8086 through the Core2 microprocessor including the 64-bit extensions.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Multipurpose Registers
RAX - a 64-bit register (RAX), a 32-bit register (accumulator) (EAX), a 16-bit register (AX), or as either of two 8-bit registers (AH and AL).
The accumulator is used for instructions such as multiplication, division, and some of the adjustment instructions. Intel plans to expand the address bus to 52 bits to address 4P (252~1015 =peta) bytes of memory.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Special-Purpose Registers
Include RIP, RSP, and RFLAGS
segment registers include CS, DS, ES, SS, FS, and GS
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
RFLAGS indicate the condition of the microprocessor and control its operation. Figure 22 shows the flag registers of all versions of the microprocessor. Flags are upward-compatible from the 8086/8088 through Core2 . The rightmost five and the overflow flag are changed by most arithmetic and logic operations.
although data transfers do not affect them
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 22 The EFLAG and FLAG register counts for the entire 8086 and Pentium microprocessor family.
Flags never change for any data transfer or program control operation. Some of the flags are also used to control features found in the microprocessor.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Flag bits, with a brief description of function. C (carry) holds the carry after addition or borrow after subtraction.
also indicates error conditions
P (parity) is the count of ones in a number expressed as even or odd. Logic 0 for odd parity; logic 1 for even parity.
if a number contains three binary one bits, it has odd parity if a number contains no one bits, it has even parity
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
P (parity) is the count of ones in a number expressed as even or odd. Logic 0 for odd parity; logic 1 for even parity.
if a number contains three binary one bits, it has odd parity; If a number contains no one bits, it has even parity
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
A (auxiliary carry) holds the carry (half-carry) after addition or the borrow after subtraction between bit positions 3 and 4 of the result. Z (zero) shows that the result of an arithmetic or logic operation is zero. S (sign) flag holds the arithmetic sign of the result after an arithmetic or logic instruction executes. T (trap) The trap flag enables trapping through an on-chip debugging feature.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
I (interrupt) controls operation of the INTR (interrupt request) input pin. D (direction) selects increment or decrement mode for the DI and/or SI registers. O (overflow) occurs when signed numbers are added or subtracted.
an overflow indicates the result has exceeded the capacity of the machine
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Segment Registers
Generate memory addresses when combined with other registers in the microprocessor. Four or six segment registers in various versions of the microprocessor. A segment register functions differently in real mode than in protected mode. Following is a list of each segment register, along with its function in the system.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
CS (code) segment holds code (programs and procedures) used by the microprocessor. DS (data) contains most data used by a program.
Data are accessed by an offset address or contents of other registers that hold the offset address
ES (extra) an additional data segment used by some instructions to hold destination data.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 23 shows how the segment plus offset addressing scheme selects a memory location.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 23 The real mode memory-addressing scheme, using a segment address plus an offset.
also shows how an offset address, called a displacement, of F000H selects location 1F000H in the memory
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Once the beginning address is known, the ending address is found by adding FFFFH.
because a real mode segment of memory is64K in length
The offset address is always added to the segment starting address to locate the data. Segment and offset address is sometimes written as 1000:2000.
a segment address of 1000H; an offset of 2000H
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The code segment register defines the start of the code segment. The instruction pointer locates the next instruction within the code segment.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
think of segments as Windows that can be moved over any area of memory to access data or code a program can have more than four or six segments,
but only access four or six segments at a time
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 25 An application program containing a code, data, and stack segment loaded into a DOS system memory.
a program placed in memory by DOS is loaded in the TPA at the first available area of memory above drivers and other TPA programs area is indicated by a freepointer maintained by DOS program loading is handled automatically by the program loader within DOS
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
TPA
The transient program area (TPA) holds the DOS (disk operating system) operating system; other programs that control the computer system.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Because memory is addressed within a segment by an offset address, the memory segment can be moved to any place in the memory system without changing any of the offset addresses. Only the contents of the segment register must be changed to address the program in the new area of memory. Windows programs are written assuming that the first 2G of memory are available for code and data.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.