Logical address

Computer terminology
Collection
zero Useful+1
zero
Logical address refers to the address of memory cell, storage element and network host seen from the perspective of application program in computer architecture. A logical address is often different from a physical address. It can be converted into a physical address through an address translator or mapping function.
Chinese name
Logical address
Foreign name
logical address; logic address;
Meaning
Address given by access instruction

brief introduction

Announce
edit
In the computer with address transformation function, the address (operand) given by the access instruction is called logical address, also called relative address. The actual effective address in the internal memory, that is, the physical address, can be obtained only after the calculation or transformation of the addressing mode.
The addressing mode (address transformation function) of various computers is different. When writing programs in assembly language, you should first be familiar with the instruction system of this machine.

Reference book explanation

1. In a computer with address transformation function, access the address given by the instruction( Operands )It's called logical address, also called Relative address Go through Addressing mode Is calculated or transformed Memory In Physical address
2. Put User program The address used in is called a relative address or logical address.
3. The logical address consists of two 16 bit address components, one is the segment base value and the other is the offset. Both components are coded with unsigned numbers. [1]

Explanation of academic literature

1. In this way, the address of the storage unit can be represented by the segment base address (segment address) and the intra segment offset (offset address). The segment base address determines the position of the segment where it is located in the entire storage space, and the offset determines its position in the segment. This address representation is called logical address, which is usually expressed in the form of segment address: offset address.
2. The so-called logical address refers to the location of the disk given by the logical block number of the data (l block=512 words l word=64 bits), while the physical address is the address determined by the physical location of the disk such as the cylinder, head, and segment.

Background

Announce
edit
After all, Intel's 8-bit 8080CPU, data bus (DB) is 8 bits, Address bus (AB) is 16 bits. Then the 16 bit address information is also transmitted through the 8-bit data bus, and also in the data channel Register , and stored in the CPU's registers and memory, but since AB is exactly an integer multiple of DB, there will be no conflict!
However, when it rose to 16 bit, the design of Intel 8086/8088 CPU could not exceed 40 pins due to the limitations of IC integration technology, external package and pin technology in that year. However, it is felt that the original address addressing capacity of the 8-bit computer, 2 ^ 16=64KB, is too small, but it cannot be reached by directly increasing it to an integer multiple of 16, i.e. AB=32 bits. Therefore, we can only temporarily add 4 items of AB to 20 items. The addressing capacity of 2 ^ 20=1MB has increased 16 times. However, this has caused a contradiction between the 20 bits of AB and the 16 bits of DB. The 20 bit address information cannot be transmitted on the DB, nor can it be transmitted between the 16 bit CPU register and the Memory unit Medium storage. Then came into being the principle of CPU segment structure.

Linear address

Announce
edit
A logical address consists of two parts, segment identifier and intra segment Offset The segment identifier consists of a 16 bit long field, called the segment selector. The first 13 digits are an index number. Quotes can be understood as array It will correspond to an array. What index is it? This is“ Segment Descriptor (segment descriptor) ", the specific address of the segment descriptor describes a segment (for the understanding of the word" segment ", we can understand it as virtual memory It is divided into sections one by one. For example, if a memory has 1024 bytes, it can be divided into 4 segments, each segment has 256 bytes). In this way, many segment descriptors form an array, called "segment descriptor table". In this way, a specific segment descriptor can be found directly in the segment descriptor table through the first 13 bits of the segment identifier. This descriptor describes a segment. I just extracted the segment incorrectly, Because we can see what is in the descriptor - that is, how it is described, we can understand what is in the segment. Each segment descriptor is composed of 8 bytes, as shown in Figure 1:
Figure 1
These things are very complicated. Although a data structure can be used to define it, I only care about the Base field, which describes the starting position of a segment Linear address
The original intention of Intel design is that some global Segment Descriptor , which is placed in the Global Segment Descriptor Table (GDT), and some local ones, such as each process's own, are placed in the so-called Local Segment Descriptor Table (LDT). When should GDT and LDT be used? This is represented by the T1 field in the segment selector,=0 means GDT,=1 means LDT.
The address and size of GDT in memory are stored in the gdtr of CPU Control register The LDT is in the ldtr register.
Many concepts, like tongue twisters. Figure 2 looks more intuitive:
Figure 2
First, give a complete logical address [segment selector: within the segment Offset address ],
1. Check whether T1 of the segment selector is 0 or 1, know whether the segment to be converted is a segment in GDT or a segment in LDT, and then get its address and size according to the corresponding register. We have one array Has.
2. Take out the first 13 bits of the segment selector, and you can find the corresponding Segment Descriptor In this way, the base address is known.
3. Base+offset is to be converted Linear address Has.

Related differences

Announce
edit
Logical Address refers to the segment related offset address generated by the program. For example, when you are programming pointers in C language, you can read the value of the pointer variable itself (&operation). In fact, this value is a logical address, which is relative to the address of your current process data segment, and is not related to the absolute physical address. Only in Intel real mode, the logical address is equal to the physical address (because there is no segmentation or paging mechanism in real mode, Cpu does not perform automatic address translation); Logic is the offset address within the code segment limit of program execution under Intel protection mode (assuming that the code segment and data segment are identical). Application programmers only need to deal with logical addresses, while segmentation and paging mechanisms are completely transparent to you and are only involved by system programmers. Although the application programmer can directly operate the memory, he can only operate in the memory segment allocated to you by the operating system.
Linear Address is the intermediate layer between logical address and physical address transformation. The program code will generate the logical address, or the offset address in the segment, and add the base address of the corresponding segment to generate a linear address. If paging is enabled, the linear address can be transformed again to produce a physical address. If the paging mechanism is not enabled, the linear address is directly the physical address. The linear address space capacity of Intel 80386 is 4G (32 power of 2, that is, 32 root address bus addressing).
Physical Address refers to the address signal addressing the physical memory on the CPU external address bus, which is the final result address of address transformation. If the paging mechanism is enabled, the linear address will be transformed into a physical address using the entries in the page directory and page table. If the paging mechanism is not enabled, the linear address will directly become the physical address.
Virtual Memory refers to the amount of memory that the computer presents is much larger than the actual memory. Therefore, it allows programmers to write and run programs with much more memory than the actual system has. This enables many large projects to be implemented on systems with limited memory resources. A good analogy is that you don't need a long track to get a train from Shanghai to Beijing. You only need a long enough track (say 3 km) to complete this task. The method adopted is to immediately lay the rear track in front of the train. As long as you operate fast enough and meet the requirements, the train can run as if it were on a complete track. This is Virtual Memory Management Tasks to be completed. In the Linux 0.11 kernel, each program (process) is allocated a virtual memory space with a total capacity of 64MB. Therefore, the logical address range of the program is 0x00000000 to 0x4000000.
Sometimes we also call logical addresses virtual addresses. Similar to the concept of virtual memory space, the logical address is also independent of the actual physical memory capacity.
The "gap" between the logical address and the physical address is 0xC0000000, because the virtual address ->linear address ->physical address mapping is exactly different from this value. This value is specified by the operating system. [2]