CALCULATE THE SUM OF SERIES OF NUMBERS WITH CARRY
In 8085 microprocessor, In this program, we perform addition for ‘n’ numbers. Where we define the total no’s to be added. All the values will be added with the accumulator. And this problem we have a new carry flag to enable the carry where we can see 16-bit resultant value.
Step 1: LXI H,2000h; to load the address in H-L register pair using LXI H from 16-bit location 2000h.
Step 2: MOV C, M; to move the value of 2000h memory address value into the C register.
Step 3: XRA A; to perform XOR operation.
Step 4: MOV D, A; to move the accumulator value to D register.
Step 5: INX H; to increase the value of the H-L register pair to get the next memory location.
Step 6: ADD M; to add memory location value with accumulator.
Step 7: JNC ; Jump on non-carry on INR D step 8.
Step 8: INR D; Increment register by 1 for D register.
Step 9: DCR C; to decrement the value of C register.
Step 10: JNZ; to jump on non zero to INX H.
Step 11: INX H; to increment H-L pair.
Step 12: MOV M, D; to store D register value in a memory location which is 2004h.
Step 13: INX H; to increment H-L register pair.
Step 14: MOV M, A; to move the value of Accumulator to memory.
Step 15: HLT; to stop the program.
|3003||MOV C, M||4E|
|3005||MOV D, A||47|
|3011||MOV M, D||72|
|3013||MOV M, A||77|
using namespace std;
int i, n, sum=0;
cout<<"Enter size of the array: ";
cout<<"Enter" << n << "elements in the array: ";
for(i=0; i<n; i++)
for(i=0; i<n; i++)
sum += arr[i];
cout<<"Sum of all elements of array = "<<sum;
INPUT AND OUTPUT :
In this program, we tried to solve the problem with repetitive addition with a loop. where we predefine that loop iteration times and given values will add with accumulator. we also tried to show and store the carrying value. And also exampled value is also given as 0Fh + 0Fh and the carry of that 02h and the summation value is 1Eh.
YOU MIGHT LIKE:
1> Which language is used in microcontroller?
2> What are the three types of language processor?
Ans: There are three types of language processors:
3> What is difference between microprocessor and micro controller?
Ans: Microprocessor consists of only a Central Processing Unit, whereas Micro Controller contains a CPU, Memory, I/O all integrated into one chip. The microprocessor uses an external bus to interface to RAM, ROM, and other peripherals, on the other hand, Microcontroller uses an internal controlling bus.
4> Is Raspberry Pi a microcontroller?
Ans: An Arduino is a microcontroller motherboard. A microcontroller is a simple computer that can run one program at a time, over and over again. It is very easy to use. A Raspberry Pi is a general-purpose computer, usually with a Linux operating system, and the ability to run multiple programs.
5> What are the 3 most important parts of a microprocessor?
Ans: There are three most important Microprocessor Components, i.e.
6> What is the operation of add B instruction in 8085 MP?
Ans: There are some of the important instructions in 8085 microprocessor. 1. ADD: – The content of operand are added to the content of the accumulator and the result is stored in Accumulator. Eg- ADD B (it adds the content of accumulator to the content of the register B)
7> Difference between Security and Protection ?
Ans: The main difference between security and protection lies within the fact that the security handles the external information threats in the computer systems whereas the protection deals with the internal threats.