Different Types of Registers used in 8051 Microcontroller

 

Different Types of Registers used in 8051 Microcontroller

The register is the main part of the Microcontrollers and microprocessor that provide a fast way to collect and store data. If we want to manipulate data with a controller or processor by performing addition, subtraction, and so on, we cannot do that directly in the memory, but it needs registers to process and store the data. Microcontrollers contain several types of registers that can be classified according to their content or instructions that operate in them.

Register: A register is a small place in a CPU that can store small amounts of the data used for performing various operations such as addition and multiplication and loads the resulting data on the main memory. Registers contain the address of the memory location where the data is to be stored. 

Type of Register in 8051 Microcontroller :The 8051 microcontroller contains mainly two types of registers

  1.      General-purpose registers (Byte addressable registers)
  2.      Special function registers (Bit addressable registers)


 The 8051 microcontroller consists of 256 bytes of RAM, which is divided into two ways, such as 128 bytes for general purpose and 128 bytes for special function registers (SFR) memory. The memory which is used for general purpose is called as RAM, and the memory used for SFR contains all the peripheral related registers like Accumulator, ‘B’ register, Timers or Counters, and interrupt related registers.

General Purpose Registers

                                                

     The general-purpose memory is called as the RAM of the 8051 microcontrollers,  which is divided into 3 areas such as banks, bit-addressable area, and scratch-pad area. The banks contain different general-purpose registers such as R0-R7, and all such registers are byte-addressable registers that store or remove only 1-byte of data.


A and B CPU Registers


The 8051 contains 34 general-purpose, or working, registers. Two of these, registers A and B, comprise the mathematical core of the 8051 central processing unit (CPU). The other 32 are arranged as part of internal RAM in four banks, BO-B3, of eight registers each, named R0 to R7.

The A (accumulator) register is the most versatile of the two CPU registers and is used for many operations, including addition, subtraction, integer multiplication and division, and Boolean bit manipulations. The A register is also used for all data transfers be tween the 8051 and any external memory. The B register is used with the A register for multiplication and division operations and has no other function other than as a location where data may be stored.

Flags and the Program Status Word (PSW)


Flags are 1-bit registers provided to store the results of certain program instructions. Other instructions can test the condition of the flags and make decisions based upon the flag states. In order that the flags may be conveniently addressed, they are grouped inside the program status word (PSW) and the power control (PCON) registers.


The 8051 has four math flags that respond automatically to the outcomes of math operations and three general-purpose user flags that can be set to 1 or cleared to 0 by the programmer as desired. The math flags include carry (C), auxiliary carry (AC), overflow (OV), and parity (P). User flags are named FO. GFO, and GF1; they are general-purpose flags that may be used by the programmer to record some event in the program. Note that all of the flags can be set and cleared by the programmer at will. The math flags, however, are also affected by math operations.


The program status word is shown in Figure 1.1. The PSW contains the math flags. user program flag FO, and the register select bits that identify which of the four general purpose register banks is currently in use by the program. The remaining two user flags, GFO and GFI, are stored in PCON,.



    7                    6                 5                 4                  3                  2                  1                0

  CY

  AC

  F0

RS1

  RS0

  OV

    -

P

                                                                 Fig-1.1

               Program Status Word(PSW) Special Function Resistor

Post a Comment

0 Comments