Memory address

Source: Wikipedia, the free encyclopedia.
In a computer using virtual memory, accessing the location corresponding to a memory address may involve many levels.

In

array endorsed by various programming languages
.

Types

Physical addresses

A

binary digit
(bit). The width of the bus, and thus the number of addressable storage units, and the number of bits in each unit, varies among computers.

Logical addresses

A

application programs do not have a knowledge of physical addresses. Rather, they address logical addresses, or virtual addresses, using the computer's memory management unit and operating system memory mapping; see below
.

Unit of address resolution

Most modern computers are

KiB
, or 1.125 MiB — slightly more than the 8086.

Some older computers (

flag bit
and four numerical bits. The 1620 used 5-digit decimal addresses, so in theory the highest possible address was 99,999. In practice, the CPU supported 20,000 memory locations, and up to two optional external memory units could be added, each supporting 20,000 addresses, for a total of 60,000 (00000–59999).

Word size versus address size

embedded systems
, usually have a word size of 8, 16, 24, 32 or 64 bits; most current general-purpose computers use 32 or 64 bits. Many different sizes have been used historically, including 8, 9, 10, 12, 18, 24, 36, 39, 40, 48 and 60 bits.

Very often, when referring to the word size of a modern computer, one is also describing the size of address space on that computer. For instance, a computer said to be "

32-bit
" also usually allows 32-bit memory addresses; a byte-addressable 32-bit computer can address 232 = 4,294,967,296 bytes of memory, or 4 gibibytes (GiB). This allows one memory address to be efficiently stored in one word.

However, this does not always hold true. Computers can have memory addresses larger or smaller than their word size. For instance, many

36-bit
processors.

In theory, modern byte-addressable

exbibytes), but in practice the amount of memory is limited by the CPU, the memory controller, or the printed circuit board
design (e.g., number of physical memory connectors or amount of soldered-on memory).

Contents of each memory location

Each memory location in a

instructions
which retrieve and manipulate it.

Some early programmers combined instructions and data in words as a way to save memory, when it was expensive: The

deprecated nowadays, as it makes testing and maintenance disproportionally difficult to the saving of a few bytes, and can also give incorrect results because of the compiler or processor's assumptions about the machine's state
, but is still sometimes used deliberately, with great care.

Address space in application programming

In modern

usually has in its address space (or spaces) chunks of memory of following types:

Some parts of address space may be not mapped at all.

Some systems have a "split" memory architecture where machine code, constants, and data are in different locations, and may have different address sizes. For example,

PIC18
microcontrollers have a 21-bit program counter to address machine code and constants in Flash memory, and 12-bit address registers to address data in SRAM.

Addressing schemes

A computer program can access an address given explicitly – in low-level programming this is usually called an absolute address, or sometimes a specific address, and is known as

relative address which specifies a location in relation to somewhere else (the base address). There are many more indirect addressing modes
.

Mapping logical addresses to physical and virtual memory also adds several levels of indirection; see below.

Memory models

Many programmers prefer to address memory such that there is no distinction between code space and data space (see above), as well as from physical and virtual memory (see above) — in other words, numerically identical pointers refer to exactly the same byte of RAM.

However, many early computers did not support such a flat memory model — in particular, Harvard architecture machines force program storage to be completely separate from data storage. Many modern DSPs (such as the Motorola 56000) have three separate storage areas — program storage, coefficient storage, and data storage. Some commonly used instructions fetch from all three areas simultaneously — fewer storage areas (even if there were the same total bytes of storage) would make those instructions run slower.

Memory models in x86 architecture

Early x86 processors use the segmented memory model addresses based on a combination of two numbers: a memory segment, and an offset within that segment.

Some segments are implicitly treated as code segments, dedicated for

data segments. Although the usages are different, the segments do not have different memory protections
reflecting this. In the flat memory model all segments (segment registers) are generally set to zero, and only offsets are variable.

See also

References

  1. ^ Abrahamson, Karl R. (Aug 20, 2022). "5.10.1. The Memory and Memory Addresses". East Carolina University. Retrieved Feb 3, 2023.