Why do we use logical addresses?

Why do we use logical addresses?

To refer to a physical memory location, a logical address is utilized. A logical address is constructed so that a user application can never directly access physical memory, and the process can not occupy memory gained by another process, so damaging that process. Logical addressing allows multiple processes to use a single set of memory maps.

The first part of a logical address is called its segment identifier. There are four main segments: an instruction pointer (EIP) that points to the current instruction being executed; a data segment (DS) that holds information about which parts of the program's address space are currently in use; a read-only code segment (CS), which contains the beginning of the instructions for any operating system services or libraries programs use to manage resources (such as the file system); and a fixed data segment (SS) that may contain the global variables used by all programs in the operating system. These segments are described in more detail below.

The second part of a logical address is a field indicating which portion of the first part is currently in use. This field can be one of three values: 0x00, 0x01, or 0x03. The first value, 0x00, indicates that the entire first part is in use by this process.

What is meant by "logical address"?

While a program is running, the CPU generates a logical address. A logical address is sometimes known as a virtual address since it does not exist physically. The CPU uses this address as a reference to reach the real physical memory location. This memory location may contain instructions or data for the executing program.

The logical address can be divided into three parts: segment number, offset within the segment and register value. The first part is called the segment number or selector. It is an eight-bit number that identifies which of the four main segments in RAM will be accessed. The other parts are both six-bit numbers that identify where to find them in their corresponding segment.

Each instruction executed by the processor has a logical address. This address can be divided into three parts: segment number, offset and register value. The same rules apply to segment numbers as before. But the offset increases from byte count to byte count, so it can identify any position in the selected segment. The register value is used instead of a general purpose pointer to avoid storing additional information in the instruction itself.

Data stored in memory can also have a logical address. This address will include the same three parts: segment number, offset and register value. Again, all you need to know is that the offset increases from byte count to byte count while the register value is used instead of a general purpose pointer.

Why do we need a logical address?

A logical address is required to safely control our physical memory. The binding of a process's instructions and data to memory occurs at compile time, load time, or execution time. Only when the process travels from one memory segment to another during its execution period does a logical address enter the picture. A logical address is an identifier that can be used by an instruction to access any location in memory.

In other words, a logical address is needed so that instructions can reference any address in the computer's memory. This is necessary because the processor reads memory locations in order to perform its functions. It cannot remember what memory location it was at any given moment if it is also being asked to execute instructions. Therefore, a mechanism is needed so that the processor can tell where it has been reading from or writing to. Logical addresses serve this purpose.

There are two types of logical addresses: linear and absolute. They differ only in where they begin their search within the total range of possible memory addresses. A linear address begins with an index that is added to/subtracted from the base register value. The base register contains the initial value for the address. Thus, the address may vary from iteration to iteration depending on how much space is allocated to it. Linear addresses are commonly used for array elements or loop variables.

An absolute address is given a specific starting point in memory. It does not change no matter how many times you repeat an instruction.

What do you mean by logical and physical address explaining it?

A Physical Address specifies the physical location of data in a memory. The physical address is never directly dealt with by the user, although it can be accessed via its equivalent logical address. When a program requests information to be read from or written to memory, the CPU translates the logical address into a physical address. The RAM itself has a number of physical addresses but they are mapped to only one logical address at a time.

Nowadays, all modern computers use virtual addressing as well. With this method, instead of referring to specific locations in the memory, we refer to general areas. The computer then uses the context of the program that is being executed to find the correct address where it can store or read information. This approach allows much more flexibility than the fixed logical-physical mapping used by early computers.

Here's an example. Say we want to write some data to memory address 100. Using logical addressing, we could specify the location of the data using a number: 0x100. Using physical addressing, the CPU would need to know which memory module contains the address 100. It could either be the first module, if it starts at zero, or maybe the fifth, if it's starting at one hundred. There's no way for us to know without looking at the manufacturer's documentation.

About Article Author

Jeffry Lagrone

Jeffry Lagrone is a man of many hats. He writes code, builds websites, designs apps, and does pretty much any other technical thing you could ever imagine. He's a jack-of-all-trades with an eye for detail and a love for all things techy. He spent the first few years after college as a freelance designer before going to work at one of Chicago's top ad agencies where he honed his skills as both a web developer and designer. After several successful years in advertising Jeff left to pursue his passion - running his own company!


TheByteBeat.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com.

Related posts