8085 Programming : In a set of nos add only the even nos



8085 Programming



            LDA 2200H  


      MOV C, A  ; Initialize counter  


            MVI B, 00H ; sum  =  0  


      LXI H, 2201H ; Initialize pointer  


BACK: MOV A, M  ; Get the number  


      ANI, 01H   ; Mask Bit1 to Bit7  


      JNZ SKIP  ; Don’t add if number is ODD  


      MOV A, B  ; Get the sum  


      ADD M  ; SUM = SUM + data  


      MOV B, A  ; Store result in B register  


SKIP:   INX  H        ; increment pointer  


      DCR C ; Decrement counter  


      JNZ BACK  ; if counter 0 repeat  


      STA 2210H ; store sum  


      HLT    ; Terminate program execution  



Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C