Beruflich Dokumente
Kultur Dokumente
CSE 341
EEE 365
\\server2\tsr\Spring\CSE\CSE341
http://groups.google.com/group/bucse341
http://faculty.bracu.ac.bd/~faruqe/
faruqe@bracu.ac.bd
1
Programming Model
Programming Model of the 8086 through P4 is considered
program visible.
Program visible Its registers are used during application
programming and are specified in the instructions.
Program Invisible Some registers are not addressable directly
and cannot be used for the purpose of application programming.
They are used for other special purposes which will be detailed
later. Only 80286 and above contain program invisible registers
used to control and operate the protected memory system.
2
8 bit
names
32 BIT
NAMES
16 bit
names
EAX
AH
AX
AL
ACCUMULATOR
EBX
BH
BX
BL
BASE INDEX
ECX
CH
CX
CL
COUNT
EDX
DH
DX
DL
DATA
ESP
SP
STACK POINTER
EBP
BP
BASE POINTER
EDI
DI
DESTINATION INDEX
ESI
SI
SOURCE INDEX
EIP
IP
EFLAGS
FLAGS
ACCUMULATOR
FLAGS
CS
CODE
DS
DATA
ES
EXTRA
SS
STACK
FS
GS
Programming Model
The architecture of the earlier 8086 through 80286 are fully
upward compatible to the 80386 through P4.
Registers EAX, EBX, ECX, EDX, EBP, EDI and ESI are
regarded as general purpose or multi purpose registers.
Multi-purpose registers hold various data sizes ( bytes, words
, or double words) and are used for almost any purpose , as
dictated by program.
Multipurpose Registers
EAX (ACCUMULATOR) The accumulator is used for
instructions such as multiplication, division and some of the
adjustment instructions. In 80386 and above, the EAX register
may also hold the offset address of a location in memory
system.
EBX (BASE INDEX) This can hold the offset address of a
location in the memory system in all version of the
microprocessor. It the 80386 and above EBX also can address
memory data.
6
Multipurpose Registers
ECX (count) This acts as a counter for various instructions.
As we will see later in 80386 and above, the ECX register also
can hold the offset address of memory data. Instruction use
use a count are the repeated string instructions
( REP/REPE/REPNE) and shift rotate and LOOP/LOOPD
instructions. The shift and rotate instructions use CL as the
count, the repeated string instruction use CX, and the
LOOP/LOOPD instructions use either CS or ECX.
Multipurpose Registers
EDX (data) EDX is a general-purpose registers that holds a
part of the result for mutilation or part of the dividend before a
division. In the 80386 and above this register can also address
memory data.
EBP(Base Pointer) EBP points to a memory location in all
version of the microprocessor for memory data transfers. This
register is addressed as either BP or EBP.
EDI (Destination index) EDI often addresses string
destination data for the string instruction. It also functions as
either a 32-bit (EDI) or 16-bit (DI) general-purpose register.
8
Multipurpose Registers
ESI (Source index) ESI can either be used as ESI or SI. It
is often used to the address source string data for the string
instructions. Like EDI ESI also functions as a general-purpose
registers.
11
Flags
31..
22
21
20
19
18
17
16
ID
VIP
VIF
AC
VM
RF
15
14
13
12
11
10
NT
IOP1
IOP0
4
A
0
C
808680888018680188
80286
80386/8986DX
80486SX
PENTIUMPENTIUM 4
12
FLAGS
The flags:
C
P
A
Z
S
O
Change after many arithmetic and logic operations
These are known as Conditional Flags.
13
Flags
C (Carry) It holds the carry after addition or the borrow
after subtraction. The carry flag also indicates error
conditions, as dictated by some programs and procedures.
P (Parity) Parity is a logic 0 for odd parity and a logic 1 for
even parity. Parity is a count of ones in a number expressed as
even or odd. Today this is seldom used, initially implemented
to check data during communication. Today this is mostly
done through external hardware rather than the P.
14
Flags
A (Auxiliary carry) The auxiliary carry holds the carry
(half-carry) after addition or the borrow after subtraction
between bits positions 3 and 5 of the results. This highly
specialized flag is use during BCD operations.
Z (Zero) The zero flag shows that the result of an arithmetic
or logical operation is zero. When Z = 1, the result is zero.
When Z = 0, the result was non-zero.
S (Sign) The sign flag holds the arithmetic sign after an
arithmetic or a logical operation. If S =1 the sign bit is set and
the result is negative. If S = 0, the sign bit is not set and the
result is positive.
15
Flags
T (Trap) The trap flag enables trapping through an on-chip
debugging facility. When this is set to 1 the microprocessor
interrupts operation based on values set in the debugging
register and the control registers.
I (Interrupt) The interrupt flag controls the operations of
the INTR(Interrupt request) input pint. If I =1, the INTR pin is
enabled; if I =0, the INTR pin is disabled. The state of the I
flag bit is controlled by the STI (set I flag) and CLI (Clear I
flag) instructions.
16
Flag
D (Direction) The direction flag selects either the increment
or decrement mode for DI and/or SI registers during string
instructions. 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) instruction.
O (overflow) Overflow occurs when signed numbers are
added or subtracted. An overflow indicates that the result has
exceeded the capacity of the machine. For example if a 7FH
(+127) is added using a 8 bit addition to a 01H ( +1) the result
is 80H(-128). The result represents an overflow condition
indicated by the overflow flag for the signed addition.
17
Flags
IOPL (I/O Privilege level) IOPL is used in protected mode
operation to select the privilege level for I./O devices. IF the
current privilege level is higher or more trusted than the IOPL,
I/O executed without hindrance. If the IOPL is lover than the
current privilege level, an interrupt occurs, causing execution
to suspend. Note that an IPOL is 00 is the highest or more
trusted; if IOPL is 11, its the lowest or least trusted.
NT (nested task) The nested task flag is used to indicated
that the current task is nested within another task in protected
mode operation. This flag is when the task I nested by
software.
18
Flags
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. Essentially, this
allows the system program to execute multiple DOS
programs.
19
Flags
AC (alignment check) This flag is activates if a word or a
double work is addressed on a non-word or non-double word
boundary. Only the 80486SX microprocessor contains the
alignment check bit that is primarily used by its companion
numeric coprocessor, the 80487SX, for synchronization.
VIF (Virtual Interrupt flag) The VIF is a copy of the
interrupt flag bit available to the Pentium P4
microprocessor. This is used in multitasking environments to
provide the operating system with virtual interrupt flags and
interrupt pending information.
20
Flags
ID (identification) The ID flag indicated that the PentiumP4 microprocessors support CPUID instruction. The CPU ID
instruction provides the systems with information about the
Pentium microprocessor, about as its version number and the
manufacturer.
21
Segment Register
CS (Code) The code segment is a section of memory that
holds the code used by the microprocessor. The code segment
registers defines the starting address of the section of memory
holding code.
In read mode operation, it defines the start of the 64K-byte
section of the memory in protected mode, it selects a
description that describes the starting address and length of a
section of memory holding code.
The code segment is limited to 64K bytes in the 8088-80268
and 4 GB in the 80386 and above when these microprocessors
operate in the protected mode.
22
25
FFFFF
1FFFF
1F000
Offset = F000
10000
Segment Register
1000
00000
29
30
Segmentation
Remember that 8086-80286 microprocessors allow four
memory segments and 80386 and above allow six memory
segments.
Memory segments can touch or even overlap if 64K bytes of
memory are not required for a segment.
Think of a segment as a windows that can be moved over any
area of the memory to access data or code within that area.
32
33
Relocate-able programs:
A program that can be places into any area of memory and
executed without changing.
Relocate-able data:
Data that can be moved to any part of the memory and can still be
used without making changes to the program that use such data.
This is ideal for use in general-purpose computer system in which
not all machines contain the same memory areas.
The structure of the personal computer memory structure is
different form machine to machine requiring relocate able software
and data.
34
35