FACTOID # 2: Puerto Rico has roughly the same gross state product as Montana, Wyoming and North Dakota combined.
 
 Home   Encyclopedia   Statistics   States A-Z   Flags   Maps   FAQ   About 
   
 
WHAT'S NEW
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Addressing mode

Addressing modes, a concept from computer science, are an aspect of the instruction set architecture in most central processing unit (CPU) designs. The various addressing modes that are defined in a given instruction set architecture define how machine language instructions in that architecture identify the operand (or operands) of each instruction. An addressing mode specifies how to calculate the effective memory address of an operand by using information held in registers and/or constants contained within a machine instruction or elsewhere. Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ... An instruction set, or instruction set architecture (ISA), describes the aspects of a computer architecture visible to a programmer, including the native datatypes, instructions, registers, addressing modes, memory architecture, interrupt and exception handling, and external I/O (if any). ... “CPU” redirects here. ... Machine code or machine language is a system of instructions and data directly understandable by a computers central processing unit. ... In computer science, an instruction typically refers to a single operation of a processor within a computer architecture. ... In mathematics, an operand is one of the inputs (arguments) of an operator. ... In computer architecture, a processor register is a small amount of very fast computer memory used to speed the execution of computer programs by providing quick access to commonly used values—typically, the values being in the midst of a calculation at a given point in time. ...


In computer programming, addressing modes are primarily of interest to compiler writers and to those who write code directly in assembly language. Computer programming (often shortened to programming or coding) is the process of writing, testing, and maintaining the source code of computer programs. ... A diagram of the operation of a typical multi-language, multi-target compiler. ... See the terminology section, below, regarding inconsistent use of the terms assembly and assembler. ...

Contents

Caveats

Note that there is no generally accepted way of naming the various addressing modes. In particular, different authors and computer manufacturers may give different names to the same addressing mode, or the same names to different addressing modes. Furthermore, an addressing mode which, in one given architecture, is treated as a single addressing mode may represent functionality that, in another architecture, is covered by two or more addressing modes. For example, some complex instruction set computer (CISC) computer architectures, such as the Digital Equipment Corporation (DEC) VAX, treat registers and literal/immediate constants as just another addressing mode. Others, such as the IBM System/390 and most reduced instruction set computer (RISC) designs, encode this information within the instruction. Thus, the latter machines have three distinct instruction codes for copying one register to another, copying a literal constant into a register, and copying the contents of a memory location into a register, while the VAX has only a single "MOV" instruction. A Complex Instruction Set Computer (CISC) is an instruction set architecture (ISA) in which each instruction can indicate several low-level operations, such as a load from memory, an arithmetic operation, and a memory store, all in a single instruction. ... The DEC logo Digital Equipment Corporation was a pioneering American company in the computer industry. ... VAX is a 32-bit computing architecture that supports an orthogonal instruction set (machine language) and virtual addressing (i. ... In computer science, a value is a sequence of bits that is interpreted according to some data type. ... IBM redirects here. ... The title given to this article is incorrect due to technical limitations. ... Reduced Instruction Set Computer (RISC), is a microprocessor CPU design philosophy that favors a smaller and simpler set of instructions that all take about the same amount of time to execute. ...


The addressing modes listed below are divided into code addressing and data addressing. Most computer architectures maintain this distinction, but there are, or have been, some architectures which allow (almost) all addressing modes to be used in any context.


The instructions shown below are purely representative in order to illustrate the addressing modes, and do not necessarily reflect the mnemonics used by any particular computer.

headerghjjyhjyhj 1 header 2 header 3jhjhfjfhj fj f
row 1, cell 1 row 1, cell 2 row 1, cell 3
row 2, cell 1 row 2, chdjdjhfdjhgjhfgfjell 2 row 2, cell 3

==Useful side effect==


Some processors, such as Intel x86 and the IBM/390, have a Load effective address instruction. This performs a calculation of the effective operand address, but instead of acting on that memory location, it loads the address that would have been accessed into a register. This can be useful when passing the address of an array element to a subroutine. It may also be a slightly sneaky way of doing more calculation than normal in one instruction; for example, using such an instruction with the addressing mode "base+index+offset" allows one to add two registers and a constant together in one instruction. x86 or 80x86 is the generic name of a microprocessor architecture first developed and manufactured by Intel. ...


How many addressing modes?

Different computer architectures vary greatly as to the number of addressing modes they provide. At the cost of a few extra instructions, and perhaps an extra register, it is normally possible to use the simpler addressing modes instead of the more complicated modes. It has proven[citation needed] much easier to design pipelined CPUs if the only addressing modes available are simple ones.


Most RISC machines have only about five simple addressing modes, while CISC machines such as the DEC VAX supermini have over a dozen addressing modes, some of which are quite complicated. The IBM System/360 mainframe had only three addressing modes; a few more have been added for the System/390. System/360 Model 65 operators console, with register value lamps and toggle switches (middle of picture) and emergency pull switch (upper right). ... The title given to this article is incorrect due to technical limitations. ...


When there are only a few addressing modes, the particular addressing mode required is usually encoded within the instruction code (e.g. IBM System/390, most RISC). But when there are lots of addressing modes, a specific field is often set aside in the instruction to specify the addressing mode. The DEC VAX allowed multiple memory operands for almost all instructions, and so reserved the first few bits of each operand specifier to indicate the addressing mode for that particular operand.


Even on a computer with many addressing modes, measurements of actual programs[citation needed] indicate that the simple addressing modes listed below account for some 90% or more of all addressing modes used. Since most such measurements are based on code generated from high-level languages by compilers, this reflects to some extent the limitations of the compilers being used.


Simple addressing modes for code

Absolute

 +----+------------------------------+ |jump| address | +----+------------------------------+ 

Effective address = address as given in instruction


PC-relative

 +------+-----+-----+----------------+ |jumpEQ| reg1| reg2| offset | jump relative if reg1=reg2 +------+-----+-----+----------------+ 

Effective address = offset plus address of next instruction.


The offset is usually signed.


This is particularly useful in connection with conditional jumps, because you usually only want to jump to some nearby instruction (in a high-level language most if or while statements are reasonably short). Measurements of actual programs suggest that an 8 or 10 bit offset is large enough for some 90% of conditional jumps.


Another advantage of program-relative addressing is that the code may be position-independent, i.e. it can be loaded anywhere in memory without the need to adjust any addresses. In computing, position independent code (PIC) is object code that can execute at different locations in memory. ...


Register indirect

 +-------+-----+ |jumpVia| reg | +-------+-----+ 

Effective address = contents of specified register.


The effect is to transfer control to the instruction whose address is in the specified register. Such an instruction is often used for returning from a subroutine call, if the actual call would have placed the return address in a register. In both conventional and electronic messaging, a return address is an explicit inclusion of the address of the person sending the message. ...


Simple addressing modes for data

Register

 +------+-----+-----+-----+ | mul | reg1| reg2| reg3| reg1 := reg2 * reg3; +------+-----+-----+-----+ 

This "addressing mode" does not have an effective address and is not considered to be an addressing mode on some computers.


In this example, all the operands are in registers, and the result is placed in a register.


Base plus offset, and variations

 +------+-----+-----+----------------+ | load | reg | base| offset | +------+-----+-----+----------------+ 

Effective address = offset plus contents of specified base register.


The offset is usually a signed 16-bit value (though the 80386 expanded it to 32 bits). In computer science, an offset within an array or other data structure object is an integer indicating the distance (displacement) from the beginning of the object up until a given element or point, presumably within the same object. ... The Intel 80386 is a microprocessor which was used as the central processing unit (CPU) of many personal computers from 1986 until 1994 and later. ...


If the offset is zero, this becomes an example of register indirect addressing; the effective address is just the value in the base register.


On many RISC machines, register 0 is fixed at the value zero. If register 0 is used as the base register, this becomes an example of absolute addressing. However, only a small portion of memory can be accessed (64 kilobytes, if the offset is 16 bits).


The 16-bit offset may seem very small in relation to the size of current computer memories (which is why the 80386 expanded it to 32-bit). It could be worse: IBM System/360 mainframes only have an unsigned 12-bit offset. However, the principle of locality of reference applies: over a short time span, most of the data items a program wants to access are fairly close to each other. The Intel 80386 is a microprocessor which was used as the central processing unit (CPU) of many personal computers from 1986 until 1994 and later. ... It has been suggested that this article or section be merged with Memory locality. ...


Example 1: Within a subroutine you will mainly be interested in the parameters and the local variables, which will rarely exceed 64 Kbytes, for which one base register suffices. If this routine is a class method in an object-oriented language, you will need a second base register pointing at the attributes for the current object (this or self in some high level languages).


Example 2: If the base register contains the address of a record or structure, the offset can be used to select a field from that record (most records/structures are less than 32 kilobytes in size).


Immediate/literal

 +------+-----+-----+----------------+ | add | reg1| reg2| constant | reg1 := reg2 + constant; +------+-----+-----+----------------+ 

This "addressing mode" does not have an effective address, and is not considered to be an addressing mode on some computers.


The constant might be signed or unsigned.


Instead of using an operand from memory, the value of the operand is held within the instruction itself. On the DEC VAX machine, the literal operand sizes could be 6, 8, 16, or 32 bits long.


Other addressing modes for code or data

Absolute/Direct

 +------+-----+--------------------------------------+ | load | reg | address | +------+-----+--------------------------------------+ 

Effective address = address as given in instruction. An absolute address in computing is the precise indication of a memory location without the use of any intermediate reference. ...


This requires space in an instruction for quite a large address. It is often available on CISC machines which have variable-length instructions, such as x86. x86 or 80x86 is the generic name of a microprocessor architecture first developed and manufactured by Intel. ...


Some RISC machines have a special Load Upper Literal instruction which places a 16-bit constant in the top half of a register. An OR literal instruction can be used to insert a 16-bit constant in the lower half of that register, so that a full 32-bit address can then be used via the register-indirect addressing mode, which itself is provided as "base-plus-offset" with an offset of 0.


Indexed absolute

 +------+-----+-----+--------------------------------+ | load | reg |index| address | +------+-----+-----+--------------------------------+ 

Effective address = address plus contents of specified index register.


This also requires space in an instruction for quite a large address. The address could be the start of an array or vector, and the index could select the particular array element required. The processor may scale the index register to allow for the size of each array element. The stride of an array, in computer programming, refers to the number of locations in memory between successive array elements. ...


Note that this is more or less the same as base-plus-offset addressing mode, except that the offset in this case is large enough to address any memory location.


Base plus index

 +------+-----+-----+-----+ | load | reg | base|index| +------+-----+-----+-----+ 

Effective address = contents of specified base register plus contents of specified index register. An index register in a computer CPU is a processor register used for modifying operand addresses during the run of a program, typically for doing vector/array operations. ...


The base register could contain the start address of an array or vector, and the index could select the particular array element required. The processor may scale the index register to allow for the size of each array element. This could be used for accessing elements of an array passed as a parameter. The stride of an array, in computer programming, refers to the number of locations in memory between successive array elements. ...


Base plus index plus offset

 +------+-----+-----+-----+----------------+ | load | reg | base|index| offset | +------+-----+-----+-----+----------------+ 

Effective address = offset plus contents of specified base register plus contents of specified index register.


The base register could contain the start address of an array or vector of records, the index could select the particular record required, and the offset could select a field within that record. The processor may scale the index register to allow for the size of each array element. The stride of an array, in computer programming, refers to the number of locations in memory between successive array elements. ...


Scaled

 +------+-----+-----+-----+ | load | reg | base|index| +------+-----+-----+-----+ 

Effective address = contents of specified base register plus scaled contents of specified index register.


The base register could contain the start address of an array or vector, and the index could contain the number of the particular array element required.


This addressing mode dynamically scales the value in the index register to allow for the size of each array element, e.g. if the array elements are double precision floating-point numbers occupying 8 bytes each then the value in the index register is multiplied by 8 before being used in the effective address calculation. The scale factor is normally restricted to being a power of two, so that shifting rather than multiplication can be used. In mathematics, a power of two is any of the nonnegative integer powers of the number two; in other words, two times itself a certain number of times. ... In computer programming, a bitwise operation operates on one or two bit patterns or binary numerals at the level of their individual bits. ...


Register indirect

 +------+-----+-----+ | load | reg | base| +------+-----+-----+ 

Effective address = contents of base register.


A few computers have this as a distinct addressing mode. Many computers just use base plus offset with an offset value of 0.


Register autoincrement indirect

 +------+-----+-----+ | load | reg | base| +------+-----+-----+ 

Effective address = contents of base register.


After determining the effective address, the value in the base register is incremented by the size of the data item that is to be accessed.


Within a loop, this addressing mode can be used to step through all the elements of an array or vector. A stack can be implemented by using this mode in conjunction with the next addressing mode (autodecrement). Look up Stack in Wiktionary, the free dictionary. ...


In high-level languages it is often thought to be a good idea that functions which return a result should not have side effects (lack of side effects makes program understanding and validation much easier). This addressing mode has a side effect in that the base register is altered. If the subsequent memory access causes an error (e.g. page fault, bus error, address error) leading to an interrupt, then restarting the instruction becomes much more problematic since one or more registers may need to be set back to the state they were in before the instruction originally started.


There have been at least two computer architectures which have had implementation problems with regard to recovery from interrupts when this addressing mode is used:

  • Motorola 68000. Could have one or two autoincrement register operands. The 68010+ resolved the problem by saving the processor's internal state on bus or address errors.
  • DEC VAX. Could have up to 6 autoincrement register operands. Each operand access could cause two page faults (if operands happened to straddle a page boundary). Of course the instruction itself could be over 50 bytes long and might straddle a page boundary as well!

The Motorola MC68010 processor is a 16/32-bit microprocessor from Motorola, made in the early 1980s. ... In computing, a bus error is generally an attempt to access memory that the CPU cannot physically address. ... In computer storage technology, a page is a fixed length block of memory that is used as a unit of transfer between physical memory and external storage like a disk, and a page fault is an interrupt (or exception) to the software raised by the hardware, when a program accesses...

Autodecrement register indirect

 +------+-----+-----+ | load | reg | base| +------+-----+-----+ 

Before determining the effective address, the value in the base register is decremented by the size of the data item which is to be accessed.


Effective address = new contents of base register.


Within a loop, this addressing mode can be used to step backwards through all the elements of an array or vector. A stack can be implemented by using this mode in conjunction with the previous addressing mode (autoincrement).


See the discussion of side-effects under the autoincrement addressing mode.


Memory indirect

Any of the addressing modes mentioned in this article could have an extra bit to indicate indirect addressing, i.e. the address calculated using some mode is in fact the address of a location (typically a complete word) which contains the actual effective address. In computing, word is a term for the natural unit of data used by a particular computer design. ...


Indirect addressing may be used for code or data. It can make implementation of pointers or references very much easier, and can also make it easier to call subroutines which are not otherwise addressable. Indirect addressing does carry a performance penalty due to the extra memory access involved.


Some early minicomputers (e.g. DEC PDP-8, Data General Nova) had only a few registers and only a limited addressing range (8 bits). Hence the use of memory indirect addressing was almost the only way of referring to any significant amount of memory. A PDP-8 on display at the Smithsonians National Museum of American History in Washington, D.C.. This example is from the first generation of PDP-8s, built with discrete transistors and later known as the Straight 8. ... Data General SuperNova The Data General Nova was a popular 16-bit minicomputer built by the United States company Data General starting in 1969. ...


PC-relative

The x86-64 architecture supports "RIP-relative" addressing, which uses the 64-bit instruction pointer RIP as a base register. This encourages position-independent code. The AMD64 or x86-64 is a 64-bit processor architecture invented by AMD. It is a superset of the x86 architecture, which it natively supports. ... The program counter (also called the instruction pointer in some computers) is a register in a computer processor which indicates where the computer is in its instruction sequence. ... In computing, position independent code (PIC) is object code that can execute at different locations in memory. ...


Obsolete addressing modes

The addressing modes listed here were used in the 1950–1980 time frame, but are no longer available on most current computers. This list is by no means complete; there have been many other interesting and peculiar addressing modes used from time to time, e.g. absolute-plus-logical-OR of two or three index registers.[citation needed]


Multi-level memory indirect

If the word size is larger than the address size, then the word referenced for memory-indirect addressing could itself have an indirect flag set to indicate another memory indirect cycle. Care is needed to ensure that a chain of indirect addresses does not refer to itself; if it did, you could get an infinite loop while trying to resolve an address.


The DEC PDP-10 computer with 18-bit addresses and 36-bit words allowed multi-level indirect addressing with the possibility of using an index register at each stage as well. The PDP-10 was a computer manufactured by Digital Equipment Corporation (DEC) from the late 1960s on; the name stands for Programmed Data Processor model 10. It was the machine that made time-sharing common; it looms large in hacker folklore because of its adoption in the 1970s by many...


Memory-mapped registers

On some computers, the registers were regarded as occupying the first 8 or 16 words of memory (e.g. ICL 1900, DEC PDP-10). This meant that there was no need for a separate "Add register to register" instruction — you could just use the "add memory to register" instruction. International Computers Ltd, or ICL, was a large British computer hardware company that operated from 1968 until 2002, when it was renamed Fujitsu Services Limited after its parent company, Fujitsu. ...


In the case of early models of the PDP-10, which did not have any cache memory, you could actually load a tight inner loop into the first few words of memory (the fast registers in fact), and have it run much faster than if it would have in magnetic core memory.


Later models of the DEC PDP-11 series mapped the registers onto addresses in the input/output area, but this was primarily intended to allow remote diagnostics. Confusingly, the 16-bit registers were mapped onto consecutive 8-bit byte addresses. The PDP-11 was a 16-bit minicomputer sold by Digital Equipment Corp. ...


Memory indirect, autoincrement

On some early minicomputers (e.g. DEC PDP-8, Data General Nova), there were typically 16 special memory locations.[citation needed] When accessed via memory indirect addressing, 8 would automatically increment after use and 8 would automatically decrement after use. This made it very easy to step through memory in loops without using any registers. A PDP-8 on display at the Smithsonians National Museum of American History in Washington, D.C.. This example is from the first generation of PDP-8s, built with discrete transistors and later known as the Straight 8. ... Data General SuperNova The Data General Nova was a popular 16-bit minicomputer built by the United States company Data General starting in 1969. ...


Zero page

In the MOS Technology 6502 the first 256 bytes of memory could be accessed very rapidly. The reason was that the 6502 was lacking in registers which were not special function registers. To use zero-page access, an 8-bit address would be used, saving one clock cycle as compared with using a 16-bit address. An operating system would use much of the zero page, so it was not as useful as it might have seemed. The zero page is the memory address page at the absolute beginning of a computers address space (the lowermost page, covered by the memory address range 0 . ... The MOS Technology 6502 is an 8-bit microprocessor that was designed by Chuck Peddle for MOS Technology in 1975. ... // An operating system (OS) is the software that manages the sharing of the resources of a computer. ... The zero page is the memory address page at the absolute beginning of a computers address space (the lowermost page, covered by the memory address range 0 . ...


Scaled index with bounds checking

This is similar to scaled index addressing, except that the instruction has two extra operands (typically constants), and the hardware would check that the index value was between these bounds.


Another variation uses vector descriptors to hold the bounds; this makes it easy to implement dynamically allocated arrays and still have full bounds checking.


Register indirect to byte within word

The DEC PDP-10 computer used 36-bit words. It had a special addressing mode which allowed memory to be treated as a sequence of bytes (bytes could be any size from 1 bit to 36 bits). A one-word sequence descriptor held the current word address within the sequence, a bit position within a word, and the size of each byte. The PDP-10 was a computer manufactured by Digital Equipment Corporation (DEC) from the late 1960s on; the name stands for Programmed Data Processor model 10. It was the machine that made time-sharing common; it looms large in hacker folklore because of its adoption in the 1970s by many...


Instructions existed to load and store bytes via this descriptor, and to increment the descriptor to point at the next byte (bytes were not split across word boundaries). Much DEC software used five 7-bit bytes per word (plain ASCII characters), with 1 bit unused per word. Implementations of C had to use four 9-bit bytes per word, since C assumes that you can access every bit of memory by accessing consecutive bytes C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ...


Index next instruction

The Elliott 503 computer had 39-bit words, only used absolute addressing, and did not have any index registers. Thus, indirect jumps, or jumps through registers, were not supported in the instruction set. Instead, it could be instructed to add the contents of the current memory word to the next instruction. Adding a small value to the next instruction to be executed could, for example, change a JUMP 0 into a JUMP 20, thus creating the effect of an indirect jump via self-modifying code.[1][2] In computer science, self-modifying code is code that alters its own instructions, whether or not it is on purpose, while it is executing. ...


  Results from FactBites:
 
Addressing mode - Wikipedia, the free encyclopedia (2674 words)
Addressing modes, a concept from computer science, are an aspect of the instruction set architecture in most central processing unit (CPU) designs.
The various addressing modes that are defined in a given instruction set architecture define how machine language instructions in that architecture identify the operand (or operands) of each instruction.
Furthermore, an addressing mode which, in one given architecture, is treated as a single addressing mode may represent functionality that, in another architecture, is covered by two or more addressing modes.
Addressing mode - definition of Addressing mode in Encyclopedia (2728 words)
In computer programming, addressing modes are primarily of interest to compiler writers and to those (few nowadays) who use assembly language.
An addressing mode specifies how to calculate the effective memory address of an operand by using information held in registers and/or constants contained within a machine instruction.
In particular, different authors and/or computer manufacturers may give different names to the same addressing mode, or the same names to different addressing modes, so you really need to look carefully at exactly how the effective address is determined in each particular case.
  More results at FactBites »

 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m