Skip to content
Related Articles

Related Articles

8086 program to find sum of Even numbers in a given series
  • Last Updated : 28 May, 2018

Problem – Write a program in 8086 microprocessor to find out the sum of series of even numbers, where numbers are stored from starting offset 500 and store the result at offset 600.

Example –

Algorithm –

  1. Assign 500 to SI
  2. Load data from offset SI to register CL (count) and assign 00 to register CH inc. SI by 1
  3. Load data from offset SI and apply TEST with 01, if result is non zero jump to step 5
  4. Add the offset data with register AL
  5. Increase offset by 1
  6. LOOP to step 3
  7. Store the result (content of register AL) to offset 600
  8. Stop

Program –



MEMORY ADDRESSMNEMONICSCOMMENT
400MOV SI, 500SI<-500
403MOV CL, [SI]CL<-[SI]
405INC SISI<-SI+1
406MOV CH, 00CH<-00
408MOV AL, 00AL<-00
40AMOV BL, [SI]BL<-[SI]
40CTEST BL, 01BL AND 01
40FJNZ 413JUMP IF NOT ZERO
411ADD AL, BLAL<-AL+BL
413INC SISI<-SI+1
414LOOP 40AJUMP TO 40A IF CX NOT ZERO
416MOV [600], ALAL->[600]
41AHLTEND

Explanation –

  1. MOV SI, 500: assign 500 to SI
  2. MOV CL, [SI]: load data from offset SI to register CL
  3. INC SI: increase value of SI by 1
  4. MOV CH, 00: assign 00 to register CH
  5. MOV AL, 00: assign 00 to register AL
  6. MOV BL, [SI]: load data from offset SI to register BL
  7. TEST BL, 01: AND register BL with 01
  8. JNZ 413: jump to address 413 if not zero
  9. ADD AL, BL: add contents of register AL and BL
  10. INC SI: increase value of SI by 1
  11. LOOP 40A: jump to 40A if CX not zero and CX=CX-1
  12. MOV [600], AL: store the value of register AL to offset 600
  13. HLT: end.

Refer for – 8086 program to find sum of odd numbers in a given series

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 :