Professional Documents
Culture Documents
& Interfacing
Techniques
Lecture 02
Contents
Internal architecture of the Microprocessor:
The programmers model, i.e. The registers model
The processor model (organization)
Objectives
Describe the function and purpose of
program-visible registers
Describe the Flags register and the
purpose of each flag bit
Describe how memory is accessed using
segmentation in both the real mode and
the protected mode
Describe the program-invisible registers
Describe the structures and operation of
the memory paging mechanism
Describe the processor model
Programming
Model
General Purpose
Registers
Special Purpose
Registers
Segment
Registers
General-Purpose Registers
The top portion of the programming model
contains the general purpose registers:
RAX, RBX, RCX, RDX, RBP, RSI, RDI and RSP.
Although general in nature, each have a
special purpose and name:
Can carry both Data & Address offsets
RAX (Accumulator)is referenced as a 64-bit
register (RAX), a 32-bit register (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
General-Purpose Registers
RBX is addressable as RBX, EBX, BX, BH, or BL. The BX
register sometimes holds the offset address of a
location in the memory system in all versions of the
microprocessor
RCX count, for shifts, rotates, and loops (ECX,CX, CH,
and CL)
RDX data, used with multiply and divide (EDX,DX,
DH, and DL)
RBP base pointer used to address stack data (EBP,
BP)
RDI destination index (EDI, DI) for memory locations
string operations
RSI source index (ESI, SI) for memory locations, e.g.
with string instructions
Special-Purpose Registers
RIP, RSP and RFLAGS
Each has a specific task
RIP Instruction Pointer: addresses the next instruction in
a program in the code segment (EIP, IP)
RSP Stack pointer: addresses the stack segment used
with functions (procedures) (ESP)
RFLAGS indicates latest conditions of the microprocessor
(EFLAGS, FLAGS)
EFLAGS
80386DX
10
The Flags
C Carry/borrow of result also show error
conditions
P The Parity Flag odd or even parity (little used
today). Parity is the count of ones in a number
expressed as even or odd.
A Auxiliary Flag used with BCD arithmetic, e.g.
using DAA and DAS (decimal adjust after
add/sub)
Z zero If Z = 1, the result is zero; if Z = 0, the
result is not zero
S sign (-ve (S=1)or +ve (S=0))
O Overflow
D direction - Determines auto incr/dec direction
for string instructions
I interrupt- Enables (using STI(set I flag)) or
disables (using CLI(clear I flag)) the processing of
11
12
Segment Registers
The segment registers are:
CS (code),
DS (data),
ES (extra data. used with string instructions),
SS (stack),
FS, and GS.
13
14
MB
(11MB)
EA (Effective Address)
20-bit (5-byte)
Physical
Memory address
64 KB
+
Segment
16-bit
Appended byte 0H
15
Effective Address
Calculations
16
Overlapping segments
Top of CS:
090F0
FFFF+
190EF
17
Defaults
CS for program (code)
SS for stack
DS for data
ES for string destination
Default offset addresses that go with them:
Segment
CS
SS
DS
ES
Offset (16-bit)
8080, 8086, 80286
Offset (32-bit)
80386 and above
Purpose
IP
EIP
Program
SP, BP
ESP, EBP
Stack
Data
EDI
String
destination
DI
18
19
20
21