0% found this document useful (0 votes)
27 views

COAL CH 2

Uploaded by

HASEEB SULMAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

COAL CH 2

Uploaded by

HASEEB SULMAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 16

Computer Organization

&
Assembly Language Programming
CH 2:
x86 Processor Architecture
Outline
 32-Bit x86 Processors
 Basic Execution Environment

Basic Concepts Computer Organization and Assembly Language


slide 2/43
32-Bit x86 Processors
 In this section, we focus on the basic architectural features of
all x86 processors. This includes members of the Intel IA-32
family as well as all 32-bit AMD processors.
 Modes of Operation
x86 processors have three primary modes of operation: protected
mode, real-address mode, and system management mode. A
sub-mode, named virtual-8086, is a special case of protected
mode.

Basic Concepts Computer Organization and Assembly Language


slide 3/43
32-Bit x86 Processors
 Protected Mode: is the native state of the processor, in which all
instructions and features are available. Programs are given separate
memory areas named segments, and the processor prevents programs from
referencing memory outside their assigned segments.
 Virtual-8086 Mode: While in protected mode, the processor can directly
execute real-address mode software such as MS-DOS programs in a safe
environment. In other words, if a program crashes or attempts to write data
into the system memory area, it will not affect other programs running at
the same time. A modern operating system can execute multiple separate
virtual-8086 sessions at the same time.

Basic Concepts Computer Organization and Assembly Language


slide 4/43
32-Bit x86 Processors
 Real-Address Mode
Real-address mode implements the programming environment with a few
extra features, such as the ability to switch to other modes. This mode is
useful if a program requires direct access to system memory and hardware
devices.
 System Management Mode:
System management mode (SMM) provides an operating system with a
mechanism for implementing functions such as power management and
system security. These functions are usually implemented by computer
manufacturers who customize the processor for a particular system setup.

Basic Concepts Computer Organization and Assembly Language


slide 5/43
Basic Execution Environment

 Address Space
In 32-bit protected mode, a program can address a linear address space of up
to 4 GBytes. In P6 processor, a technique called extended physical
addressing allows a total of 64 GBytes of physical memory to be
addressed.
Real-address mode programs, on the other hand, can only address a range of
1 MByte. If the processor is in protected mode and running multiple
programs in virtual-8086 mode, each program has its own 1-MByte
memory area.

Basic Concepts Computer Organization and Assembly Language


slide 6/43
Basic Execution Environment
 Basic Program Execution Registers
 Registers are high-speed storage locations directly inside the CPU, designed to be
accessed at a much higher speed than conventional memory.
Processor Registers
 There are ten 32-bit and six 16-bit processor registers. The registers are grouped
into three categories −
• General registers,
• Control registers, and
• Segment registers.
 The general registers are further divided
• Data registers,
• Pointer registers, and
• Index registers.

Basic Concepts Computer Organization and Assembly Language


slide 7/43
Basic Execution Environment
Data Registers
Four 32-bit data registers are used for arithmetic, logical, and other operations. These 32-bit registers can be
used in three ways −
•As complete 32-bit data registers: EAX ( basic task is i/o), EBX, ECX, EDX.
•Lower halves of the 32-bit registers can be used as four 16-bit data registers: AX, BX, CX and DX.
•eight 8-bit data registers: AH, AL, BH, BL, CH, CL, DH, and DL.

The remaining general-purpose registers can only be accessed using


32-bit or 16-bit Names.

Basic Concepts Computer Organization and Assembly Language


slide 8/43
Basic Execution Environment
 Some of these data registers have specific use in arithmetical operations.
 AX is the primary accumulator; it is used in input/output and most arithmetic
instructions. For example, in multiplication operation, one operand is stored in
EAX or AX or AL register according to the size of the operand.
 BX is known as the base register, as it could be used in indexed addressing.
 CX is known as the count register, as the ECX, CX registers store the loop count
in iterative operations.
 DX is known as the data register. It is also used in input/output operations. It is
also used with AX register along with DX for multiply and divide operations
involving large values.

Basic Concepts Computer Organization and Assembly Language


slide 9/43
Basic Execution Environment
 Specialized Uses Some general-purpose registers have specialized uses:
 EAX is automatically used by multiplication and division instructions. It is
often called the extended accumulator register.
 The CPU automatically uses ECX as a loop counter.
 ESP addresses data on the stack (a system memory structure). It is rarely
used for ordinary arithmetic or data transfer. It is often called the extended
stack pointer register.
 ESI and EDI are used by high-speed memory transfer instructions. They
are sometimes called the extended source index and extended destination
index registers.
 EBP is used by high-level languages to reference function parameters and
local variables on the stack. It should not be used for ordinary arithmetic or
data transfer except at an advanced level of programming. It is often called
the extended frame pointer register.
Basic Concepts Computer Organization and Assembly Language
slide 10/43
Basic Execution Environment
 Segment Registers In real-address mode, 16-bit segment
registers indicate base addresses of preassigned memory areas
named segments. Some segments hold program instructions
(code), others hold variables (data), and another segment
named the stack segment holds local function variables and
function parameters.
 Instruction Pointer The EIP, or instruction pointer, register
contains the address of the next instruction to be executed.
 EFLAGS Register The eflags register is a 32-bit register, and
each bit in this register is a flag. The bits in EFLAGS registers
are used to indicate the status of the computations and to
control the CPU operations.

Basic Concepts Computer Organization and Assembly Language


slide 11/43
Basic Execution Environment
 Control Flags control the CPU’s operation. For example, they can cause the CPU to
break after every instruction executes, and interrupt when arithmetic overflow is
detected.
 Status Flags The status flags reflect the outcomes of arithmetic and logical
operations performed by the CPU.
 The Carry flag (CF) is set when the result of an unsigned arithmetic operation is too large
to fit into the destination.
 The Overflow flag (OF) is set when the result of a signed arithmetic operation is too large
or too small to fit into the destination.
 The Sign flag (SF) is set when the result of an arithmetic or logical operation generates a
negative result.
 The Zero flag (ZF) is set when the result of an arithmetic or logical operation generates a
result of zero.
 The Parity flag (PF) it is used for error checking when there is a possibility that data
might be altered or corrupted.
 The Auxiliary Carry flag (AC) is set when an arithmetic operation causes a carry from
bit 3 to bit 4 in an 8-bit operand. This flag is only available internally
Basic Concepts Computer Organization and Assembly Language
slide 12/43
Basic Execution Environment
 MMX Registers (the Pentium® processor 1st use this)
MMX technology improves the performance of Intel processors when implementing
advanced multimedia and communications applications. The eight 64-bit MMX
registers support special instructions called SIMD (Single-Instruction, Multiple-
Data).
 XMM Registers
The x86 architecture also contains eight 128-bit registers called XMM registers. They
are used by streaming SIMD extensions to the instruction set. XMM registers can
only be used to perform calculations on data

Basic Concepts Computer Organization and Assembly Language


slide 13/43
Question Set
1. What are the x86 processor’s three basic modes of operation?
2. Name all eight 32-bit general-purpose registers.
3. Name all six segment registers.
4. What special purpose does the ECX register serve?

5. Which flag is set when the result of an unsigned arithmetic operation is too large to
fit into the destination?
6. Which flag is set when the result of a signed arithmetic operation is either too large
or too small to fit into the destination?
7. Which flag is set when an arithmetic or logical operation generates a negative result?
8. Which Intel processor first used MMX technology?

Basic Concepts Computer Organization and Assembly Language


slide 14/43
Memory

 ROM is permanently burned into a chip and cannot be erased.


 EPROM can be erased slowly with ultraviolet light and reprogrammed.
 DRAM, commonly known as main memory, is where programs and data are kept
when a program is running. It is inexpensive, but must be refreshed every
millisecond to avoid losing its contents. Some systems use ECC (error checking
and correcting) memory.
 SRAM is used primarily for expensive, high-speed cache memory. It does not have
to be refreshed. CPU cache memory is comprised of SRAM.
 VRAM holds video data. It is dual ported, allowing one port to continuously
refresh the display while another port writes data to the display.
 CMOS RAM on the system motherboard stores system setup information. It is
refreshed by a battery, so its contents are retained when the computer’s power is
off.

Basic Concepts Computer Organization and Assembly Language


slide 15/43
Question set
1. Describe SRAM and its most common use.
2. Describe VRAM.
3. Name four types of RAM

Basic Concepts Computer Organization and Assembly Language


slide 16/43

You might also like