BIG 8051 Manual
24
Register Addressing
In CPU registers are used to store information temporarily. That information can be in
the form of bytes of data to be processed or some address pointing to a data to be
fetched. In 8051 there is only one data type: 8 bits. With an 8 bit data registers, any
data more than 8-bit should be divided into 8 bit chunks before being processed.
The most widely used registers of 8051 are A (accumulator), R0, R1, R2, R3, R4, R5,
R6, R7, DPTR (data pointer), PC (program counter). A register is used for all arithme-
tic and logic operations. These registers are divided into two groups:
General purpose registers
Special purpose registers
The register addressing instruction involves information transfer between registers
Example:
MOV
R0, A
MOV
A,#51H
MOV
R1,#0FFH
MOV
R2, #3BH
The first instruction above transfers the accumulator content into the R0 register. The
register bank (Bank 0,1,2 or 3) must be specified prior to this instruction.
# signifies that it is a number and not a byte address
‘H’ symbolizes that it is a hexadecimal number. Similarly if we write a binary
number it should end with ‘B’
The ‘0’ in the third instruction in 0FFH symbolizes that the ‘F’ is a hex number
and not a letter. This is always necessary if we are writing any hex numbers. It
should always start with a 0.
All the register should be assumed to be of 1 byte unless otherwise mentioned.
Now to transfer contents of R1 to lets say, R6, the following code should do the trick:
MOV
R6,R1 ; copy contents of R1 to T6
DIRECT ADDRESSING:
This mode allows you to specify the operand by giving its actual memory address
(typically specified in hex format) or by giving its abbreviated name. It is also used for
SFR accesses.
INDIRECT ADDRESSING:
In the indirect addressing mode, a register is used to hold the effective address of the
operand. This register, which holds the address, is called the pointer register and is
said to point to the operand. Only registers R0, R1 and DPTR can be used as pointer
registers. DPTR is useful in accessing operands which are in the external memory.
The 8051 microcontroller instructions are divided among five functional groups
1. Arithmetic
2. Logical
3. Data transfer
4. Boolean variable
5. Program branching