280 likes | 447 Views
Lecture on Real Mode Memory Addressing. Presented By WWW.Assignmentpoint.Com. Real Mode Memory Addressing. Segment n. * * *. The first 1MB memory is Real memory or the Conventional memory. 1MB. Segment 2. offset. 16 bit Segment registers. Segment 1. SS. CS. DS. 8000h. 0000h.
E N D
Lecture on Real Mode Memory Addressing Presented By WWW.Assignmentpoint.Com www.assignmentpoint.com
Real Mode Memory Addressing Segment n * * * • The first 1MB memory is Real memory or the Conventional memory 1MB Segment 2 offset 16 bit Segment registers Segment 1 SS CS DS 8000h 0000h A000h 1 MB requires 20 bit address Each segment is 64 KB Offset address is 16 bit or 2 byte Actual address = segment address + offset address www.assignmentpoint.com
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 www.assignmentpoint.com
Segment Plus Offset Determines Address • To get the real address • Pad 0H at the end of segment register • Add the offset value CS = 1000H Offset = F000H DS = 1234H Offset = 245FH 10000H F000H 1F000H 12340H 245FH 1479FH Since each segment is 64 K, the offset address can take maximum of FFFFH 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. www.assignmentpoint.com From Intel Microprocessor
Default Segment and Offset Registers If CS = 1400H and IP/EIP = 1200 H The microprocessor access instruction from 14000 H+ 1200H = 15200H. www.assignmentpoint.com
Suppose 1000H bytes of code 190H bytes of data 200H bytes of stack Allows relocation Figure 2-4: A memory system showing the placement of four memory segments www.assignmentpoint.com Figure 2-5
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) www.assignmentpoint.com
Selectors and Descriptors * * * 8191 * * 2 1 0 31 15 7 16 8 0 Segment Registers As Selector Offset 8192 number of descriptors in each table Each descriptor 8 bytes long, thus table size is 64 KB Selector selects one descriptor Descriptor describes the segment GDT/LDT www.assignmentpoint.com
Selectors and Descriptors Segment Register CS/DS/ES 0000 0000 0001 0010 0012H 0000 0000 0100 0100 0044H 1111 1111 1111 0000 FFF0H 8191 * * 2 1 0 31 15 7 16 8 0 Offset GDT/LDT www.assignmentpoint.com
Selectors and Descriptors CS/DS/ES 8191 * * 2 1 0 31 15 7 16 8 0 Offset GDT/LDT www.assignmentpoint.com
Access Right Bits www.assignmentpoint.com
Selectors and Descriptors CS/DS/ES 8191 * * 2 1 0 31 15 7 16 8 0 7 5 3 1 0000 0000 0000 0000 6 4 2 0 Offset 1001 1011 00H A0H C2H GDT/LDT 10H 00H www.assignmentpoint.com
Selectors and Descriptors Code a descriptor for 80286 that starts at 210000H and ends at 21001FH. This memory segment is a code segment that can be read CS/DS/ES 8191 * * 2 1 0 31 15 7 16 8 0 7 5 3 1 0000 0000 0000 0000 6 4 2 0 Offset 21H 00H 00H GDT/LDT 00H 1FH Limit = 21001FH – 210000H = 001FH www.assignmentpoint.com
Selectors and Descriptors Code a descriptor for 80286 that starts at 210000H and ends at 21001FH. This memory segment is a code segment that can be read 7 5 3 1 0000 0000 0000 0000 6 4 2 0 1xx1 1x11 21H 00H 00H 00H 1FH Limit = 21001FH – 210000H = 001FH www.assignmentpoint.com
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 www.assignmentpoint.com
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 AV 01H 0H 0 D O 00H 00H 00H FFH FFH 7 5 3 1 6 4 2 0 Start = 01000000H Limit = 0FFFFH End = 0100FFFFH www.assignmentpoint.com
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 AV 00H 0H 1 D O 28H 00H 00H 00H 10H 7 5 3 1 6 4 2 0 Start = 00280000H Limit = End = H 00010 000 00390000H www.assignmentpoint.com
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 AV 03H 0H 1 G D O 00H 00H 00H 2FH FFH 7 5 3 1 6 4 2 0 End = 05FFFFFFH Start = 03000000H Size = 02FFFFFFH Limit = 02FFFH www.assignmentpoint.com
AV 03H 0H 1 G D O 1xx1 001x 00H 00H 00H 2FH FFH 7 5 3 1 6 4 2 0 End = 05FFFFFFH Start = 03000000H Size = 02FFFFFFH Limit = 02FFFH www.assignmentpoint.com