Hardware Reference
In-Depth Information
5.4.2 Immediate Addressing
The simplest way for an instruction to specify an operand is for the address
part of the instruction actually to contain the operand itself rather than an address
or other information describing where the operand is. Such an operand is called an
immediate operand because it is automatically fetched from memory at the same
time the instruction itself is fetched; hence it is immediately available for use. A
possible immediate instruction for loading register R1 with the constant 4 is shown
in Fig. 5-16.
MOV
R1
4
Figure 5-16. An immediate instruction for loading 4 into register 1.
Immediate addressing has the virtue of not requiring an extra memory refer-
ence to fetch the operand. It has the disadvantage that only a constant can be sup-
plied this way. Also, the number of values is limited by the size of the field. Still,
many architectures use this technique for specifying small integer constants.
5.4.3 Direct Addressing
A method for specifying an operand in memory is just to give its full address.
This mode is called direct addressing . Like immediate addressing, direct ad-
dressing is restricted in its use: the instruction will always access exactly the same
memory location. So while the value can change, the location cannot. Thus direct
addressing can only be used to access global variables whose address is known at
compile time. Nevertheless, many programs have global variables, so this mode is
widely used. The details of how the computer knows which addresses are immedi-
ate and which are direct will be discussed later.
5.4.4 Register Addressing
Register addressing is conceptually the same as direct addressing but specifies
a register instead of a memory location. Because registers are so important (due to
fast access and short addresses) this addressing mode is the most common one on
most computers. Many compilers go to great lengths to determine which variables
will be accessed most often (for example, a loop index) and put these variables in
registers.
This addressing mode is known simply as register mode . In load/store archi-
tectures such as the OMAP4420 ARM architecture, nearly all instructions use this
addressing mode exclusively. The only time this addressing mode is not used is
when an operand is moved from memory into a register ( LDR instruction) or from a
register to memory ( STR instruction). Even for those instructions, one of the oper-
ands is a register—where the memory word is to come from or go to.
 
 
 
 
Search WWH ::




Custom Search