Top Banner
Lecture 7 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU
20
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 7

Lecture 7

Presented ByDr. Shazzad Hosain

Asst. Prof. EECS, NSU

Page 2: Lecture 7

Real Mode Memory Addressing• The first 1MB memory is Real memory or the

Conventional memory

16 bit Segment registers

***

Segment 1

Segment 2

Segment n

0000hCS

8000hDS

A000hSS

1MB

offset

1. 1 MB requires 20 bit address2. Each segment is 64 KB3. Offset address is 16 bit or 2 byte4. Actual address = segment address + offset address

Page 3: Lecture 7

Real Mode Memory Addressing

• Real mode operation allows to address 1MB of memory space – even for the Pentium microprocessor

• This first 1MB memory is called the real memory or the conventional memory

• A combination of segment and offset address access the real memory

• Segment registers contains the beginning address of any 64KB memory segment

• The offset address selects the any location within the 64KB memory space

Page 4: Lecture 7

Segment Plus Offset Determines Address

From Intel Microprocessor

To get the real address1. Pad 0H at the end of segment register2. Add the offset value

1. Since each segment is 64 K, the offset address can take maximum of FFFFH

2. Once, the beginning address is found in segment registers, ending address is calculated by adding FFFFH with the value of segment register after padding 0H after it.

10000H F000H1F000H

CS = 1000HOffset = F000H

12340H 245FH1479FH

DS = 1234HOffset = 245FH

Page 5: Lecture 7

Default Segment and Offset Registers

1. If CS = 1400H and IP/EIP = 1200 H2. The microprocessor access instruction from

14000 H+ 1200H = 15200H.

Page 6: Lecture 7

Figure 2-4: A memory system showing the placement of four memory segments

Suppose1. 1000H bytes of code2. 190H bytes of data3. 200H bytes of stack

Figure 2-5

Allowsrelocation

Page 7: Lecture 7

Protected Mode

• The segment register now contains a selector• Selector selects a descriptor from a descriptor

table• The descriptor describes the memory

segment’s location• Two descriptor table– Global Descriptor Table (GDT)– Local Descriptor Table (LDT)

Page 8: Lecture 7

Selectors and Descriptors

***

Offset 1680

31157

GDT/LDT

8191

**210

Segment RegistersAs Selector

1. 8192 number of descriptors in each table2. Each descriptor 8 bytes long, thus table size is 64 KB3. Selector selects one descriptor4. Descriptor describes the segment

Page 9: Lecture 7

Selectors and Descriptors

CS/DS/ES

Offset 1680

31157

GDT/LDT

8191

**210

Segment Register

0000 0000 0001 0010 0012H

0000 0000 0100 0100 0044H

1111 1111 1111 0000 FFF0H

Page 10: Lecture 7

Selectors and Descriptors

CS/DS/ES

Offset 1680

31157

GDT/LDT

8191

**210

Page 11: Lecture 7

Access Right Bits

Page 12: Lecture 7

Selectors and Descriptors

CS/DS/ES

Offset 1680

31157

GDT/LDT

8191

**210

7

5

3

1

6

4

2

0

A0H C2H

00H

10H 00H

1001 1011

0000 0000 0000 0000

Page 13: Lecture 7

Selectors and Descriptors

CS/DS/ES

Offset 1680

31157

GDT/LDT

8191

**210

7

5

3

1

6

4

2

0

00H 00H

21H

00H 1FH

0000 0000 0000 0000

Code a descriptor for 80286 that starts at 210000H and ends at 21001FH. This memory segment is a code segment that can be read

Limit = 21001FH – 210000H = 001FH

Page 14: Lecture 7

Selectors and Descriptors

7

5

3

1

6

4

2

0

00H 00H

21H

00H 1FH

1xx1 1x11

0000 0000 0000 0000

Code a descriptor for 80286 that starts at 210000H and ends at 21001FH. This memory segment is a code segment that can be read

Limit = 21001FH – 210000H = 001FH

Page 15: Lecture 7

Selectors and Descriptors

• 32 bit / 4 byte base, memory size is 4 GB = 22x210x210x210

• AV = 1, means available, 0 means not available• D = 1, means 32 bit instructions, 0 means 16 bit instructions• G bit or the Granularity bit

– G = 0, the limit is from 1 to 1MB in length– G = 1, the limit is multiplied by 4K bytes (appended with 000H). So

segment length is 4K to 4G bytes in steps of 4K bytes

Page 16: Lecture 7

Selectors and Descriptors

• G bit or the Granularity bit– G = 0, the limit is from 1 to 1MB in length– G = 1, the limit is multiplied by 4K bytes (appended with 000H). So

segment length is 4K to 4G bytes in steps of 4K bytes

00H 00H

01H

00H

0H

FFH FFH

7

5

3

1

6

4

2

0

0 D OAV

Start = 01000000HLimit = 0FFFFHEnd = 0100FFFFH

Page 17: Lecture 7

Selectors and Descriptors

• G bit or the Granularity bit– G = 0, the limit is from 1 to 1MB in length– G = 1, the limit is multiplied by 4K bytes (appended with 000H). So

segment length is 4K to 4G bytes in steps of 4K bytes

00H 00H

00H

28H

0H

00H 10H

7

5

3

1

6

4

2

0

1 D OAV

Start = 00280000HLimit =End =

00010H00000390000H

Page 18: Lecture 7

• G bit or the Granularity bit– G = 0, the limit is from 1 to 1MB in length– G = 1, the limit is multiplied by 4K bytes (appended with 000H). So

segment length is 4K to 4G bytes in steps of 4K bytes

00H 00H

03H

00H

0H

2FH FFH

7

5

3

1

6

4

2

0

G D OAV

End = 05FFFFFFHStart = 03000000H

Size = 02FFFFFFH

Limit = 02FFFH

1

Page 19: Lecture 7

00H 00H

03H

00H

0H

2FH FFH

7

5

3

1

6

4

2

0

G D OAV

End = 05FFFFFFHStart = 03000000H

Size = 02FFFFFFH

Limit = 02FFFH

1

1xx1 001x

Page 20: Lecture 7

References

• Chapter 2, Intel Microprocessors – by Brey