Most viewed

30 May 2011

Chapter 4 8051 - Addressing Modes


Chapter 4

8051 - Addressing Modes

 Addressing Modes
 Direct Addressing  
 External Direct Addressing
 Immediate Addressing
 Indirect Addressing
 External Indirect Addressing






8051 Tutorial: Addressing Modes



An "addressing mode" refers to how you are addressing a given memory location. In summary, the addressing modes are as follows, with an example of each:
    Immediate Addressing
    MOV A,#20h
    Direct Addressing
    MOV A,30h
    Indirect Addressing
    MOV A,@R0
    External Direct
    MOVX A,@DPTR
    Code Indirect
    MOVC A,@A+DPTR
Each of these addressing modes provides important flexibility.
Immediate Addressing
Immediate addressing is so-named because the value to be stored in memory immediately follows the operation code in memory. That is to say, the instruction itself dictates what value will be stored in memory.
For example, the instruction:
    MOV A,#20h

Chapter 3 8051 - Basic Registers


Chapter 3

8051 - Basic Registers

 Basic Registers
 Accumulator
 B Register
  Program Counter (PC)
 "R" Registers
 Data Pointer (DPTR)
 Stack Pointer (SP)










8051 Tutorial: Basic Registers



The AccumulatorIf youve worked with any other assembly languages you will be familiar with the concept of an Accumulator register.
The Accumulator, as its name suggests, is used as a general register to accumulate the results of a large number of instructions. It can hold an 8-bit (1-byte) value and is the most versatile register the 8051 has due to the shear number of instructions that make use of the accumulator. More than half of the 8051s 255 instructions manipulate or use the accumulator in some way.
For example, if you want to add the number 10 and 20, the resulting 30 will be stored in the Accumulator. Once you have a value in the Accumulator you may continue processing the value or you may store it in another register or in memory.
The "R" registers
The "R" registers are a set of eight registers that are named R0, R1, etc. up to and including R7.
These registers are used as auxillary registers in many operations. To continue with the above example, perhaps you are adding 10 and 20. The original number 10 may be stored in the Accumulator whereas the value 20 may be stored in, say, register R4. To process the addition you would execute the command:

    ADD A,R4

Chapter 2 8051 - Special Function Registers



Chapter 2
8051 - Special Function Registers



8051 Tutorial: SFRs



What Are SFRs?
The 8051 is a flexible microcontroller with a relatively large number of modes of operations. Your program may inspect and/or change the operating mode of the 8051 by manipulating the values of the 8051's Special Function Registers (SFRs).
SFRs are accessed as if they were normal Internal RAM. The only difference is that Internal RAM is from address 00h through 7Fh whereas SFR registers exist in the address range of 80h through FFh.
Each SFR has an address (80h through FFh) and a name. The following chart provides a graphical presentation of the 8051's SFRs, their names, and their address.








As you can see, although the address range of 80h through FFh offer 128 possible addresses, there are only 21 SFRs in a standard 8051. All other addresses in the SFR range (80h through FFh) are considered invalid. Writing to or reading from these registers may produce undefined values or behavior.
Programming Tip: It is recommended that you not read or write to SFR addresses that have not been assigned to an SFR. Doing so may provoke undefined behavior and may cause your program to be incompatible with other 8051-derivatives that use the given SFR for some other purpose.

 

Based on your view




You have to try this

This is trending now #