Texas Instruments MSC1210 User Manual

Page 202

Advertising
background image

Register Assignment (MOV)

16-8

Note:

Recursive subroutines (subroutines that call themselves) are a very popular
method of solving some common programming problems. However, unless
you know for certain that the subroutine will call itself a certain number of
times, it is generally not possible to use subroutine recursion in 8052 assem-
bly language. Due to the small amount of Internal RAM a recursive subrou-
tine could quickly cause the stack to fill all of internal RAM.

16.9 Register Assignment (MOV)

One of the most commonly used 8052 assembly language instructions, and
the first to be introduced here, is the MOV instruction. 57 of the 254 opcodes
are MOV instructions because there are many ways data can be moved be-
tween various registers using various addressing modes.

The MOV instruction is used to move data from one register to another—or to
simply assign a value to a register—and has the following general syntax:

MOV DestinationRegister,SourceValue

DestinationRegister always indicates the register or address in which Source-
Value
will be stored, whereas SourceValue indicates the register the value will
be taken from, or the value itself if it is preceded by a pound sign (#).

For example:

MOV A,25h

;Moves contents of Internal RAM address 25h
;to accumulator

MOV 25h,A

;Move contents of accumulator into Internal
;RAM address 25h

MOV 80h,A

;Move the contents of the accumulator to P0
;SFR (80h)

MOV A,#25h

;Moves the value 25h into the accumulator

As shown, the first parameter is the register, internal RAM address, or SFR ad-
dress that a value is being moved to. Another way of looking at it is that the first
parameter is the register that is going to be assigned a new value.

Likewise, the second parameter tells the 8052 where to get the new value.
Normally, the value of the second parameter indicates the Internal RAM or
SFR address from which the value should be obtained. However, if the second
parameter is preceded by a pound sign, the register will be assigned the value
of the number that follows the pound sign (as is demonstrated in the previous
example).

Advertising