- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
8051 Program to Add two 8 Bit numbers
Intel 8051 is an 8-bit microcontroller. It has many powerful instructions and IO accessing techniques. In this section, we will see one of the simplest program using 8051.
Here we will add two8-bit numbers using this microcontroller. The register A(Accumulator) is used as one operand in the operations. There are seven registers R0 – R7 in different register banks. We can use any of them as the second operand.
We are taking two number 5FH and D8H at location 20H and 21H, After adding them, the result will be stored at location 30H and 31H.
MOVR0,#20H;set source address 20H to R0 MOVR1,#30H;set destination address 30H to R1 MOVA,@R0; take the value from source to register A MOVR5,A; Move the value from A to R5 MOVR4,#00H; Clear register R4 to store carry INCR0; Point to the next location MOVA,@R0; take the value from source to register A ADDA,R5;Add R5 with A and store to register A JNC SAVE INCR4; Increment R4 to get carry MOVB,R4;Get carry to register B MOV@R1,B; Store the carry first INCR1; Increase R1 to point to the next address SAVE: MOV@R1,A;Store the result HALT: SJMP HALT ;Stop the program
So by adding 5FH + D8H, the result will be 137H. The 01H will be stored at 30H, and 37 is stored at 31H.
- 8051 Program to Subtract two 8 Bit numbers
- 8051 Program to Multiply two 8 Bit numbers
- 8051 Program to Divide two 8 Bit numbers
- Program to Subtract two 8 Bit numbers in 8051 Microprocessor
- Program to Multiply two 8 Bit numbers in 8051 Microprocessor
- Program to Divide two 8 Bit numbers in 8051 Microprocessor
- 8085 Program to Add two 8 Bit numbers
- 8086 program to add two 8 bit BCD numbers
- Program to Add two 8 Bit numbers in 8085 Microprocessor
- 8085 Program to Subtract two 8 Bit numbers
- 8085 Program to Divide two 8 Bit numbers
- 8085 program to multiply two 8 bit numbers
- 8085 program to swap two 8-bit numbers
- 8086 program to multiply two 8-bit numbers
- 8085 Program to multiply two 8-bit numbers (shift and add method)