lecture2
lecture2
Interfacing Techniques
Lecture 02
2 Contents
Special Purpose
Registers
80386DX
13
The Flags
C – Carry/borrow of result also show error conditions
P – The Parity Flag odd or even parity (little used
today)(error detection).
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 hardware
interrupts arriving at the INTR input pin
T – Trap- (turns trapping on/off for program debugging)
IOPL – 2-bit I/O privilege level in protected mode
14 NT – nested task flag indicates that the current task is nested within
another task in protected mode operation
RF – resume flag 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
AC – alignment check: The alignment check flag bit activates if a
word or doubleword is addressed on a non-word or non-
doubleword boundary
VIF – virtual interrupt flag in Pentium–Pentium 4 microprocessors.
VIP – virtual interrupt pending: VIP provides information about a
virtual mode interrupt for the Pentium–Pentium 4 microprocessors.
This is used in multitasking environments
ID (identification) The ID flag indicates that the Pentium–Pentium 4
microprocessors support the CPUID instruction . The instruction gives
info on CPU version and manufacturer.
15 Segment Registers
EA (Effective Address)
20-bit (5-byte) 64 KB +
Physical Segment
16-bit
Memory address
Appended byte 0H
19 Effective Address Calculations
Top of CS:
090F0
FFFF+
190EF
Defaults
21
CS for program (code)
SS for stack
DS for data
ES for string destination
Default offset addresses
:
Segment Offset (16-bit) Offset (32-bit) Purpose
8080, 8086, 80286 80386 and above
IP EIP Program
CS
SP, BP ESP, EBP Stack
SS
BX, DI, SI, 8-bit or 16-bit # EAX, EBX, ECX, EDX, ESI, Data
DS EDI, 8-bit or 32-bit #
DI EDI String
ES destination
22 Segmentation: Pros and Cons
Advantages:
Allows easy and efficient relocation of code and
data
A program can be located anywhere in memory
without any change to the program
Program writing needs not worry about actual
memory structure of the computer used to
execute it
To relocate code or data only the segment
number needs to be changed
Disadvantages:
Complex hardware and for address generation
Software: Programs limited by segment size
(only 64KB with the 8086)
23 Limitations of the above real mode
segmentation scheme
Segment size is fixed at 64 KB
Segment can not begin at an arbitrary memory
address…
With 20-bit memory addressing, can only begin
at addresses starting with 0H, i.e. at 16 byte
intervals
Difficult to use with 24 or 32-bit memory
addressing with segment registers remaining at
16-bits