Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Addressing mode
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Simple addressing modes for data== Some simple addressing modes for data are shown below. The nomenclature may vary depending on platform. ==={{anchor|REGISTER PLUS REGISTER}}Register (or, register direct)=== +------+-----+-----+-----+ | 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. ==={{anchor|REGISTER PLUS IMMIEDIATE CONSTANT}}Base plus offset, and variations=== This is sometimes referred to as 'base plus displacement' or 'truncated'. +------+-----+-----+----------------+ | load | reg | base| offset | reg := RAM[base + offset] +------+-----+-----+----------------+ (Effective address = offset + contents of specified base register) 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. The offset is often small in relation to the size of current computer memories. 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. This addressing mode is closely related to the indexed absolute addressing mode. ''Example 1'': Within a subroutine a programmer will mainly be interested in the parameters and the local variables, for which one base register (the [[frame pointer]]) usually suffices. If this routine is a class method in an object-oriented language, then a second base register is needed which points 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 [[composite type]] (a record or structure), the offset can be usually used to select a field from that record. ===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. For example, <code>move.l #$FEEDABBA, D0</code> to move the immediate hex value of "FEEDABBA" into register D0. 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. [[Andrew S. Tanenbaum|Andrew Tanenbaum]] showed that 98% of all the constants in a program would fit in 13 bits (see [[Reduced instruction set computer#Instruction set philosophy|RISC design philosophy]]). ===Implicit=== +-----------------+ | clear carry bit | +-----------------+ +-------------------+ | clear Accumulator | +-------------------+ The implied addressing mode, also called the implicit addressing mode ([[x86 assembly language]]), does not explicitly specify an effective address for either the source or the destination (or sometimes both). Either the source (if any) or destination effective address (or sometimes both) is implied by the opcode. Implied addressing was quite common on older computers (up to mid-1970s). Such computers typically had only a single register in which arithmetic could be performed—the accumulator. Such [[accumulator machine]]s implicitly reference that accumulator in almost every instruction. For example, the operation < a := b + c; > can be done using the sequence < load b; add c; store a; > -- the destination (the accumulator) is implied in every "load" and "add" instruction; the source (the accumulator) is implied in every "store" instruction. Later computers generally had more than one [[general-purpose register]] or RAM location which could be the source or destination or both for arithmetic—and so later computers need some other addressing mode to specify the source and destination of arithmetic. Among the x86 instructions, some use implicit registers for one of the operands or results (multiplication, division, counting conditional jump). Some instruction sets (such as x86 and AVR) have one special-purpose register called the [[stack pointer]] which is implicitly incremented or decremented when pushing or popping data from the stack, and the source or destination effective address is (implicitly) the address stored in that stack pointer. Some other instruction sets (such as [[Motorola 68000 family|m68k]], ARM, and PowerPC) have more than one register that could be used as a stack pointer—and so use the "register autoincrement indirect" addressing mode to specify which of those registers should be used when pushing or popping data from a stack. Some current computer instruction sets (e.g. [[z/Architecture]] and [[IA-32]]/[[x86-64]]) contain some instructions with implicit operands in order to maintain backwards compatibility with earlier designs. On some instruction sets, instructions that flip the user/system mode bit, the interrupt-enable bit, etc. implicitly specify the special register that holds those bits. This simplifies the hardware necessary to trap those instructions in order to meet the [[Popek and Goldberg virtualization requirements]]—on such a system, the trap logic does not need to look at any operand (or at the final effective address), but only at the opcode. Some instruction sets have been designed where every operand is always implicitly specified in every instruction -- [[Instruction set#Number of operands|zero-operand]] CPUs.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)