[go: up one dir, main page]

0% found this document useful (0 votes)
5 views10 pages

CSC204

The document discusses addressing modes in computer architecture, detailing how operands are specified in CPU instructions. It classifies instructions based on the number of operands, including three-address, two-address, one-and-half-address, one-address, and zero-address instructions, and describes various addressing modes such as immediate, direct, indirect, and indexed. Additionally, it outlines different types of instructions, including data movement, arithmetic and logical instructions, and input/output instructions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views10 pages

CSC204

The document discusses addressing modes in computer architecture, detailing how operands are specified in CPU instructions. It classifies instructions based on the number of operands, including three-address, two-address, one-and-half-address, one-address, and zero-address instructions, and describes various addressing modes such as immediate, direct, indirect, and indexed. Additionally, it outlines different types of instructions, including data movement, arithmetic and logical instructions, and input/output instructions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

SA’ADU ZUNGUR UNIVERSITY BAUCHI

DEPARTMENT OF MATHEMATICAL SCIENCES


FACULTY OF SCIENCE
(CSC204/IFT212) Computer Architecture and Organization

ADDRESSING MODES
Information involved in any operation performed by the CPU needs to be
addressed. In computer terminology, such information is called the operand.
Therefore, any instruction issued by the processor must carry at least two types of
information. These are the operation to be performed, encoded in what is called the
op-code field, and the address information of the operand on which the operation is
to be performed, encoded in what is called the address field.
Instructions can be classified based on the number of operands as: three-address,
two-address, one-and-half-address, one-address, and zero-address
Noted that in presenting these examples, the convention operation, source,
destination is used to express any instruction. In that convention, operation
represents the operation to be performed, for example, add, subtract, write, or read.
The source field represents the source operand(s). The source operand can be a
constant, a value stored in a register, or a value stored in the memory. The
destination field represents the place where the result of the operation is to be
stored, for example, a register or a memory location.
A three-address instruction takes the form operation add-1, add-2, add-3. In this
form, each of add-1, add-2, and add-3 refers to a register or to a memory location.
Consider, for example, the instruction ADD R1,R2,R3. This instruction indicates
that the operation to be performed is addition. It also indicates that the values to be
added are those stored in registers R1 and R2 that the results should be stored in
register R3. An example of a three-address instruction that refers to memory
locations may take the form ADD A,B,C. The instruction adds the contents of
memory location A to the contents of memory location B and stores the result in
memory location C.
A two-address instruction takes the form operation add-1, add-2. In this form, each
of add-1 and add-2 refers to a register or to a memory location. Consider, for
example, the instruction ADD R1,R2. This instruction adds the contents of register
R1 to the contents of register R2 and stores the results in register R2. The original
contents of register R2 are lost due to this operation while the original contents of
register R1 remain intact. This instruction is equivalent to a three-address
instruction of the form ADD R1,R2,R3. A similar instruction that uses memory
locations instead of registers can take the form ADD A,B. In this case, the contents
of memory location A are added to the contents of memory location B and the
result is used to override the original contents of memory location B.
The operation performed by the three-address instruction ADD A,B,C can be
performed by the two two-address instructions MOVE B,C and ADD A,C. This is
because the first instruction moves the contents of location B into location C and
the second instruction adds the contents of location A to those of location C (the
contents of location B) and stores the result in location C.
A one-address instruction takes the form ADD R1. In this case the instruction
implicitly refers to a register, called the Accumulator Racc, such that the contents of
the accumulator is added to the contents of the register R1 and the results are stored
back into the accumulator Racc. If a memory location is used instead of a register,
then an instruction of the form ADD B is used. In this case, the instruction adds the
content of the accumulator Racc to the content of memory location B and stores the
result back into the accumulator Racc. The instruction ADD R1 is equivalent to the
three-address instruction ADD R1,Racc,Racc or to the two-address instruction ADD
R1,Racc.
Between the two- and the one-address instruction, there can be a one-and-half
address instruction. Consider, for example, the instruction ADD B,R1. In this case,
the instruction adds the contents of register R1 to the contents of memory location
B and stores the result in register R1. Owing to the fact that the instruction uses two
types of addressing, that is, a register and a memory location, it is called a one-
andhalf-address instruction. This is because register addressing needs a smaller
number of bits than those needed by memory addressing.
It is interesting to indicate that there exist zero-address instructions. These are the
instructions that use stack operation. A stack is a data organization mechanism in
which the last data item stored is the first data item retrieved. Two specific
operations can be performed on a stack. These are the push and the pop operations.
As can be seen, a specific register, called the stack pointer (SP), is used to indicate
the stack location that can be addressed. In the stack push operation, the SP value is
used to indicate the location (called the top of the stack) in which the value (5A) is
to be stored (in this case it is location 1023). After storing (pushing) this value the
SP is incremented to indicate to location 1024. In the stack pop operation, the SP is
first decremented to become 1021. The value stored at this location (DD in this
case) is retrieved (popped out) and stored in the shown register.
The different ways in which operands can be addressed are called the addressing
modes. Addressing modes differ in the way the address information of operands is
specified. The simplest addressing mode is to include the operand itself in the
instruction, that is, no address information is needed. This is called immediate
addressing. A more involved addressing mode is to compute the address of the
operand by adding a constant value to the content of a register. This is called
indexed addressing. Between these two addressing modes there exist a number of
other addressing modes including absolute addressing, direct addressing, and
indirect addressing.
1. Immediate Mode
According to this addressing mode, the value of the operand is (immediately)
available in the instruction itself. Consider, for example, the case of loading the
decimal value 1000 into a register Ri. This operation can be performed using an
instruction such as the following: LOAD #1000, Ri. In this instruction, the
operation to be performed is to load a value into a register. The source operand is
(immediately) given as 1000, and the destination is the register Ri. It should be
noted that in order to indicate that the value 1000 mentioned in the instruction is
the operand itself and not its address (immediate mode), it is customary to prefix
the operand by the special character (#). As can be seen the use of the immediate
addressing mode is simple. The use of immediate addressing leads to poor
programming practice. This is because a change in the value of an operand requires
a change in every instruction that uses the immediate value of such an operand.
2. Direct (Absolute) Mode
According to this addressing mode, the address of the memory location that holds
the operand is included in the instruction. Consider, for example, the case of
loading the value of the operand stored in memory location 1000 into register Ri.
This operation can be performed using an instruction such as LOAD 1000, Ri. In
this instruction, the source operand is the value stored in the memory location
whose address is 1000, and the destination is the register Ri. Note that the value
1000 is not prefixed with any special characters, indicating that it is the (direct or
absolute) address of the source operand
For example, if the content of the memory location whose address is 1000 was
(2345) at the time when the instruction LOAD 1000, Ri is executed, then the result
of executing such instruction is to load the value (2345) into register Ri
3. Indirect Mode
In the indirect mode, what is included in the instruction is not the address of the
operand, but rather a name of a register or a memory location that holds the
(effective) address of the operand. In order to indicate the use of indirection in the
instruction, it is customary to include the name of the register or the memory
location in parentheses. Consider, for example, the instruction LOAD (1000), Ri
. This instruction has the memory location 1000 enclosed in parentheses, thus
indicating indirection. The meaning of this instruction is to load register Ri with the
contents of the memory location whose address is stored at memory address 1000.
Because indirection can be made through either a register or a memory location,
therefore, we can identify two types of indirect addressing. These are register
indirect addressing, if a register is used to hold the address of the operand, and
memory indirect addressing, if a memory location is used to hold the address of the
operand.
4. Indexed Mode
In this addressing mode, the address of the operand is obtained by adding a
constant to the content of a register, called the index register. Consider, for
example, the instruction LOAD X(Rind), Ri. This nstruction loads register Ri with
the contents of the memory location whose address is the sum of the contents of
register Rind and the value X. Index addressing is indicated in the instruction by
including the name of the index register in parentheses and using the symbol X to
indicate the constant to be added.
The table below shows the summary of some addressing mode.

INSTRUCTION TYPES
The type of instructions forming the instruction set of a machine is an indication of
the power of the underlying architecture of the machine. Instructions can in general
be classified as:
1. Data Movement Instruction: Data movement instructions are used to move
data among the different units of the machine. Most notably among these are
instructions that are used to move data among the different registers in the
CPU. A simple register to register movement of data can be made through
the instruction
MOVE Ri,Rj.

Some Common Data Movement Operations


This instruction moves the content of register Ri to register Rj. The effect of the
instruction is to override the contents of the (destination) register Rj without
changing the contents of the (source) register Ri. Data movement instructions
include those used to move data to (from) registers from (to) memory. These
instructions are usually referred to as the load and store instructions, respectively.
Examples of the two instructions are
LOAD 25838, Rj
STORE Ri, 1024
The first instruction loads the content of the memory location whose address is
25838 into the destination register Rj. The content of the memory location is
unchanged by executing the LOAD instruction. The STORE instruction stores the
content of the source register Ri into the memory location 1024. The content of the
source register is unchanged by executing the STORE instruction.
2. Arithmetic and Logical Instructions: Arithmetic and logical instructions
are those used to perform arithmetic and logical manipulation of registers
and memory contents. Examples of arithmetic instructions include the ADD
and SUBTRACT instructions. These are
ADD R1,R2,R0
SUBTRACT R1,R2,R0
The first instruction adds the contents of source registers R1 and R2 and stores the
result in destination register R0. The second instruction subtracts the contents of
the source registers R1 and R2 and stores the result in the destination register R0.
The contents of the source registers are unchanged by the ADD and the
SUBTRACT instructions. In addition to the ADD and SUBTRACT instructions,
some machines have MULTIPLY and DIVIDE instructions. These two instructions
are expensive to implement and could be substituted by the use of repeated
addition or repeated subtraction. Therefore, most modern architectures do not have
MULTIPLY or DIVIDE instructions on their instruction set.
Logical instructions are used to perform logical operations such as AND, OR,
SHIFT, COMPARE, and ROTATE. As the names indicate, these instructions
perform, respectively, and, or, shift, compare, and rotate operations on register or
memory contents.
Some Common Arithmetic Operations

Some Common Logical Operations


3. Input/Output Instructions
Input and output instructions (I/O instructions) are used to transfer data between
the computer and peripheral devices. The two basic I/O instructions used are the
INPUT and OUTPUT instructions. The INPUT instruction is used to transfer data
from an input device to the processor. Examples of input devices include a
keyboard or a mouse. Input devices are interfaced with a computer through
dedicated input ports. Computers can use dedicated addresses to address these
ports. Suppose that the input port through which a keyboard is connected to a
computer carries the unique address 1000. Therefore, execution of the instruction
INPUT 1000 will cause the data stored in a specific register in the interface
between the keyboard and the computer, call it the input data register, to be moved
into a specific register (called the accumulator) in the computer. Similarly, the
execution of the instruction OUTPUT 2000 causes the data stored in the
accumulator to be moved to the data output register in the output device whose
address is 2000. Alternatively, the computer can address these ports in the usual
way of addressing memory locations. In this case, the computer can input data
from an input device by executing an instruction such as MOVE Rin, R0. This
instruction moves the content of the register Rin into the register R0. Similarly, the
instruction MOVE R0, Rin moves the contents of register R0 into the register Rin,
that is, performs an output operation.

You might also like