Sushila Devi Bansal College of Technology, Indore
Department of Electronics & Communication Microprocessor and its application
Engineering (EC-501)
Experiment no.09
Date of Performance Date of Submission Grade obtained
Student’s Name Enrollment No Signature of Faculty
EXPERIMENT NO.-9
Objective:- To study register set of 8051 microcontroller
INTRODUCTION:
8051 microcontroller is designed by Intel in 1981. It is an 8-bit microcontroller. It is
built with 40 pins DIP (dual inline package), 4kb of ROM storage and 128 bytes of RAM storage,
2 16-bit timers. It consists of are four parallel 8-bit ports, which are programmable as well as
addressable as per the requirement. An on-chip crystal oscillator is integrated in the
microcontroller having crystal frequency of 12 MHz.
Let us now discuss the architecture of 8051 Microcontroller.
In the following diagram, the system bus connects all the support devices to the CPU. The system
bus consists of an 8-bit data bus, a 16-bit address bus and bus control signals. All other devices
like program memory, ports, data memory, serial interface, interrupt control, timers, and the CPU
are all interfaced together through the system bus.
ARCHITECTURE OF 8051 MICROCONTROLLER
Registers are used in the CPU to store information on temporarily basis which could be data to be
processed, or an address pointing to the data which is to be fetched. In 8051, there is one data type
is of 8-bits, from the MSB (most significant bit) D7 to the LSB (least significant bit) D0. With 8-
bit data type, any data type larger than 8-bits must be broken into 8-bit chunks before it is
processed.
The most widely used registers of the 8051 are A (accumulator), B, R0-R7, DPTR (data pointer),
and PC (program counter). All these registers are of 8-bits, except DPTR and PC.
Storage Registers in 8051
We will discuss the following types of storage registers here −
• Accumulator
• R register
• B register
• Data Pointer (DPTR)
• Program Counter (PC)
• Stack Pointer (SP)
Accumulator
The accumulator, register A, is used for all arithmetic and logic operations. If the accumulator is
not present, then every result of each calculation (addition, multiplication, shift, etc.) is to be
stored into the main memory. Access to main memory is slower than access to a register like the
accumulator because the technology used for the large main memory is slower (but cheaper) than
that used for a register.
The "R" Registers
The "R" registers are a set of eight registers, namely, R0, R1 to R7. These registers function as
auxiliary or temporary storage registers in many operations. Consider an example of the sum of 10
and 20. Store a variable 10 in an accumulator and another variable 20 in, say, register R4. To
process the add
Addition operation, execute the following command −
ADD A,R4
After executing this instruction, the accumulator will contain the value 30. Thus "R" registers are
very important auxiliary or helper registers. The Accumulator alone would not be very useful if it
were not for these "R" registers. The "R" registers are meant for temporarily storage of values.
Let us take another example. We will add the values in R1 and R2 together and then subtract the
values of R3 and R4 from the result.
MOV A,R3 ;Move the value of R3 into the accumulator
ADD A,R4 ;Add the value of R4
MOV R5,A ;Store the resulting value temporarily in R5
MOV A,R1 ;Move the value of R1 into the accumulator
ADD A,R2 ;Add the value of R2
SUBB A,R5 ;Subtract the value of R5 (which now contains R3 + R4)
As you can see, we used R5 to temporarily hold the sum of R3 and R4. Of course, this is not the
most efficient way to calculate (R1 + R2) – (R3 + R4), but it does illustrate the use of the "R"
registers as a way to store values temporarily.
The "B" Register
The "B" register is very similar to the Accumulator in the sense that it may hold an 8-bit (1-byte)
value. The "B" register is used only by two 8051 instructions: MUL AB and DIV AB. To quickly
and easily multiply or divide A by another number, you may store the other number in "B" and
make use of these two instructions. Apart from using MUL and DIV instructions, the "B" register
is often used as yet another temporary storage register, much like a ninth R register.
The Data Pointer
The Data Pointer (DPTR) is the 8051’s only user-accessible 16-bit (2-byte) register. The
Accumulator, R0–R7 registers and B register are 1-byte value registers. DPTR is meant for
pointing to data. It is used by the 8051 to access external memory using the address indicated by
DPTR. DPTR is the only 16-bit register available and is often used to store 2-byte values.
The Program Counter
The Program Counter (PC) is a 2-byte address which tells the 8051 where the next instruction to
execute can be found in the memory. PC starts at 0000h when the 8051 initializes and is
incremented every time after an instruction is executed. PC is not always incremented by 1. Some
instructions may require 2 or 3 bytes; in such cases, the PC will be incremented by 2 or 3.
Branch, jump, and interrupt operations load the Program Counter with an address other than the
next sequential location. Activating a power-on reset will cause all values in the register to be lost.
It means the value of the PC is 0 upon reset, forcing the CPU to fetch the first opcode from the
ROM location 0000. It means we must place the first byte of upcode in ROM location 0000
because that is where the CPU expects to find the first instruction.
The Stack Pointer (SP)
The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit (1-byte) value. The
Stack Pointer tells the location from where the next value is to be removed from the stack. When a
value is pushed onto the stack, the value of SP is incremented and then the value is stored at the
resulting memory location. When a value is popped off the stack, the value is returned from the
memory location indicated by SP, and then the value of SP is decremented.
This order of operation is important. SP will be initialized to 07h when the 8051 is initialized. If a
value is pushed onto the stack at the same time, the value will be stored in the internal RAM
address 08h because the 8051 will first increment the value of SP (from 07h to 08h) and then will
store the pushed value at that memory address (08h). SP is modified directly by the 8051 by six
instructions: PUSH, POP, ACALL, LCALL, RET, and RETI.
RESULT:
Thus the internal architecture and instruction set of 8051 have been studied.