Real mode switch to protected mode, why turn on the A20 address line (compatibility issues resulting from system upgrade)

Source: Internet
Author: User

"-1" written in front:The following section summarizes the Http://blog.csdn.net/ruyanhai/article/details/7181842complementary: compatibility refers to programs that run on the previous CPU, such as 8086/8088, can also be run on its later processors, such as 80286; "0" look at the Intel processor development process

addressing and issues for "1" 8086/8088 1.1) Addressing:In 8086/8088, there are only 20 address bus, so the address that can be accessed is 2^20=1m, but since 8086/8088 is a 16-bit address pattern, the address range that can be represented is 0-64k, so in order to access 8086/8088 m of memory under 1, Intel took a segmented pattern: 16-bit segment Base address: 16-bit offset. The absolute address calculation method is: 16-bit base site to move Left 4 bit + 16-bit offset = 20-bit address; (this is relatively simple) 1.2) Questions:But this approach raises new questions, through the above segmented mode, the maximum memory that can be expressed is: ffffh:ffffh=ffff0h+ffffh=10ffefh=1m+64k-16bytes (1M redundant part is called the high-end memory area HMA). But 8086/8088 has only 20-bit address lines, and if you access memory between 100000H~10FFEFH, you must have a 21st address line. So when the programmer gives more than 1M (100000H-10FFEFH) address, the system does not think its access is out of bounds and produce an exception, but automatically starting from 0 to calculate, that is, the system calculates the actual address in accordance with the method of 1M modulo, This technique is called wrap-around. addressing and issues for "2" 80286 2.0) Addressing:By the 80286, the system's address bus developed to 24, so that the memory can be accessed to reach 2^24=16m. Intel's goal in designing 80286 was that, in real mode, the system behaves exactly the same as 8086/8088, meaning that in real mode, 80286 and subsequent series should be fully compatible with 8086/8088. 2.1) Questions:If the programmer accesses memory between 100000H-10FFEFH, 80286 will actually access this memory instead of starting from 0 as in the past, because 80286 has this addressing capability, but this does not satisfy and 8086/8088 system compatibility because 8086/ 8088 Unable to access the real address of the memory between the 100000H-10FFEFH, but according to the 1M modulo memory addressing mode; "3" Talk about compatibility issues between 80286 and 8086/8088: (real mode, 80286 system performance to be consistent with 8086/8088) 3.1) When A20 is forbidden:Programmers give the address between the 100000H~10FFEFH, 80286 and 8086/8088 of the system performance is consistent, that is, in accordance with the mode of 1M to address, to meet the compatibility of the system upgrade; 3.2) When A20 is turned on:The programmer gives the address between the 100000H~10FFEFH, 80286 is the real address of the access, and 8086/8088 is always in accordance with the mode of 1M (note here, is always); "4" Workaround:To address these issues, IBM uses some of the remaining output lines on the keyboard controller to manage the 21st address line (from 0 to 20th), called A20gate: if A20 gate is open, when the programmer gives the address between the 100000H-10FFEFH, The system will actually access this area of memory, and if A20gate is banned, the system still uses 8086/8088 of the way when the programmer gives the address between 100000h-10ffefh. "5" Welcome to the real mode + protection mode Flash Debut (dry) 5.1) Real mode:The real mode is that in order to achieve the compatibility of the system upgrade, such as 80286 of the system performance (including 80286 after the CPU) to be consistent with the 8086/8088 system performance, you need to 80286 the CPU to access the address between 100000H-10FFEFH, According to the mode of 1M, regardless of whether the A20 address line is turned off or not, this kind of memory access is called real mode; 5.2) Protection mode:Protection mode is to A20 address line to open the premise, 80286 CPU access 100000H-10FFEFH between the address of the time, is to access the real memory address, not to find the mode access, such as access to 100001H, is really true to access 0x 100001H, rather than modulo 0X000001H address, this memory access condition is called the protection mode; 5.3) Date of birth:The real mode exists from 8088/8086, and the protection mode starts from 80286. why does "6" Require protection mode? (Because real mode is born with 8088/8086 falling from the sky, it is only a way to access memory, and for 8086/8088, it has only real mode this kind of memory addressing mode, and for 80286 including its future CPU, There are two ways to address both real and protected modes, because system compatibility is a considerationObviously with the upgrading of the CPU, 8088/8086 of the memory addressing mode has been unable to meet the needs, it can be said that in order to access more than 10FFEFH of memory, you must enter the protection mode; "7" A20 prohibited + turned on different results 7.1) If a20gate is forbidden:For 80286来, the address is 24bit and its address is efffff, and for the 80386 extremely subsequent 32-bit chip, the address is expressed as ffefffff. This means that if a20gate is forbidden, then its 20-bit is invalid when the CPU does address access, and can only be used as 0; 7.2) If A20 Gate is opened:Then its 20-bit is valid, and its value can be either 0 or 1; 7.3) So:In protected mode, if the A20 gate is opened, the memory that can be accessed is contiguous, and if a20gate is forbidden, the memory that can be accessed is only an even segment, since it is 20 bits (starting from 0) Total zero, 23~20 bits can only be 0000, 0010, 0100, 0110, 1000, 1010, 1100, 1110 corresponds to hex 0, 2, 4, 6, 8, A, C, E. The corresponding hex address segment is 000000-0FFFFF,200000-2FFFFF,400000-4FFFFF ...

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Real mode switch to protected mode, why turn on the A20 address line (compatibility issues resulting from system upgrade)

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.