Your SlideShare is downloading. ×
8051 addressing modes
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

8051 addressing modes

2,626
views

Published on

<a />8051 addressing modes </a>

<a />8051 addressing modes </a>


0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,626
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
54
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MICROCONTROLLERS 8051 Created By: Sachin Bhalavat (Elect. & Comm. Engg.) profspbhalavat@gmail.com
  • 2. • The first byte of an instruction is known as the opcode (operation code) because this is the byte that is decoded by the processor - from this code the processor can work out what operation it must perform.• For a one-byte instruction there is only the opcode.• For a two-byte instruction the second byte is the operand.• The operand can be data or an 8-bit address.• For a three-byte instruction the second and third bytes make up the operand.• A two-byte operand is usually a 16-bit address, as we shall see when we look at long addressing
  • 3. The five addressing modes are:Immediate addressing modesRegister addressing modesDirect addressing modesIndirect addressing modesRegister specific addressing mode
  • 4.  Immediate addressing is only use when the data to be read is aconstant. The data is numeric constant in the operand indicated by a “#” sign Useful for getting constants into registers. For example, if your program needed to perform some calculationsbased on the number of weeks in the year, you could use immediateaddressing to load the number 52 (34H) into a register and then performarithmetic operations upon this data. MOV R0, #34H The above instruction is an example of immediate addressing. It movesthe data 34H into R0. The has symbol (#) is used for this purpose (whenever the assemblersees # before a number it knows this is immediate addressing). This is a two-byte instruction. Data can be 16-bits when dealing with the DPTR register . MOV DPTR, #2500H
  • 5.  Direct access to eight registers (R0-R7). There are 4 banks of registers accessible through register addressing. Only one bank can be accessed at a time controllable through bit RS0 and RS1 of the PSW. Often we need to move data from a register into the accumulator so that we can perform arithmetic operations upon it. For example, we may wish to move the contents of R5 into the accumulator. MOV A, R5 This is an example of register addressing. It moves data from R5 (in the currently selected register bank) into the accumulator.
  • 6.  Direct addressing is Used to access any on-chip RAM location, General purpose registers, Control registers or SFRs, which can be addressed by address or name. MOV A, 67 The above instruction moves the data in location 67H into the accumulator. Note the difference between this and immediate addressing. Immediate addressing uses the data, which is immediately after the instruction. With direct addressing, the operand is an address. The data to be operated upon is stored in that address. The assembler realises this is an address and not data because there is no hash symbol before it.
  • 7.  R0 or R1 hold the location of the internal RAM location. Indicated by the @ sign. It Can be used for accessing external memory, where R0 and R1 point to external memory locations 00H to FFH. Example: 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 The first instruction is an example of immediate addressing where the data 30H is placed in R0. The second instruction is indirect addressing. It moves the contents of location 30H into the accumulator.
  • 8. • In this addressing mode the instruction refer to a specific register such as accumulator or a data pointer.• Example: DA A :decimal adjust accumulator for addition RR A :rotate the content of accumulator to the right SWAP A:swap the nibble within the accumulator