Java FAQ _01 Basic Concepts (017) _ How the memory physical address is formed in the CPU

Source: Internet
Author: User

Click to enter _ more _java thousand ask

1, what is the physical address of memory

We use 8086CPU to illustrate how memory addresses are formed.

First we need to understand the physical address, when the CPU needs to access a memory unit, the address of the memory unit needs to be given, and each memory unit in the physical memory space has a unique address, that is, this address can be located to the memory unit, and this address is the physical address.

The CPU sends the physical address of a memory unit to the memory via address bus, and then the CPU can access the memory unit that the physical address points to by the physical address.

2. How the memory physical address is formed in the CPU

First of all, we know that the 8086CPU address bus is 20, that is, each can transmit 20-bit address, thus addressing the ability to have 2^20, that is, the size of 1MB. However, the 8086CPU register only 16 bits, that is, within 8086CPU, processing, transmission, staging of the address can only be 16 bits, that is, 8086CPU can not complete the next physical address (physical address is 20 bits).

If the simplest way (that is, to save the physical address directly with 16-bit registers), the addressable capacity is only 2^16, that is, 64KB size, 8086CPU can only support 64KB size of memory?
Of course not, 8086CPU has taken some measures here to make its addressing capacity reach 1MB.

The 8086CPU internally synthesizes two 16-bit addresses to form a 20-bit physical address, and the 8086CPU addressable capacity can reach 1MB. How do you combine two 16-bit addresses into a 20-bit physical address?
When the CPU accesses memory, it uses a 16-bit base address and then uses a 16-bit offset address, which can be constructed by combining two addresses into the 8086CPU address adder, which means that the physical address of the 20-bit is structured.

The way to synthesize is as follows:
Move the segment address 4 bits to the left, form a base address, and then add the base address and offset address to form a 20-bit physical address. Such as:

3. What is the memory segment?

In fact, there is no memory segment concept in physical memory, and the concept of memory segment comes from the segment registers in the CPU.

We consider a number of contiguous memory units as a segment, by moving a segment address to the left 4 bits to form the base address, and then through the base site to locate the beginning address of the segment, and finally through the offset address can be accurately positioned to the memory unit in the segment.

Since the start address of a memory segment is a segment address left 4 bits, the starting address of the memory segment must be a multiple of 16. and the memory unit inside a memory segment can only be located by the offset address, and the offset address is 16 bits, so the length of a segment is 2^16 that is the size of 64KB.

In programming, a section of memory can be defined as a segment, divided into data segments, code snippets, stack segments of the three types of segments. Specific as follows:

    1. Data segment
      The memory segment where we need to use the data (of course the starting address is definitely a multiple of 16, and the segment length is <=64KB).

    2. Code snippet
      The memory segment that holds the code (that is, the instruction).

    3. Stack segment
      We use a piece of memory as a stack to be called a stack.

A simple example:

MOV1000H   ;MOV DS, BX????  ;向DS段寄存器传入1000H段地址。MOV AX, [1234H]?;将内存地址1000H:1234H(即11234H)中的值读到AX寄存器中。

Java FAQ _01 Basic Concepts (017) _ How the memory physical address is formed in the CPU

Related Article

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.