0% found this document useful (0 votes)
12 views4 pages

8051 Microcontroller Program For 8 Bit Addition

This document provides a guide for adding two 8-bit numbers using the 8051 microcontroller, detailing the assembly language program and expected output. The program loads two predefined numbers, performs the addition, and stores the result in a designated memory location while handling potential overflow. It serves as an introduction to assembly programming and arithmetic operations relevant for embedded systems applications.

Uploaded by

dipankarbala0001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

8051 Microcontroller Program For 8 Bit Addition

This document provides a guide for adding two 8-bit numbers using the 8051 microcontroller, detailing the assembly language program and expected output. The program loads two predefined numbers, performs the addition, and stores the result in a designated memory location while handling potential overflow. It serves as an introduction to assembly programming and arithmetic operations relevant for embedded systems applications.

Uploaded by

dipankarbala0001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

8051 Microcontroller Program for 8-bit

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:

Load two predefined 8-bit numbers into internal registers.


Execute an addition operation on these numbers.
Store the sum in a designated memory location or register.
Handle potential overflow conditions, although for this basic program, the focus is on direct addition within the
8-bit range.

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.

ORG 0000H ; Start program at address 0000H

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

ADD A, R0 ; Add the content of R0 to the Accumulator (A)


; Result (30H + 20H = 50H) is stored in A

MOV 50H, A ; Store the result from Accumulator (A) into internal RAM location 50H

HERE: SJMP HERE ; Loop indefinitely, halting program execution


END ; End of program

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.

Register/Memory Value Before Execution Value After Execution Description


Location

Accumulator (A) Undefined 50H Contains the first


number (30H) initially,
then the sum (50H)
after addition.

Register R0 Undefined 20H Contains the second


number (20H).

Internal RAM 50H Undefined 50H The memory location


where the final sum
(50H) is stored.

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.

You might also like