Skip to content
Related Articles

Related Articles

8085 program to find the sum of series of even numbers
  • Last Updated : 25 Nov, 2019
GeeksforGeeks - Summer Carnival Banner

Problem – Calculate the sum of series of even numbers from the given list of numbers. The length of the list is in memory location 2200H and the series begins from memory location 2201H. Result will store at memory location 2210H.

Examples –

Input : 
2200H= 4H
2201H= 20H
2202H= l5H
2203H= l3H
2204H= 22H

Output : 
Result 2210H = 42H

Program –

LDA2200H[A] <- 2200H
MOVC, AInitialize counter
MVIB, 00Hsum = 0
LXIH, 2201HInitialize pointer
BACK:MOV A, MGet the number
ANI0lHMask Bit l to Bit7
JNZSKIPDon’t add if number is ODD
MOVA, BGet the sum
ADDMSUM = SUM + data
MOVB, AStore result in B register
SKIP:INX Hincrement pointer
DCRCDecrement counter
JNZBACKif counter 0 repeat
MOVA, BStore result in A register
STA2210Hstore sum
HLTTerminate program execution

Explanation –
A microprocessor is a computer processor that incorporates the functions of a central processing unit on a single integrated circuit.

  1. A is an 8-bit accumulator which is used to load and store the data directly.
  2. LDA is used to load accumulator direct using 16-bit address (3 Byte instruction).
  3. Instructions like MOV, MVI, LDA are the data transfer instructions.
  4. ADD is used to add data.
  5. HLT is used to halt the program.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :