Upcoming SlideShare
×

2,345 views
2,154 views

Published on

Published in: Technology
7 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
2,345
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
54
0
Likes
7
Embeds 0
No embeds

No notes for slide

1. 1. 8051 ADDRESSING MODES (CONT.) By: Mayank Garg 2013H140040H
2. 2. “What is an addressing mode ?“
3. 3. “What is an addressing mode ?“ Addressing mode is the way of addressing a memory location in instruction. Microcntroller 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.
4. 4. “What is an addressing mode ?“ Addressing mode is the way of addressing a memory location in instruction. Microcntroller 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. Now question arises: How many types of addressing modes?
5. 5. ADDRESSING MODES The 8051 instructions use eight addressing modes. These are: 1. Register 2. Direct 3. Indirect 4. Immediate 5. Relative 6. Absolute 7. Indexed 8. Long
6. 6. ABSOLUTE ADDRESSING MODE  There are only two instructions that use this addressing:  ACALL (absolute call)  AJMP (absolute jump).  These instructions perform branching within the current 2K page of program memory.  The branch address is obtained by successively concatenating the five high-order bits of the program counter, bits 5 – 7 of the op-code,and the second byte of the instruction.
7. 7. CONTD…  The operation of the AJMP instruction is detailed below:  AJMP address (PC) <- (PC) + 2 (PC10-PC0) <- address10 - address0  The eleven least significant bits of the PC are altered. The five most significant bits remain the same. This means the AJMP will only allow you to jump to a location in the same 2K page as the instruction directly after the jump.
8. 8. For example: If the label THERE represents an instruction at address 0F46H and the instruction AJMP THERE is in memory at locations 0900H and 0901H, the assembler will encode the instruction as 11100001 1st byte (A10 - A8 + opcode) 01000110 2nd byte (A7 - A0) The underlined bits are the low-order 11 bits of the destination address, 0F46H = 0000111101000110B. The upper five bits in the program counter will not change when this instruction executes. Note that both the AJMP instruction and the destination are within the 2K page bounded by 0800H and 0FFFH, and therefore have the upper five address bits in common.
9. 9. ANY Query regarding this?? Lets move to next….
10. 10. RELATIVE ADDRESING  Relative addressing is used only with certain jump instructions. The system executes a jump by changing the contents of the PC to the address of the next instruction to be executed.  For example, if we wished to jump to the instruction stored at location 4EH in code memory, the PC would be loaded with 4EH. Then, during the next execution cycle the contents of the PC (4EH) are placed on the address bus and the instruction at 4EH is retrieved.
11. 11. SJUMP is an unconditional jump and is a 2-byte instruction. The number following it is an offset address. If this instruction were stored in code memory at locations 100H and 101H, as shown below: 100H 80H 101H 06H ---The PC contains 100H, therefore the instruction 80H is read into the IR. ---The instruction is decoded as the 2-byte SJMP instruction. ---The PC is incremented so that the operand may be retrieved. ---The operand is read from code memory and the PC is incremented again (because this is a 2-bye instruction). ---The operand (06H) is added to the PC (102H + 06H = 108H).
12. 12. ANY Query regarding this?? Lets move to next….
13. 13. INDEXED ADDRESSING MODE  In this mode the 16-bit address in a base register is added to a positive offset to form an effective address for the jump indirect instruction  JMP @A+DPTR  the two move code byte instructions  MOVC A,@A+DPTR and  MOVC A,@A+PC.  The base register in the jump instruction is the data pointer and the positive offset is held in the accumulator.  For the move instructions the base register can either be the data pointer or the program counter, and again the positive offset is in the accumulator.
14. 14. Example: JMP @A+DPTR (PC)  (A) +(DPTR) MOVC A,@A+DPTR (A)  ((A) + (DPTR)) MOVC A,@A+PC (PC)  (PC) + 1 (A)  ((A) + (PC))
15. 15. ANY Query regarding this?? Lets move to next….
16. 16. LONG ADDRESSING MODE  Only two instructions use this addressing mode.  These instructions are:  LCALL addr16  LJMP addr16.  Both of these are three byte instructions with the op- code being the first byte and the following two bytes are the address high-byte and address low-byte respectively.  These instructions enable the program to branch to anywhere within the full 64 K-bytes of program memory address space
17. 17. ANY Query regarding this?? Lets move to next….
18. 18. INDIRECT ADDRESSING MODE  In this mode of addressing the instruction performs an operation on the data whose address is contained in register R0 or R1. Instructions using indirect addressing are single byte instructions.  In 8051 assembly language the symbol @ before R0 or  SUBB A, @R0 R1 (denotes indirect addressing.)
19. 19. This instruction performs the operation: (A) (A) (C)  ((R0)). For example, ***if you had an array of 8-bit numbers stored in memory, starting at address 30H, you may wish to examine the contents of each number in the array (perhaps to find the smallest number). ***To do so, you would need to read location 30H, then 31H, then 32H and so on.
20. 20. This can be achieved using indirect addressing. R0 and R1 may be used as pointer registers. MOV A, @Ri (where Ri is either R0 or R1.) Now, we can read the contents of location 30H through indirect addressing: MOV R0, #30H MOV A, @R0
21. 21. ANY Query regarding this?? So now we know all addressing modes. What is next now??
22. 22. What is the difference between Microprocessor and Microcontroller???
23. 23. Microprocessors generally require external components to implement program memory, ram memory and Input/output. -Here cpu is stand alone,RAM ROM I/O, timer are separate. -It is expensive n versatile. -used for general purpose. -RAM n ROM size is user defined. -bit manipulation is less. -access time is less. -more hardware is used.
24. 24. MICROCONTROLLER  Microcontrollers incorporate program memory, ram memory and input/output resources internal to the chip. -Here cpu RAM ROM I/O, timer are on a single chip. -It is cheaper as compared to microprocessor. -used for single purpose. -fixed amount of on chip RAM,ROM and I/O ports. -bit manipulation is more. -access time is more. -less hardware is used.
25. 25. WHAT IS DIFFERENCE BETWEEN:  8085  8086  8051 ???
26. 26. 8051  16 bit Microcontroller  On chip ROM( 8KB) and On chip RAM (128 bytes)  Two 16 bit timer/counter.  Four 8-bit ports for input/output  Fully duplex serial receiver/transmitter.  No pre-fetching of instruction.  16 address pins
27. 27. 8086  16 bit Microprocessor  No on chip memory.  Memory is divided into two banks to increase the processing speed.  Pre-fetching of 6 bytes of instruction in a queue.  20 address pins
28. 28. 8085  8 bit microprocessor  16-bit address bus  8-bit registers  16-bit register pairs, BC, DE, and HL  256 input/output (I/O) ports  External Memory
29. 29. REFERENCES  https://www.silabs.com/Support%20Documents/Softw are/8051_Instruction_Set.pdf  http://coitweb.uncc.edu/~abw/ITCS3182F09/slides3.p df  http://www.cs.iit.edu/~virgil/cs470/Book/chapter4.pd  http://www.slideshare.net/chappidi_saritha/addressin g-modes-of-8051  http://www.edsim51.com/8051Notes/8051/instruction SetSummary.html  http://www.nptel.iitm.ac.in/courses/Webcourse- contents/IITKANPUR/microcontrollers/micro/ui/Cours e_home2_6.htm
30. 30. So now move to what is instruction? Types of instructions???