Notes 1

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 1

An "addressing mode" refers to how you are Indirect Addressing

addressing a given memory location. In summary, the Indirect addressing is a very powerful addressing mode which in many
addressing modes are as follows, with an example of cases provides an exceptional level of flexibility. Indirect addressing is
each: also the only way to access the extra 128 bytes of Internal RAM found on
Immediate an 8052.
MOV A,#20h Indirect addressing appears as follows: MOV A,@R0
Addressing
Direct Addressing MOV A,30h This instruction causes the 8051 to analyze the value of the R0 register.
Indirect Addressing MOV A,@R0 The 8051 will then load the accumulator with the value from Internal
RAM which is found at the address indicated by R0.
External Direct MOVX A,@DPTR For example, lets say R0 holds the value 40h and Internal RAM address
MOVC 40h holds the value 67h. When the above instruction is executed the 8051
Code Indirect
A,@A+DPTR will check the value of R0. Since R0 holds 40h the 8051 will get the
Each of these addressing modes provides important value out of Internal RAM address 40h (which holds 67h) and store it in
flexibility the Accumulator. Thus, the Accumulator ends up holding 67h. Indirect
Immediate Addressing addressing always refers to Internal RAM; it never refers to an SFR.
Immediate addressing is so-named because the value to Thus, in a prior example we mentioned that SFR 99h can be used to write
be stored in memory immediately follows the operation a value to the serial port. Thus one may think that the following would be
code in memory. That is to say, the instruction itself a valid solution to write the value 1 to the serial port: MOV R0,#99h
dictates what value will be stored in memory. ;Load the address of the serial port
For example, the instruction: MOV A,#20h MOV @R0,#01h ;Send 01 to the serial port -- WRONG!!
This instruction uses Immediate Addressing because the This is not valid. Since indirect addressing always refers to Internal RAM
Accumulator will be loaded with the value that these two instructions would write the value 01h to Internal RAM address
immediately follows; in this case 20 (hexidecimal). 99h on an 8052. On an 8051 these two instructions would produce an
Immediate addressing is very fast since the value to be undefined result since the 8051 only has 128 bytes of Internal RAM.
loaded is included in the instruction. However, since the
value to be loaded is fixed at compile-time it is not very
flexible. External Direct
Direct Addressing External Memory is accessed using a suite of instructions which use what
Direct addressing is so-named because the value to be I call "External Direct" addressing. I call it this because it appears to be
stored in memory is obtained by directly retrieving it direct addressing, but it is used to access external memory rather than
from another memory location. For example: MOV internal memory.
A,30h There are only two commands that use External Direct addressing mode:
This instruction will read the data out of Internal RAM MOVX A,@DPTR and MOVX @DPTR,A
address 30 (hexidecimal) and store it in the As you can see, both commands utilize DPTR. In these instructions,
Accumulator. DPTR must first be loaded with the address of external memory that you
Direct addressing is generally fast since, although the wish to read or write. Once DPTR holds the correct external memory
value to be loaded isnt included in the instruction, it is address, the first command will move the contents of that external
quickly accessable since it is stored in the 8051s Internal memory address into the Accumulator. The second command will do the
RAM. It is also much more flexible than Immediate opposite: it will allow you to write the value of the Accumulator to the
Addressing since the value to be loaded is whatever is external memory address pointed to by DPTR.
found at the given address--which may be variable. External Indirect
Also, it is important to note that when using direct External memory can also be accessed using a form of indirect addressing
addressing any instruction which refers to an address which I call External Indirect addressing. This form of addressing is
between 00h and 7Fh is referring to Internal Memory. usually only used in relatively small projects that have a very small
Any instruction which refers to an address between 80h amount of external RAM. An example of this addressing mode is:
and FFh is referring to the SFR control registers that MOVX @R0,A
control the 8051 microcontroller itself. Once again, the value of R0 is first read and the value of the Accumulator
The obvious question that may arise is, "If direct is written to that address in External RAM. Since the value of @R0 can
addressing an address from 80h through FFh refers to only be 00h through FFh the project would effectively be limited to 256
SFRs, how can I access the upper 128 bytes of Internal bytes of External RAM. There are relatively simple hardware/software
RAM that are available on the 8052?" The answer is: tricks that can be implemented to access more than 256 bytes of memory
You cant access them using direct addressing. As stated, using External Indirect addressing; however, it is usually easier to use
if you directly refer to an address of 80h through FFh External Direct addressing if your project has more than 256 bytes of
you will be referring to an SFR. However, you may External RAM.
access the 8052s upper 128 bytes of RAM by using the
next addressing mode, "indirect addressing.
Cache Coherence: In a shared memory multiprocessor with a 1. Every write operation appears to occur instantaneously.
separate cache memory for each processor , it is possible to have 2. All processes see exactly the same sequence of changes of values for each
many copies of any one instruction operand : one copy in the separate operand.
main memory and one in each cache memory. When one copy of 3. Different processes may see an operand assume different sequences of values.
an operand is changed, the other copies of the operand must be (This is considered noncoherent behavior.)
changed also. Cache coherence is the discipline that ensures that
changes in the values of shared operands are propagated In both level 2 behavior and level 3 behavior, a program can observe stale data .
throughout the system in a timely fashion. There are three Recently, computer designers have come to realize that the programming discipline
distinct levels of cache coherence: required to deal with level 2 behavior is sufficient to deal also with level 3 behavior.
Therefore, at some point only level 1 and level 3 behavior will be seen

You might also like