Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
48 views

Lecture# 4 The Microprocessor and It's Architecture: Course Instructor: Engr. Linta Khalil

The document discusses memory addressing techniques in real mode for microprocessors like 8086. It describes the flag register bits and their purposes. Real mode allows addressing the first 1MB of memory using segment registers and offsets. Segments define 64KB blocks, and offsets select locations within. The combination of segment and offset generates a 20-bit physical address. Relocatable programs can be loaded anywhere in memory under DOS using this scheme.

Uploaded by

Sohaib Umar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Lecture# 4 The Microprocessor and It's Architecture: Course Instructor: Engr. Linta Khalil

The document discusses memory addressing techniques in real mode for microprocessors like 8086. It describes the flag register bits and their purposes. Real mode allows addressing the first 1MB of memory using segment registers and offsets. Segments define 64KB blocks, and offsets select locations within. The combination of segment and offset generates a 20-bit physical address. Relocatable programs can be loaded anywhere in memory under DOS using this scheme.

Uploaded by

Sohaib Umar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Lecture# 4

The Microprocessor and it’s


Architecture
Course Instructor: Engr. Linta Khalil
NFC Institution of Engineering & Technology, Multan Pakistan
Lecture Objectives
• Detail the flag register and the purpose of each flag
bit.
• Describe how memory is accessed using real mode
memory- addressing techniques.
• Describe how memory is accessed using protected
mode memory-addressing techniques.
• The Flag register is a Special Purpose Register. The flag
bits are changed to 0 or 1 depending upon the value of
result after arithmetic or logical operations.
• 8086 has 16-bit flag register, and there are 9 valid flag
bits. The format of flag register is like below.

Flag register of
8086
Microprocessor
• We can divide the flag bits into two sections.
The Status Flags, and the Control Flags.
1- Status Flags
• There are 6 flag registers in 8086
microprocessor which become set(1) or
reset(0) depending upon condition after either
Continue….. 8-bit or 16-bit operation.
• These flags are conditional/status flags.
• 5 of these flags are same as in case of 8085
microprocessor and their working is also same
as in 8085 microprocessor.
• S (sign)
After any operation if the MSB is 1, then it
indicates that the number is negative. And
this flag is set to 1
• Z(Zero)
Continue….. If the total register is zero, then only the Z flag
is set
• AC(auxiliary carry)
When some arithmetic operations generates
carry after the lower half and sends it to
upper half, the AC will be 1
• P (Parity)
This is even parity flag. When result has even
number of 1, it will be set to 1, otherwise 0 for
odd number of 1s
• C(Carry)
Holds the carry after addition or borrow after
subtraction and also indicates error
Continue…. conditions.
O (overflow)
The overflow flag is set to 1 when the result of a
signed operation is too large to fit.
• In 8086 there are 3 different flags which are
used to enable or disable some basic
operations of the microprocessor. These flags
and their functions are listed below.
• D (direction)
This is directional flag. This is used in string
2- Control Flag related operations.
D = 1, then the string will be accessed from
higher memory address to lower memory
address, and if D = 0, it will do the reverse.
• I(Interrupt Flag)
This is interrupt flag. If I = 1, then MPU will
recognize the interrupts from peripherals. For
I = 0, the interrupts will be ignored
• T(Trap Flag)
The trap flag enables trapping through
Continue…. an on-chip debugging feature.
❑ If T=1, cause interupt after the
execution of each instruction used for
debugging.
❑ If T=0, the trapping (debugging) feature
is disabled.
Segment Registers
• The segment registers stores the starting addresses of
a segment. To get the exact location of data or instruction
within a segment, an offset value (or displacement) is
required.
• Four segment registers in various versions of the
microprocessor.(The 8086–80286 microprocessors allow
four memory segments and the 80386– Core2
microprocessors allow six memory segments.
• A segment register functions differently in real mode
than in protected mode.
• Code Segment (CS) Register:
The user cannot modify the content of these
registers. Only the microprocessor's compiler
can do this.
CS is used for addressing memory location in the
code segment of the memory, where the
Continue….. executable program is stored.
• Data Segment (DS) Register:
The user can modify the content of the data
segment. DS points to the data segment of the
memory where the data is stored.
• Stack Segment (SS) Registers:
The SS is used to store the information about
the memory segment. The operations of the
SS are mainly Push and Pop.
• Extra Segment (ES) Register:
By default, the control of the compiler
Continue….. remains in the DS where the user can add and
modify the instructions. If there is less space in
that segment, then ES is used. ES is also used
for copying purpose.
• This mode allows the microprocessor to
Real Mode address only the first 1M byte of memory
space.
Memory • Is called conventional memory, or DOS
memory system

Addressing • The DOS operating system requires that the


microprocessor operates in the real mode.
Windows does not use the real mode.
• The 80286 and above operate in either the
real or protected mode.
• Only the 8086 and 8088 operate exclusively
in the real mode.
• In the 64-bit operation mode of the Pentium 4
and Core2, there is no real mode operation. it
cannot execute real mode applications.
Segments and Offsets
• To access a memory location in the real mode,
a combination of a segment address and an
offset address is needed.
• The segment address, located within one of
the segment registers, defines the beginning
address of any 64K-byte memory segment.
• The offset address(displacement), is the
distance above the start of the segment
selects any location within the 64K byte
memory segment .
Continue….
Continue….

• the segment plus offset generate a 20-bit


memory address to access a location within
the first 1M of memory.
• The 8086 processor has a 20-bit address bus,
which gives a physical address space of up to 1
MB (2 20), addressed as 00000h to FFFFFh
• the ending address is found by adding FFFFH.
Memory
Address
Generation
• if a segment register contains 3000H,
and the offset is F000H (3000:F000)
• Thus…
• the first address of the segment is
Example 30000H. the physical address=
30000H+F000H= 3F000H.
• the ending address is
30000H+FFFFH= 3FFFFH.
• 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.
For Example…
• segment address is 4000H and offset address is
specified as the sum of F000H plus 3000H
• Offset= F000H+3000H=12000H, which greater than
Continue…. FFFFH.
• So that the carry of 1 is dropped for this addition to form
the offset address of 2000H.
• Physical address= 40000H+2000H=42000H, and not
52000H which is cause the system to halt and indicate
an addressing error.
Continue….

• A memory system showing the placement


of four memory segments
• NOTE: When this program is placed in
the memory system by DOS, it is
loaded in the TPA at the first available
area of memory above the drivers and
other TPA program. This area is
indicated by a free- pointer that is
maintained by DOS. Program loading is
handled automatically by the program
loader located within DOS.
Continue….

• An application program
containing a code, data, and
stack segment loaded into a DOS
system memory.
Segment and • A relocatable program is one that can be
Offset placed into any area of memory and executed
without change.
Addressing • Relocatable data are data that can be placed
in any area of memory and used without any
Scheme Allows change to the program.

Relocation

You might also like