Instruction Format and Addressing Modes
Instruction Format and Addressing Modes
And
Addressing modes
Instruction
Opcode
CMA
Immediate addressing mode
Instruction
Opcode Operand
ADD 5
Direct addressing mode
Instruction
Opcode Address A
Memory
A
Operand
Indirect addressing mode
• Memory cell pointed to by address field contains the
address of (pointer to) the operand.
• EA = address contained in memory location M
• Look in M, find address contained in M and look there
for operand
• For example
ADD @M
• Add contents of memory location pointed to by contents
of M to accumulator
Indirect addressing mode diagram
Instruction
Opcode Address M
Memory
Pointer to operand
Operand
Register addressing mode
• Operand is held in register named in the address field.
• EA = R
• Example ADD B
Advantages and disadvantages
• No memory access. So very fast execution.
• Very small address field needed .
• Shorter instructions
• Faster instruction fetch
• Limited number of registers.
• Multiple registers helps performance
• Requires good assembly programming or compiler
writing
Register addressing mode diagram
Instruction
Opcode Register Address R
Registers
Operand
Register Indirect addressing mode
• In this the instruction specifies a register whose
contents give the address of the operand in memory.
• Therefore EA = the address stored in the register R
• Operand is in memory cell pointed to by contents of
register R
• Example LDAX B
Advantage
• Less number of bits are required to specify the
register.
• One fewer memory access than indirect addressing.
Register Indirect addressing mode diagram
Instruction
Opcode Register Address R
Memory
Registers
Instruction
Opcode Register Address R
Memory
Registers
value
value++ Operand
Operand
Relative addressing mode
• In this mode the contents of the program counter is added
to the address field of the instruction in order to obtain the
effective address.
• EA = A + contents of PC
• Example : PC contains 825 and address part of instruction
contains 24.
After the instruction is read from location 825, the PC is
incremented to 826. So EA=826+24=850. The operand will
be found at location 850 i.e. 24 memory locations forward
from the address of the next instruction.
Relative addressing mode diagram
Instruction
Opcode Address A
Memory
Program counter
Contents of register + Operand
Indexed addressing mode
• The contents of an index register is added to the address
field of the instruction to get the effective address.
• The address field of the instruction is the beginning
address of the data array in the memory.
• Index register contains a index value which can be
incremented or decremented as required.
• Therefore
EA = A + IR
• Example MOV AL , DS: disp [SI]
Advantage
• Good for accessing arrays.
Indexed addressing mode diagram
Instruction
Opcode IR Address A
Memory
Index Register
Contents of register + Operand
A
Base Register addressing mode
• In this mode the content of a base register is added to
the address part of the instruction to obtain the
effective address.
• The base register contains the address of the
beginning of the data array.
• Therefore
EA= A + BR
• For example:
MOV AL, disp [BX]
Segment registers in 8086
Base Register addressing mode diagram
Instruction
Opcode BR Address A
Memory
Base Register
Contents of register + Operand
Value of BR