Addressing mode is the way of addressing a memory location in instruction. Microcontroller needs data or operands on which the operation is to be performed. The method of specifying source of operand and output of result in an instruction is known as addressing mode.
There are various methods of giving source and destination address in instruction, thus there are various types of Addressing Modes. Here you will find the different types of Addressing Modes that are supported in Micro Controller 8051. Types of Addressing Modes are explained below:
1.Register Addressing Mode
2.Direct Addressing Mode
3.Register Indirect Addressing Mode
4.Immediate Addressing Mode
5.Index Addressing Mode
Explanation:
Register Addressing Mode: In this addressing mode, the source of data or destination of result is Register. In this type of addressing mode the name of the register is given in the instruction where the data to be read or result is to be stored.
Example: ADD A, R5 ( The instruction will do the addition of data in Accumulator with data in register R5)
Direct Addressing Mode: In this type of Addressing Mode, the address of data to be read is directly given in the instruction. In case, for storing result the address given in instruction is used to store the result.
Example: MOV A, 46H ( This instruction will move the contents of memory location 46H to Accumulator)
Register Indirect Addressing Mode: In Register Indirect Addressing Mode, as its name suggests the data is read or stored in register indirectly. That is, we provide the register in the instruction, in which the address of the other register is stored or which points to other register where data is stored or to be stored.
Example: MOV A, @R0 ( This instruction will move the data to accumulator from the register whose address is stored in register R0 ).
Also Read: Architecture Of 8051
Immediate Addressing Mode : In Immediate Addressing Mode , the data immediately follows the instruction. This means that data to be used is already given in the instruction itself.
Example: MOV A, #25H ( This instruction will move the data 25H to Accumulator. The # sign shows that preceding term is data, not the address.)
Index Addressing Mode: Offset is added to the base index register to form the effective address if the memory location.This Addressing Mode is used for reading lookup tables in Program Memory. The Address of the exact location of the table is formed by adding the Accumulator Data to the base pointer.
Example: MOVC, @A+DPTR ( This instruction will move the data from the memory to Accumulator; the address is made by adding the contents of Accumulator and Data Pointer.
2. What you will see??
• Stack Organizations
• Instruction Formats
• Addressing modes
by Ruchi Maurya
3. Stack Organization
• A stack is a storage device
• Stores information in such a way that the item stored last would be the
first to be retrieved
• Follows principle of LIFO(Last In First Out)
• A group of memory locations with a register that holds address of Top
• Register that holds the address is called Stack Pointer(SP)
by Ruchi Maurya
4. Stack Operations
• Two operations of stack are insertion & deletion
• The operation of insertion is called PUSH into stack because it can
be thought of as pushing a new item
• The operation of deletion is called POP from stack because it can
be thought of as removing one item
by Ruchi Maurya
6. Instruction Format
“The assembler processes an instruction, and it converts the
instruction from its mnemonic form to a standard machine-language
(binary) format called an “instruction format”
by Ruchi Maurya
7. Components of Instruction format
• Operation code
• Specifies operations to be performed.
• Address field
• Designates a memory address or a processor register.
• Mode
• The way the operand or the effective address is determined.
by Ruchi Maurya
8. Instruction format
In an instruction format:
• First 12 bits(0-11) specify an address
• Next 3 bits specify operation code(opcode)
• Left most bit specify the addressing mode I
I=0 for direct address
I=1 for indirect address
AddressOpcodeI
011121415
9. Types of Instruction Format
• Three address instruction
• ADD R1, A, B //R1<-M[A]+M[B]
• Two address instruction
• MOV R1, A //R1<-M[A]
• One address instruction
• LOAD A //AC<-M[A]
• Zero address instruction
• PUSH A //TOS<-A
by Ruchi Maurya
10. Addressing Modes
• The way the operands are chosen during program execution is
dependent on the addressing mode of the instruction.
• The addressing mode specify a rule for interpreting or the
modifying the address field of the instruction before the operand
is actually referenced.
Opcode Mode Address
Figure Instruction format with mode field
11. Types of Addressing modes
• Implied Mode
• Immediate Mode
• Register Mode
• Register Indirect Mode
• Autoincrement or Autodecrement Mode
• Direct Address Mode
• Indirect Address Mode
• Relative Address Mode
• Indexed Addressing Mode
• Base Register Addressing Mode
by Ruchi Maurya
12. Implied Mode
• The operand is hidden/fixed inside the instruction.
• Zero Address instructions in a stack organized computer are
implied mode instructions.
Complement Accumulator CMA
(Here accumulator A is implied by the instruction)
Complement Carry Flag CMC
(Here Flags register is implied by the instruction)
Set Carry Flag STC
(Here Flags register is implied by the instruction)
by Ruchi Maurya
13. Immediate Mode
• In this mode the operand is specified in instruction itself.
• Operand itself is provided in the instruction rather than its
address.
Move Immediate
MVI A , 15h A ← 15h Here 15h is the immediate operand
Add Immediate
ADI 3Eh A ← A + 3Eh Here 3Eh is the immediate operand
by Ruchi Maurya
14. Register Mode
• The operand is specified with in one of the processor register.
• Instruction specifies the register in which the operand is stored.
Move
MOV C , A C ← A Here A is the operand specified in register
Add
ADD B A ← A + B Here B is the operand specified in register
by Ruchi Maurya
15. Register Indirect Mode
• The instruction specifies the register in which the memory address
of operand is placed.
• It do not specify the operand itself but its location with in the
memory where operand is placed.
Move
MOV A , M A ← [[H][L]]
It moves the data from memory location specified by HL register
pair to A.
by Ruchi Maurya
16. Direct Addressing Mode
• The instruction specifies the direct address of the operand.
• The memory address is specified where the actual operand is.
Load Accumulator
LDA 2805h A ← [2805]
It loads the data from memory location 2805 to A.
Store Accumulator
STA2803h [2803] ← A
It stores the data from A to memory location 2803.
by Ruchi Maurya