If you are interested in hardware field, then one of the most important thing you must know before going forward in the field is addressing modes because if you are not familier with addressing modes then you cannot program a device or circuit, no matter how intelligent you are ? Here I am going to tell you addressing modes of 8051.
These modes are applicable to whole 8086 family including microprocessors of the given family, thus these are very important for hardware designing and programming.
The 8051's addressing modes are designed from the perspective that data-access priority should reflect how the data is to be accessed. In most applications, very few variables are accessed a lot, some quite a bit, and most quite infrequently. In designing 8051 Intel used this philosophy to specify the single-byte/12-clock-cycle instruction cycle for determining how data would be accessed.
The four modes which can be used for addressing any variable in microcontroller memory are explained below :-
The first addresing mode is basically not an addressing mode, it is just a method to pass the value to be executed as part of the instruction. The immediate value is specified by placing a '#' character in front of the immediate value to be passed. For example look at the following instruction : -
add A, #77 ; add 77 to the accumulator
this instruction will add 77 (decimal) to the contents of the accumulator and store the result in accumulator. This method is used when we are required to pass certain integer values into calculation like multiplication and division.
Bank addressing mode allows programmer to access a byte in the current register bank. This is most efficient ( both in terms of clock cycle and control store ) method of accessing data. Most register instruction execute in one register cycle and only require one byte to execute the instruction. The 8 bytes are known as R0 through R7. For example
add A, R2 ;add content of R2 to accumulator and store result in accumulator
Direct Memory Addressing
It differs from register addressing in that any byte within the first 256 addresses can be accessed by specifying 8-bit address. When using this mode, there are few things watch out for. The first RAM addresses ( 080h to 0FFh, if the device you are using has RAM at these locations ) cannot be accessed by direct memory addressing. If you specify an instruction like : mov A, 088h
You wil load the accumulator with the contents of the TCON register located at address 088h rather than the contents of RAM byte.
Register Indirect Addressing
As the name indicates it is an indirect mode of addressing. It user R0 or R1 as an 8-bit index register to access a byte in the first 256 addresses of the data space. As : -
orl A, @R0
The register indirect addressing mode is identified by the symbol '@' before either R0 or R1. Using any other bank (R2 to R7) will result in an error. This is all about the addressing in 8051 microcontroller. I think the information is useful to you.
Sunil Saharan Working for an ideal and peaceful society.
More articles: 5