- 8051

8051 alp code to find the number of even numbers in an array.

I have posted how to find a number is even or nor before…. Just check it.

            ORG 000h
            MOV DPTR,#0Ah  ; an external address
            MOV RO,#0Ah       ;array counter
            MOV R1,#0h           ;to count number even numbers
 loop:
            MOV A,@DPTR
            RRC A
            JC  odd
            INC R1
            DJNZ R0,loop
             SJMP end
         
odd: DJNZ R0,loop

end: NOP

END

In alp programming its important to look that loops are executed only when we need ,coz as is said,compiler executes sequentially.If u dont branch them correctly ,the program may go wrong.

Leave a Reply