8051, Microcontroller, Register Bank, Functionalities
Register Bank in the 8051
The 8051 microcontroller has four register banks, each containing 8 registers. Each register bank is associated with a certain segment of the program memory and is selected according to the current instruction's segment (Code or Data). The 8051 registers can be categorized into two types: Special Function Registers (SFRs) and General Purpose Registers (GPRs).
Special Function Registers (SFRs)
The 8051 consists of a set of 16 8-bit registers known as Special Function Registers (SFRs). These registers are located in the range of 0x80 to 0xFF. All SFRs have special functions and operations, such as controlling ports and timers, controlling watchdog timers and interrupts, and operating UARTs, etc. All SFRs’ names are preceded by the character "P". For example, P0 is the first SFR, P1 is the second, and so on.
General Purpose Registers (GPRs)
The 8051 contains eight General Purpose Registers (GPRs), which are used for executing instructions. GPRs are 8-bit registers designated as R0, R1, R2,... R7. They are located in the range of 0x00 to 0x7F. Generally, the data transfer instructions such as MOV, MVI, XCH, etc. involve the GPRs.
Switching Between Register Banks
In 8051, there are four register banks, each having 8 registers. The four banks are designated as Bank 0, Bank 1, Bank 2, and Bank 3. By default, the 8051 executes instructions from Bank 0. However, this can be changed by using the PSW (Program Status Word). The PSW contains a register bank select bit (RB0/RB1) which allows us to choose any one of the four register banks.