8051 ALP program to find number of negative numbers in an array

I have posted how to find a number is positive or negative  before…. Just check it.
            ORG 000h
            MOV DPTR,#0Ah  ; an external address
            MOV RO,#0Ah       ;array counter
            MOV R1,#0h           ;to count number neg numbers
 loop:
            MOV A,@DPTR
            RLC A
            JNC pos
            INC R1.  ;Counter
            DJNZ R0,loop
             SJMP end
       
pos: DJNZ R0,loop

end: NOP

END

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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisment ad adsense adlogger