8051 Microcontroller Program For 8 Bit Addition
8051 Microcontroller Program For 8 Bit Addition
Addition
This document outlines the process of adding two 8-bit numbers using the 8051 microcontroller. It covers the
objectives, the assembly language program, and the expected output, providing a comprehensive guide for
embedded systems enthusiasts and students. The 8051, a widely used microcontroller in various embedded
applications, is an excellent platform for understanding fundamental arithmetic operations at a low level.
DB by Dipankar Bala
Objective
The primary objective of this program is to perform the addition of two 8-bit numbers and store the result. This
exercise serves as a fundamental introduction to assembly language programming for the 8051 microcontroller,
demonstrating basic data manipulation and arithmetic operations. Specifically, the program aims to:
This foundational understanding is crucial for more complex embedded system applications, such as sensor data
processing, control algorithms, and digital signal processing, where efficient arithmetic operations are paramount.
Program
The following assembly language program for the 8051 microcontroller demonstrates the addition of two 8-bit
numbers. The numbers are hardcoded for simplicity, but in a real-world application, they could be fetched from
input ports or external memory.
MOV A, #30H ; Load the first 8-bit number (30H = 48 decimal) into Accumulator (A)
MOV R0, #20H ; Load the second 8-bit number (20H = 32 decimal) into Register R0
MOV 50H, A ; Store the result from Accumulator (A) into internal RAM location 50H
In this program, MOV A, #30H moves the hexadecimal value 30 (decimal 48) into the Accumulator (A). Similarly,
MOV R0, #20H moves the hexadecimal value 20 (decimal 32) into general-purpose register R0. The ADD A, R0
instruction performs the addition, with the sum automatically placed back into the Accumulator. Finally, MOV 50H,
A stores this sum into internal data memory at address 50H. The SJMP HERE instruction creates an infinite loop,
effectively stopping further program execution for observation of the result.
Output
Upon successful execution of the assembly program on an 8051 microcontroller, the sum of the two 8-bit numbers
will be stored in a designated memory location. To observe this output, a debugger or an emulator for the 8051
would be used to inspect the contents of the internal RAM.
As shown in the table, the Accumulator (A) will hold the result, which is 50H (hexadecimal) or 80 (decimal). This
value will also be explicitly saved to internal RAM location 50H. This outcome confirms that the addition operation
was performed correctly, demonstrating the fundamental arithmetic capabilities of the 8051 microcontroller when
programmed in assembly language.