Register Assignment (MOV)

As already mentioned, the MOV instruction is one of the most common and vital instructions that an 8052 assembly language programmer uses. The pro- spective assembly language programmer must fully master the MOV instruc- tion. This may seem simple, but it requires knowing all of the permutations of the MOV instruction and knowing when to use them. This knowledge comes with time and experience, and by reviewing Appendix A, 8052 Instruction Set Overview.

It is important that all types of MOV instructions be understood so that the pro- grammer knows what types of MOV instructions are available, as well as what kinds of MOV instructions are not available.

Careful inspection of the MOV commands in the instruction set reference will reveal that there is no MOV from R register to R register instruction. That is to say, the following instruction is invalid:

MOV R2,R1 ;INVALID!!

This is a logical type of operation for a programmer to implement, but the in- struction is invalid. Instead, it must be programmed as:

MOV A,R1 ;Move R1 to accumulator

MOV R2,A ;Move accumulator to R2

Another combination that is not supported is MOV indirectly from Internal RAM to another Indirect RAM address. Again, the following instruction is invalid:

MOV @R0,@R1 ;INVALID!!

This is not a valid MOV combination. Instead, it could be programmed as:

MOV A,@R1 ;Move contents of IRAM pointed to by R1 to accumulator

MOV @R0,A ;Move accumulator to Internal RAM address pointed to by R0

Also note that only R0 and R1 can be used for Indirect Addressing.

Note:

When you need to execute a type of MOV instruction that does not exist, it is generally helpful to use the accumulator. If a given MOV instruction does not exist, it can usually be accomplished by using two MOV instructions that both use the accumulator as a transfer or temporary register

8052 Assembly Language

16-9

 

Page 203
Image 203
Texas Instruments MSC1210 manual MOV R2,R1 Invalid