?addressing Modes
?addressing Modes
&
ADDRESSING MODES
Opcode Operand
More precisely, there is another field that specifies the way the
operand or the effective address is determined – Mode field.
Generally, this field is implicitly associated with the opcode field.
Mode Opcode Operand
Name Mnemonic
Load LD
Store ST
Move MOV
Exchange XCH
Input IN
Output OUT
Push PUSH
Pop POP
Data Manipulation Instructions
Name Mnemonic
Logical Shift Right SHR
Logical Shift Left SHL
Arithmetic Shift Right ASHR
Arithmetic Shift Left ASHL
Circular Shift Right CIR
Circular Shift Left CIL
Rotate Right ROR
Rotate Left ROL
Rotate Right Through Carry RORC
Rotate Leftt Through Carry ROLC
Program Control Instructions
• Specify conditions for altering the content of PC, while data transfer &
manipulation instructions specify conditions for data processing operations.
• Cause a break in the sequence of instructions.
• Capability for branching to different program segments.
• Provide control over the flow of program execution.
Name Mnemonic
Branch BR
Jump JMP
Skip SKP
Call CALL
Return RET
Compare (by subtraction) CMP
Test (by ANDing) TST
RISC (Reduced Instruction Set Computer)
Instructions Micro-operations
PUSH A TOS A
PUSH B TOS B
ADD TOS (A+B)
0 – address PUSH C TOS C
PUSH D TOS D
ADD TOS (C+D)
MUL TOS (A+B)*(C+D)
ST X M[X] TOS
1-Address Instructions
• One explicit operand per instruction
• Second operand is implicit
– Always found in hardware register
– Known as accumulator
e.g. Considering X=(A+B)*(C+D)
Instructions Micro-operations
LD A AC M[A]
ADD B AC AC + M[B]
ST T M[T] AC
LD C AC M[C]
ADD D AC AC + M[D]
MUL T AC AC * M[T]
ST X M[X] AC
AC is the Accumulator
2-Address Instructions
• Two explicit operands per instruction
• Result overwrites one of the operands
• Operands known as source and destination
• Works well for instructions such as memory copy
e.g. Considering X=(A+B)*(C+D)
Instructions Micro-operations
MOV R1 , A R1 M[A]
ADD R1 , B R1 R1 + M[B]
MOV R2 , C R2 M[C] R1 , R2 : General
ADD R2 , D R2 R2 + M[D] purpose registers
MUL R1 , R2 R1 R1 * R2
MOV X , R1 M[X] R1
3-Address Instructions
• Three explicit operands per instruction
• Operands specify source, destination, and result
e.g. Considering X=(A+B)*(C+D)
Instructions Micro-operations
ADD R1 , A , B R1 M[A] + M[B]
ADD R2 , C , D R2 M[C] + M[D]
MUL X , R1 , R2 M[X] R1 * R2
RISC Instructions
• Processor is restricted to simple “Load & Store” instructions when communicating
between CPU & memory.
• All the other instructions are executed within the processor registers without
referring to memory.
• Computational-type instructions have 3 addresses which are for specifying
processor registers.
e.g. Considering X=(A+B)*(C+D)
Instructions Micro-operations
LD R1 , A R1 M[A]
LD R2 , B R2 M[B]
ADD R3 , R1 , R2 R3 R1 + R2
LD R4 , C R4 M[C]
LD R5 , D R5 M[D]
ADD R6 , R4 , R5 R6 R4 + R5
MUL R7 , R3 , R6 R7 R3 * R6
ST X , R7 M[X] R7
Operand Types
• Operand that specifies a source
– Signed constant
– Unsigned constant
– Contents of a register
– Value in a memory location
• Operand that specifies a destination
– Single register
– Pair of contiguous registers
– Memory location
• Operand that specifies a constant is known as immediate value
• Memory references usually much more expensive than
immediate or register access
Instruction Cycle
The processing required for a single instruction.
• Goal:
1. It offers the programmers various facilities such as
counters for loop control, pointers to memory & indexing
of data thereby enabling them to write more efficient
program.
2. It tends to decrease the no. of bits in the address fields of
the instruction.
Different Types of Addressing Modes
1. Implied Addressing Mode
2. Immediate Addressing Mode
3. Direct Addressing Mode
4. Indirect Addressing Mode
5. Register Addressing Mode (Direct)
6. Register Indirect Addressing Mode
7. Auto Increment/Decrement Addressing Mode
8. Relative Addressing Mode
9. Indexed Addressing Mode Displacement
Addressing
10. Base Register Addressing Mode
1. Implied Addressing Mode
• Operands are implicitly specified in the instruction.
• Also known as Implicit or Inherent addressing mode.
• All the register reference instructions that use an accumulator
are implied mode instructions.
• 0-address instructions for stack-organized computer.
e.g. ADD 5
Add 5 to contents of accumulator
5 is operand
3. Direct Addressing Mode
• Address field contains address of operand
• Effective address (EA) = address field (A)
e.g. ADD A
– Add contents of cell A to accumulator
– Look in memory at address A for operand
• Single memory reference to access data
• No additional calculations to work out effective address
• Limited address space
• Also known as Absolute addressing mode.
Cntd…
4. Indirect Addressing Mode
• Memory cell pointed to by address field contains the address of
(pointer to) the operand
• EA = (A)
– Look in A, find address (A) and look there for operand
e.g. ADD (A) => AC AC + M[M[A]]
– Add contents of cell pointed to by contents of A to
accumulator
• Large address space => 2n where n = word length
• Helpful to implement the concept of pointers.
• May be nested, multilevel, cascaded
– e.g. EA = (((A)))
• Multiple memory accesses to find operand => slower
Cntd…
5. Register Addressing Mode (Direct)
• Address field refers to a processor register that contains the operand
itself.
• EA = R e.g ADD R1,R2
• Limited number of registers
• Very small address field needed
– Shorter instructions
– Faster instruction fetch
• No memory access
• Very fast execution
• Very limited address space
• Multiple registers helps performance
– Requires good assembly programming or compiler writing
– N.B. : C programming
register int a;
Cntd…
6. Register Indirect Addressing Mode
• The address field refers to a processor register that contains the
memory location of the operand instead of the actual operand.
• EA = (R) e.g. LD (R1) => AC M[R1]
• Large address space (2n)
• Register acts as MAR
• Before using this mode, it must be ensured that the memory
address of the operand has already been stored in the register.
• Less no. of bits are to be used in the address field for
specifying a register as compared to that of specifying a
memory address.
Cntd…
References
1. Computer Organization – Carl Hamacher
2. Computer System Architecture – Morris Mano
3. Computer Organization & Architecture – T. K. Ghosh
4. Wikipedia