Microprocessor CHAP2
Microprocessor CHAP2
Memory Unit
Speed Comparison:
Secondary Storage < Primary Storage(RAM) < cache < Registers
Internal microprocessor architecture
● Before a program is written or any instruction investigated, the internal
configuration of the microprocessor must be known.
● In a multiple core microprocessor each core contains the same programming
model, where each core runs a separate task or thread simultaneously.
● The programming model of 8086 through Core-2 is considered program visible
● These registers are used during programming and are specified by the
instructions.
● Other registers considered to be program invisible
● They are not addressable directly during applications programming but may be
used indirectly in system programming.
Types of registers
1.Multipurpose Registers- General purpose registers are extra registers that are
present in the CPU and are utilized anytime data or a memory location is
required. These registers are used for storing operands and pointers.
2.Special Purpose Registers-To store machine state data and change state
configuration, special purpose registers are employed. In other words, these can
also be defined as registers that are used to carry out instruction execution. The
special-purpose registers include RIP, RSP, and RFLAGS.
RCX (count):
RCX addressable as RCX, ECX, CX, CH, or CL,.
It is a general-purpose register that also holds the count for various instructions.
In the 80386 and above, the ECX register also can hold the offset address of memory data.
In the 64-bit Pentium 4, RCX can also address memory data.
Instructions that use a count are the repeated string instructions (REP/REPE/REPNE); and shift,
rotate, and LOOP/LOOPD instructions.
RDX (data) :
RDX is addressable as RDX, EDX, DX, DH, or DL,.
It is a general-purpose register that holds a part of the result from a
multiplication or part of the dividend before a division.
In the 80386 and above, this register can also address memory data.
RBP(base pointer) :
RBP is addressable as RBP, EBP, or BP.
It points to a memory location in all versions of the microprocessor for
memory data transfers.
RDI (destination index) :
RDI, which is addressable as RDI, EDI, or DI.
It addresses string destination data for the string instructions.
RSI (source index):
RSI is used as RSI, ESI, or SI.
The source index register often addresses source string data for the string instructions.
R8 through R15 :
These registers are only found in the Pentium 4 and Core2 if 64-bit extensions are enabled.
Older software does not use these registers and most applications will not use these until
64-bit processors are common.
SPECIAL PURPOSE REGISTERS
● D ( direction )
○ The direction flag selects either the increment or decrement mode.
○ If D = 1, the registers are automatically decremented; if D = 0, the registers are
automatically incremented.\
○ The D flag is set with the STD (set direction) and cleared with the CLD ( clear
direction) instructions.
● O (overflow)
○ Overflows occur when signed numbers are added or subtracted.
○ An overflow indicates that the result has exceeded the capacity of the machine.
○ For unsigned operations, the overflow flag is ignored.
● RF (resume)
○ The resume flag is used with debugging to control the resumption of execution after
the next instruction.
● VM (virtual mode)
○ The VM flag bit selects virtual mode operation in a protected mode system.
○ A virtual mode system allows multiple DOS memory partitions that are 1M byte in
length to coexist in the memory system.
● VIF (virtual interrupt) :
○ The VIF is a copy of the interrupt flag bit available to the
Pentium–Pentium 4 microprocessors.
● AC (alignment check) :
○ The alignment check flag bit activates if a word or doubleword is
addressed on a non-word or non-doubleword boundary.
○ Only the 80486SX microprocessor contains the alignment check bit.
● VIP (Virtual Pending Interrupt):
○ VIP provides information about a virtual mode interrupt for the
Pentium–Pentium 4 microprocessors.
○ This is used in multitasking environments to provide the operating system
with virtual interrupt flags and interrupt pending information.
● ID (identification) :
○ The ID flag indicates that the Pentium–Pentium 4 microprocessors support
the CPUID instruction.
○ The CPUID instruction provides the system with information about the
Pentium microprocessor, such as its version number and manufacturer.
SEGMENT REGISTERS
A linear address is a 32-bit address in the processor’s linear address space. Just
like the physical address space, the linear address space is also a flat memory
model and it is unsegmented. The linear address space consists of all the
segments and system tables which are used to define a system.
1. Address Translation
2. Protection
3. Demand Paging
Control Registers -
The paging unit is controlled by the contents of the microprocessor’s control
registers.
There are four control registers labelled CR0 to CR3 in the microprocessor 80386.
Size of each control register is 32 bits.
They are only available in the protection mode of 80386 microprocessor.
Structure of the Control Registers -
The structure of the control registers is given below -
1. Protection Enable (PE) -
All the control registers are available only if the PE bit is set to 1. This
indicates that the microprocessor 80386 is in protection mode.
● Real mode operation allows the microprocessor to address only the first 1M
byte of memory space—even if it is the Pentium 4 or Core 2 microprocessor.
● The first 1 Megabyte of memory is called the real memory, conventional
memory, or DOS memory.
● DOS operating system requires that the microprocessor operates in the real
mode.
● Only the 8086 and 8088 operate exclusively in the real mode.
● In the 64-bit operation mode of the Pentium 4 and Core 2, there is no real
mode operation, hence it cannot execute real mode applications; hence,
DOS applications will not execute in the 64-bit mode unless a program that
emulates DOS is written for the 64-bit mode.
Segments and Offsets
● A combination of a segment address and an offset address accesses a memory location in
the real mode.
● Segment Address - The segment address, located within one of the segment registers,
defines the beginning address of any memory segment.
● Offset Address - The offset address selects any location within the 64K byte memory
segment.
The figure below shows the segment plus offset addressing scheme to select a memory location.
The segment register in Figure 2–3 contains 1000H, yet it addresses a starting segment at location
10000H. In the real mode, each segment register is internally appended with a 0H on its rightmost end.
This forms a 20-bit memory address, allowing it to access the start of a segment.
● The segment and offset address is sometimes written as 1000:2000 for a
segment address of 1000H with an offset of 2000H.
● Some addressing modes combine more than one register and an offset
value to form an offset address. When this occurs, the sum of these values
may exceed FFFFH.
● When the F000H and 3000H are added, they form a l6-bit (modulo 16) sum
of 2000H used as the offset address; not 12000H, the true sum. Note that
the carry of 1 ( F000H + 3000H = 12000H) is dropped for this addition to
form the offset address of 2000H. The address is generated as 4000:2000
or 42000H.
Default Segment and Offset Registers
● The microprocessor has a set of rules that apply to segments whenever
memory is addressed. These rules, which apply in the real and protected
mode, define the segment register and offset register combination.
● The code segment register is always used with the instruction pointer to
address the next instruction in a program. This combination is CS:IP
● Another of the default combinations is the stack. Stack data are referenced
through the stack segment at the memory location addressed by either the
stack pointer (SP/ESP) or the pointer (BP/EBP).
● Other defaults are shown in the following Table for addressing memory
using any Intel microprocessor.
Protected Mode Memory
Addressing
Kaam wahi, steps nayi
What it does?
● Protects a particular segment from direct access by the
microprocessor
● Allows the processor to address the complete memory (within
and above the first 1M)
How?
Segment Register
selects describes
Selector Descriptor Memory Segment
selector - Selects one of the descriptor from the two descriptor tables, each
containing 8192 descriptors.
8x8192 = 64KB
Descriptor table
The two descriptor tables are:
80286 has a 16 bit limit (216 = 64K), so it can access memory segment of size 1 to
64K bytes.
80386 through Pentium 4 has 20 bit (220 = 1M), so it can access memory segment
of size 1 to 1M bytes (or 4K to 4G bytes, by using G bit)
G - Granularity bit allows a segment length of 4K to 4G bytes in steps of 4K bytes
Access right byte - controls access to the protected mode segment. This byte
describes how the segment functions in the system.
Example
Base = 10000000H
Limit = 001FFH
G=0
Last address = Base + Limit = 10000000H + 001FFH = 100001FFH
Selector TI RPL
15 3 2 1 0
They are used to access and specify the address of descriptor tables.
GDTR (global descriptor table register) and IDTR (interrupt descriptor table
register) - contain the base address of the descriptor table and its limit.
LDTR (local descriptor table register) - used to load a selector, just like SR
TR(task register) - holds selector, which access a descriptor that defines a task
Flat
Mode
Memory
Flat Memory Model
● Flat memory model(Linear memory model) refers to a memory addressing
paradigm in which “memory appears to program as a single contiguous
address space.”
● The CPU can directly address all of the available memory locations without
having to resort to any sort of paging and segmentation.
● Flat mode is only available in Pentium 4 and Core 2 that have enabled their
64-bit extension.
FLAT MODE MEMORY
● No Segmentation - Doesn’t use segment registers.
● Doesn’t select the memory address of a segment using the base and limit in the
descriptor.
● Most used is IA32 compatible mode
● Easier to understand.
● Paging is allowed.
● Little protection.
64- bit Flat Memory Model
FFFFFFFFFF H
Linear Address
00000F0000 00000F0000 H
● 40 bit address
● Represented as 10 hexa-digits
0000000000 H
8086
KEY Points
● 8085 - Accumulator Based microprocessor
● 8086 - General Purpose Register Based microprocessor