Memory addressing mechanism for 80x86

Source: Internet
Author: User

memory addressing mechanism for 80x86

80386 operating mode of the processor :

The 80386 processor has three modes of operation: real mode , protected mode , and virtual 86 mode .

Mode switching: The real mode and the protected mode can be converted to each other, the protection mode and the virtual 86 mode can be converted to each other, while the real mode and the Virtual 86 mode can not be converted to each other .

The DOS system runs in real mode, and the Windows system runs in protected mode.


Real Mode :

80386 when the processor is reset or power up, it starts in real mode.

The addressing method in real mode is 80,861-like, (Segment register content-segment address) SA (16bit) *16+ea (16bit) (offset address), where 32-bit address lines are only used with low 20-bit (16+4=20) addressing space of 2^20b = 1MB .

In real mode 80386 can not be paged management of memory, the address of the instruction addressing is the actual physical address in memory , so in real mode, all the segments are readable , writable and executable .

In real mode, the interrupt mode of 80386 is the same as 8086, and the interrupt vector table is used to locate the address of the interrupt service program, where the interrupt vector structure is 4 bytes, where 2 bytes are sa,2 bytes for ea.

real mode to protected mode conversion : Initialize control registers, GDTR, LDTR, IDTR and TR management registers and page tables, and then by loading CR0 pe bit ( No. 0 bit ) to 1 Convert to Protected mode.


Protection Mode :

All 32-bit address lines are used in protected mode with up to 4GB of addressable space.

The protection mode supports 4 priority levels, namely ring0~ring3.

protection mode to real mode conversion : Establish global descriptor descriptor for GDT, interrupt descriptor sheet IDT, etc., by setting CR0 PE bit ( No. 0 bit ) to 0 to protect mode.


Virtual 86 Mode :

is set to be able to execute 8086 programs in protected mode . For example, the cmd command runs "MS-DOS application" running in the Windows operating system.

Virtual 86 mode is a mode of operation based on protected mode . with 8086 addressing , the addressing space is 1M.


80386 Memory addressing mechanism :

80386 address in real mode with 80,861 samples.

Focus on protection mode :


Segment Description Table (Segmenttable): Divided into Global description table (GDT Global ...) and local description table (LDT local ...), where the Segment descriptor table holds the segment descriptor .

Segment Descriptor (Segment descriptor): priority, whether read-write executable, and so on the parameters of the description segment, a total of 64 bits .

Segment Selector (Segment Selector):16-bit segment Register , which holds the segment selector, which holds the "index" of the Segment description table.


GDT: The GDT Global descriptor table has only one , containing segment descriptors that are available for all tasks in the system , including code snippets , data segments , stack segments in the operating system And each task of the LDT section , etc., by the GDTR point.

Ldt: each task has a separate LDTthat contains each task's private code snippet , data segment , stack segment, and some of the gate descriptors used by the task, such as the task Gate and the call Gate descriptor , are pointed by LDTR .


GDTR Direct to memory address , ldtr, CS, DS, SS, ES, FS, and GS store index values , pointing to descriptors for memory segments in the local description table in the Global Description table position , as long as the table LDTR, the system's current LDT will switch, convenient for each task switch and the separation of data between tasks, GDT will not switch with the task switch.


the specific addressing process :

In a 16-bit Segment Selector (segment register), the high 13 bits represent the index value , the No. 0, and 1 bits represent the program's current priority RPL (requirement privilege[ ' privilid3] level), the 2nd bit of TI is in the DT position,ti=0 in the GDT ,ti=1 in the Ldt .


Virtual Address: SA (16bit): Calculation of EA (32bit)

(Segment register Content-segment address) SA (16bit) *16+ea (32bit) (offset address) Note offset to 32bit


In two cases:

One

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.