Write an Assembly Language Program for Intel 8085 microprocessor to calculate the sum of N natural numbers, that is, ΣN = 1+2+3+ … +(N-1)+N.
Fulfil as many constraints as you can:
- Not using the formula of N*(N+1) / 2
- Not using any increment and decrement instructions like INR, DCR, INX, and DCX
- Not using memory address to read data and write output results (Assume Accumulator register for the same)
My Code is :
START: LDA 3000H
MOV B, A
INR A
MOV C, A
MVI A, 00H
LOOP1: ADD B
DCR C
JNZ LOOP1
MVI C, 02H
MVI B, 00H
LOOP2: INR B
SUB C
JNZ LOOP2
MOV A,B
STA 3001H
HLT
I have tried and made the program but with using all these constraints, while the question asks not to use them. So my doubt is whether it is possible to make a program without using these.