Addressing (computer architecture)

from Wikipedia, the free encyclopedia

In programming, addressing is the definition of which operands (e.g. data fields ) a machine command refers to. The operands can be addressed in different ways ( addressing type or addressing mode ), for example by specifying them directly in the command or by referring to a memory address . The operation code and the information about the operands contained in the machine command only in coded form are decisive for the type of addressing to be used .

In assembler programming, the programmer himself determines the type of addressing by choosing certain operation codes (and the associated parameters). When using higher programming languages, the machine commands are automatically generated by compilers (and thus also their addressing types are specified), mostly without the direct influence of the programmer. The processor decodes the machine commands during execution and carries out the corresponding address calculations as well as loading the data to be used in the command.

The different types of addressing are one aspect of processor design. They are defined within a given instruction set architecture and determine how the actual (physical) memory address of its operands is determined / calculated for each instruction of the machine language , for example with the aid of the information stored in registers and / or constants within the machine instruction .

If a command relates to several operands (source and / or target fields), the information required for addressing is required / available separately for each operand. Further parameters contained in the machine command (such as information on the length of operands, jump indicators from logical commands such as equal or greater) are not used for addressing in the narrower sense.

Differences related to addressing types

Different names

Please note that there is no universally valid naming convention for the different addressing types / modes. In particular, different authors or hardware manufacturers sometimes use different terms for the same address mode, or the same name for different modes.

The following distinctions in the naming of addressing types are widespread. A fundamental distinction is that between

  • logical or program-side addresses on the one hand (programming level). Logical addresses are divided into absolute, relative, indirect and symbolic addresses, although different precise characterizations, delimitations and overlaps can be found.
  • Machine addresses or physical addresses on the other hand (machine command level). Machine addresses are also often called real addresses.

In addition to the different names, an addressing mode that is treated as a single mode in one architecture can stand for a functionality that is covered by two or more modes in another architecture.

Different meanings in detail

With 'addressing' different things can be understood in detail:

  • The work involved in programming in machine-level languages: choosing commands, coding operators
  • The information in the machine command referring to the operators in code form
  • The functionality of the processor with which it determines the actual addresses

Naming the operators in a higher-level programming language (MOVE A TO B), in the broader sense also a type of addressing, does not count towards the meaning of 'addressing, addressing mode' dealt with here in the article .

Differences between instruction sets

The instruction sets of individual processor types differ not only in terms of performance, but also in terms of addressing. Significant examples are given below:

  • In certain instruction sets the opcode contains the register number - while in other cases the register number is contained in a separate parameter field. Accordingly, such an instruction set contains many more operation codes.
  • In the System / 390 processor family , only 1-digit direct values ​​('immediate') can be contained in the machine command. For 'indexed addressing', the offset value for an address specification is stored together with the register number in a 'half-word' (4 bits register number, 12 bits offset / integer).

Typical addressing types of a processor

Scheme for alternative types of addressing for machine commands

In the simplest case, the individual memory locations are numbered consecutively from 0 ( linear address space ). An address then represents the number of a specific memory location. The registers of a processor are usually also numbered consecutively.

Because of the different types of addressing, machine commands have different structures, for example one operand belongs to one operation code, and several operands to others as the source or destination of the command. For command examples, see individual addressing types.

Since there are usually only a few registers but many memory locations in a processor, register addresses are shorter than main memory addresses. Example: In a system with a processor with 16 registers and 4 GiB memory, a register address requires 4 bits, while a main memory address requires 32 bits. In machine language , register addresses are often stored together with the instruction code in a memory word - they are therefore available to the processor without further memory accesses, while the processor requires further memory accesses - and thus execution time - to transmit each main memory address.

With a purely orthogonal command set , each command can be used in any type of addressing. The common processor families, however, have many restrictions, so that the (assembler) programmer has to find out about the “programming model” of the processor, which types of addressing are actually available for which commands.

Addressing types that work from the main memory into the main memory are only used today in integrated circuits and embedded systems with little memory space. High execution speeds can only be achieved with commands that work in the registers - this is why processors optimized for performance today usually have a load / store architecture .

Register addressing

With register addressing (in English "register direct") the instruction refers to the content of a processor register. In the case of 'read' commands, the operand is already available in the register and no longer needs to be loaded from memory. In the case of implicit register addressing, the register implicitly defined for the opcode is used (example: the opcode implicitly refers to the accumulator). With explicit register addressing, the number of the register is entered in a register field of the machine command or is part of the command code.

# Addiere den Inhalt von Register 1 mit dem Inhalt des Registers 2, speichere Ergebnis in Register 3
add_rrr R2, R1, R3
# Also drei Adressierungen:
# Quelle_1 .. Register,
# Quelle_2 .. Register,
# Ziel_1 .. Register

Immediate addressing

The operand or operands (not their address) are part of the command, stored in the command code itself or in the memory words that immediately follow the command code in the memory . The instruction usually contains an additional operand.

# Lade das Akkumulatorregister mit dem Wert 22 (101102) (nicht mit dem Inhalt von Speicherplatz 22)
load_direct acc, 10110
# Also zwei Adressierungen:
# Ziel_1 .. Register
# Quelle_1 .. unmittelbar angegebener Wert

Absolute or direct addressing

With this type of addressing, it is not the operand itself, but its memory address (where the actual data can be found) that is specified directly and completely in the command (reference level 1).

# Addiere den Inhalt von Adresse 22 (= 101102) und Adresse 6 (= 001102)
 und speichere das Ergebnis in Adresse 1 (= 000012)
add_AdrAdrAdr 10110, 00110, 00001

Indexed and relative addressing

Both types of addressing use a register to address memory cells in the main memory. With indexed addressing, the content of a so-called index register is added to an address formed from other address information. Example: There is a base address register (e.g. the special register "index") to which the parameter given is added as an offset . Often negative offsets are also possible. The result of the addressing is the address of the operand, i. H. this points to the operand (reference level 1)

# Addiere den Inhalt der Adressen (Index+002 =22) und (Index+012 =23)
 und speichere das Ergebnis in Adresse (Index+102 =24)
load_direct index, 10110     # lade (Basis-)Adresse 22 ins Indexregister
add_iii 00, 01, 10

Often these relative addresses have fewer digits (for example 8 bits, i.e. 8 binary digits; with an 8-bit opcode, the overall command is then 8 + 3 * 8 = 32-bit length), which on the one hand saves space and possibly "saves the overall command including addressing data once loadable "makes; on the other hand, this restricts the address space (in the example only index + 00000000 2 .. index + 11111111 2 is possible).

This type of access is mainly used for access to arrays or composite data types.

Since a computer generally has more than one register, the instruction must contain an indication of which register is to be used as the base register. In the example it is assumed that the register "index" is fixed for this.

The relative addressing is similar, but the command counter ( program counter , PC) is used instead of the index register . The addressing does not take place relative to an address specified in the index register, but rather relative to the command counter, i.e. H. the location that contains the command itself.

Sometimes the offset can also be given in a register, in particular with so-called segmented addressing . The base address register is then often called the “segment register”.

Indirect addressing

The instruction points to a register or a memory address in main memory (in the case of the 6502 in its zeropage ). The effective address of the operation results from the content of the corresponding register or the corresponding memory cell (s) (reference level 2). Possibly. the content of a further register (index register) is added to the address determined in this way (indirect-indexed addressing).

The indirect addressing was patented by Heinz Schecher in 1953 .

Virtual addressing

Addressing tools provided by the operating system are described here.

Operating systems use virtual addressing to be able to execute programs that require more storage space than is actually available in terms of physical memory in RAM . The entire available storage space is called the virtual address space and access to the addresses contained therein is called virtual addressing. The operating system uses a virtual memory management , which is a memory management unit serves to outsource to the hard drive to parts of the program and load into memory, if necessary, if a selected address outside of the RAM is located address space. The addresses are specified either directly, relatively, indexed or symbolically.

literature

  • Hans Liebig: Computer organization: The principles . Springer-Verlag, 3rd edition, 2003, ISBN 978-3-540-00027-3
  • Edited by Thomas Beierlein, Olaf Hagenbruch: Pocket book on microprocessor technology . Carl Hanser Verlag, 4th edition, 2010, ISBN 978-3-446-42331-2