0% found this document useful (0 votes)
11 views40 pages

COA Lecture 6-1

The document discusses various addressing modes used in computer architecture, including immediate, direct (absolute), indirect, indexed, relative, autoincrement, and autodecrement modes. Each mode specifies how operands are addressed in instructions, with examples illustrating their usage. Additionally, it covers instruction types such as data movement and arithmetic/logical instructions, highlighting their roles in manipulating data within a machine.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views40 pages

COA Lecture 6-1

The document discusses various addressing modes used in computer architecture, including immediate, direct (absolute), indirect, indexed, relative, autoincrement, and autodecrement modes. Each mode specifies how operands are addressed in instructions, with examples illustrating their usage. Additionally, it covers instruction types such as data movement and arithmetic/logical instructions, highlighting their roles in manipulating data within a machine.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

COA Lecture 6

Addressing Modes
Introduction
• 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.
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
– the destination is the register Ri.
Immediate addressing diagram
• Note that -:
– in order to indicate that the value 1000 mentioned in
the instruction is the operand itself and not its address
(immediate mode), we prefix the operand by the special
character (#).
• The use of immediate addressing is simple and leads
to poor programming practice - change in the value
of an operand requires a change in every instruction
that uses the immediate value of such an operand.
• A more flexible addressing mode is explained next.
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:
– 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.
Illustration of the direct addressing mode
• 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.
• Direct (absolute) addressing mode provides
more flexibility compared to the immediate
mode.
• However, it requires the explicit inclusion of
the operand address in the instruction.
• A more flexible addressing mechanism is
provided through the use of the indirect
addressing mode.
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.
– the name of the register or the memory location is put in
parentheses.
• Consider this 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 - we can identify two
types of indirect addressing:
– register indirect addressing, if a register is used to hold
the address of the operand
– memory indirect addressing, if a memory location is
used to hold the address of the operand.
Illustration of the indirect addressing mode
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, the instruction
– LOAD X(Rind), Ri.
• This instruction 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.
Other Modes
• The addressing modes presented before
represent the most commonly used modes in
most processors.
• They provide the programmer with sufficient
means to handle most general programming
tasks.
• However, a number of other addressing modes
have been used in a number of processors to
facilitate execution of specific programming tasks.
• These additional addressing modes are more
involved as compared to those presented
above.
• Among these addressing modes are:
– relative,
– autoincrement,
– and the autodecrement modes
• They represent the most well-known ones.
These are explained next.
Relative Mode
• Recall that in indexed addressing, an index
register, Rind , is used.
• Relative addressing is the same as indexed
addressing except that the program counter
(PC) replaces the index register.
• For example, the instruction:
– LOAD X(PC), Ri
• The instruction loads register Ri with the
contents of the memory location whose
address is the sum of the contents of the
program counter (PC) and the value X
Illustration of relative addressing mode
Autoincrement Mode
• This addressing mode is similar to the register
indirect addressing mode - the effective address of
the operand is the content of a register
– call it the autoincrement register, that is included in the
instruction.
• However, the content of the autoincrement register
is automatically incremented after accessing the
operand.
• As before, indirection is indicated by including the
autoincrement register in parentheses.
• The automatic increment of the register’s content after
accessing the operand is indicated by including a (+) after
the parentheses.
• Consider the instruction:
– LOAD (Rauto)+, Ri.
• This instruction loads register Ri with the operand whose
address is the content of register Rauto.
• After loading the operand into register Ri, the content of
register Rauto is incremented, pointing for example to the
next item in a list of items.
Illustration of the autoincrement
addressing mode
Autodecrement Mode
• Similar to the autoincrement - the
autodecrement mode uses a register to hold
the address of the operand.
• However, in this case the content of the
autodecrement register is first decremented
and the new content is used as the effective
address of the operand.
• A (-) is included before the indirection parentheses
show that the content of the autodecrement register
is decremented before accessing the operand.
• Consider the instruction:
– LOAD - (Rauto), Ri.
• This instruction decrements the content of the
register Rauto and then uses the new content as the
effective address of the operand that is to be loaded
into register Ri.
Illustration of the autodecrement
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.
Data Movement Instructions
• Data movement instructions are used to move
data among the different units of the machine
e.g. among the different registers in the CPU.
• A simple register to register movement of data
can be made through the instruction :
– MOVE Ri,Rj
• 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.
Some Common Data Movement Operations
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. E.g.
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.
• Most modern architectures do not have
MULTIPLY or DIVIDE instructions on their
instruction set.
Some Common Arithmetic Operations
Logical Instructions
• Logical instructions are used to perform logical
operations such as AND, OR, SHIFT, COMPARE,
and ROTATE on register or memory contents.
Some Common Logical Operations
Question
• Consider a computer that has a number of registers
such that the three registers R0 = 1500, R1 = 4500,
and R2 = 1000. Show the effective address of memory
and the registers’ contents in each of the following
instructions (assume that all numbers are decimal).
(a) ADD (R0)+, R2
(b) SUBTRACT - (R1), R2
(c) MOVE 500(R0), R2
(d) LOAD #5000, R2
(e) STORE R0, 100(R2)

You might also like