8051 Micrcontroller
8051 Micrcontroller
A Register (Accumulator)
A register is a general-purpose register used for storing intermediate results obtained during
operation. Prior to executing an instruction upon any number or operand it is necessary to
store it in the accumulator first. All results obtained from arithmetical operations performed
by the ALU are stored in the accumulator. Data to be moved from one register to another
must go through the accumulator. In other words, the A register is the most commonly used
register and it is impossible to imagine a microcontroller without it. More than half
instructions used by the 8051 microcontroller use somehow the accumulator.
B Register
Multiplication and division can be performed only upon numbers stored in the A and B
registers. All other instructions in the program can use this register as a spare accumulator
(A).
The program status word contains the math flags, user flag F0, and the register select bits
this identify which of the four general-purpose register banks is currently in use by the
programmer. The remaining two user flags, GF0 and GF1, are stored in PCON.
Fig. 8051 Architecture
CY, the carry flag
This flag is set whenever there is a carry out from the D7 bit. This flag bit is affected after an
8-bit addition or subtraction. It can also be set to 1 or 0 directly by an instruction "SETB C"
and "CLR C", where "SETB C" stands for set bit carry and "CLR C" for clear carry.
AC, the auxiliary carry flag
If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set otherwise it is
cleared. This flag is used by instruction that performs BCD arithmetic.
ALU
The arithmetic and logic unit performs 8-bit arithmetic and logical operations over the
operands held by the temporary registers TMPI and TMP2. Users cannot access these
temporary registers.
Instruction Register
This register decodes the opcode of an instruction to be executed and gives information to
the timing and control unit to generate necessary signals for the execution of the instruction.