Addressing mode

Addressing is in the programming setting, on which operands (for example, data fields) refers to a machine instruction. The operands can be addressed in different ways ( " addressing " or " addressing mode " ), for example by directly specifying the command or a reference to a memory address. The determining factor for the increase of addressing are the operation code and the information contained only in coded form in the machine instruction on the operands.

The assembly programming, the programmer specifies the choice of particular operational codes ( and the associated parameters ) to specify the addressing itself. By using high-level programming the machine instructions of compilers are automatically generated ( and thus also their addressing modes set ), usually without direct influence of the programmer. The processor decodes the machine instructions in the execution, and executes the appropriate address calculations and loading to be used in the command data.

The various addressing modes are an aspect of processor designs. They are defined within a given instruction set architecture and determine the actual ( physical) memory address of its operand determined / calculated, for example, using the information stored in registers and / or constants within the machine instruction as for each instruction of the machine language.

Does a command on multiple operand (source and / or destination fields), as necessary for the addressing information for each operand are separated required / available. More in the machine instruction parameters included (such as information on the length of operands, jump indicators of logical commands such as equal to or greater ) are not used for addressing in the strict sense.

  • 2.1 register addressing
  • 2.2 Immediate Addressing
  • 2.3 Absolute or direct addressing
  • 2.4 Indexed and relative addressing
  • 2.5 Indirect Addressing

Differences with respect to addressing modes

Different designations

Note that no universal naming for the different types of addressing / modes exist. In particular, partially different authors or even hardware manufacturers use different names for the same address mode, or even the same names for different modes.

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

  • Logical or programmatic addresses one hand ( level programming). Logical addresses are divided into absolute, relative, indirect and symbolic addresses, but you will find various precise characterizations, boundaries and overlaps.
  • Machine addresses or physical addresses on the other hand ( level machine instruction ). Machine addresses are also often referred to as real addresses.

In addition to the description, a different addressing mode, which is treated in an architecture as a single mode, represent functionality that is covered in a different architecture of two or more modes.

In detail, different meanings

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

  • The activity in programming in machine-oriented languages: choice of commands, thereby encoding the operators
  • The footnote referring to the operators in code form data in machine instruction
  • The functionality of the processor with which it determines the actual addresses

In a high level language to name the operators ( MOVE A TO B), in a broader sense, a kind of address that is not one of the items discussed here in the field of meaning, addressing, addressing mode.

Differences between instruction sets

The instruction sets of individual processor types differ concerning not only the scope but also the addressing. Following significant examples are listed below:

  • In particular command sets the opcode contains the register number - while in other cases, registration number is contained in a separate parameter field. Accordingly, such an instruction set contains a lot more opcodes.
  • In the System/390 processor family only 1- digit direct values ​​( ' immediate ') may be included in the machine instruction. For, indexed addressing halfword ' (4 bits register number, 12 bits of offset / integer) ', the offset value for an address specification along with the register number in a 'is stored.

Typical addressing modes of a processor

In the simplest case, the individual memory locations of the memory starting from 0 are numbered (linear address space). An address is then the number of a particular memory location represents the register of a processor are also numbered as a rule.

Due to the different addressing modes include machine instructions in different structures, for example one of an opcode, an operand, a plurality of operands to other than the source or destination of the command. Command examples, see individual addressing.

Since in a processor usually only a few registers, but many memories exist, register addresses are shorter than main memory addresses. Example: On a system with a processor with 16 registers and 4 GiB memory register address requires 4 bits, while a main memory address requires 32 bits. In the machine language register addresses are often stored with the command code in a memory word - are therefore the processor without additional memory accesses are available, while the processor for transmitting each main memory address more memory accesses - and thus execution time - needed.

In a purely orthogonal instruction set, each command in each addressing mode can be used. In the real world, however, processors have many limitations, so the programmer must inform himself of the " programming model " of the processor, which addressing modes are involved in which commands actually available.

Addressing modes that operate from main memory into the main memory, are now used only in integrated circuits and embedded systems with little memory. High design speeds can be reached only with commands that work in the registers - therefore have a performance-optimized processors today mostly a load / store architecture.

Register addressing

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

# Add the contents of register 1 with the contents of register 2, store result in register 3 add_rrr R2, R1, R3 # So three addressing modes: # Quelle_1 .. registers, # Quelle_2 .. registers, # TARGET_1 register .. Immediate addressing

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

# Load the accumulator with the value 22 (101102) (not with the content of memory location 22) load_direct acc, 10110 # So two addressing modes: # TARGET_1 register .. # Quelle_1 .. immediately given value Absolute or direct addressing

In this addressing mode is not the operand itself, but its memory address ( where to find the actual data ) specified directly and fully in command ( reference level 1).

# Add the contents of address 22 ( = 101102 ) and address 6 ( = 001102 )    and store the result in address 1 (= 000012 ) add_AdrAdrAdr 10110, 00110, 00001 Indexed and relative addressing

Both addressing modes use a register for addressing memory cells in the main memory. In the indexed addressing the content of a so-called index register are added to an address formed from other address information. Example: There is a base address registers (eg, the special register " index", to which the cogiven parameter is added as an offset Often negative offsets are possible The result of addressing is the address of the operand d. . is, this points to the operand ( reference level 1)

# Add the contents of the addresses (index 002 = 22) and (index = 23 012 )    and store the result in address (index 102 = 24) load_direct index, 10110 # load (base) address 22 into the index register add_iii 00, 01, 10 Often these relative addresses fewer places ( for example, 8 bits, ie 8 binary digits, 8- bit opcode of the total command then has 8 3 * 8 = 32 bits in length ), which on the one hand saves space and the overall command including addressing data possibly "on once loaded " makes; On the other hand, this limits the address space (in the example is only index 000000002 111111112 .. index possible).

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

And because it generally has more than one register, the command must indicate which register is to be used as the base register. In the example it is assumed that noted in the register "index" is fixed.

The relative addressing is similar, but, instead of the index register of the instruction pointer ( program counter, PC) used. Addressing is performed as a non- relative to a specified address in the index register, but relative to the program counter, ie the memory location that contains the command itself.

Sometimes the offset can also be provided in a register, in particular in the so-called segmented addressing. The base address register is then often referred to as " segment register ".

Indirect addressing

Target of the command is a memory cell in the main memory. The address is given about the content of an explicitly specified register ( or in 6502 on a pair of bytes in the zero page ) that points to a memory cell in the main memory that contains the address of the actual command target. The information in the command contain the address of the address of the operand (Reference 2).

Virtual addressing

Here tools are described for addressing that provides the operating system.

Operating systems use the Virtual addressing to run programs that require more memory than is available of physical memory in RAM at all. The entire available memory space is referred to as a virtual address space and the access to the addresses contained in the virtual address. The operating system uses a virtual memory management, a Memory Management Unit uses to outsource parts of the program on the hard drive and, if necessary, to load into memory, if a selected address is outside of the address space in RAM. The indication of the addresses is carried out either directly, relative, indexed, or even symbolic.

30997
de