Program to find the sum of all negative numbers stored in an array.
This program finds the negative numbers in an array and adds them.Basically negative number is one whose carry bit is 1.
Code goes here:
MAIN: MOV R0,#0XA0 ; the address of the stored array
MOV R1,#10 ;the counter which counts the numbers stored in array
LOOP: MOV A,@R0
RLC A ; rotating right to check whether the carry bit is 1
JNC LABEL1 ; if the carry bit is 0 then it is positive so it should not be added and jump to label1
ADD A,R2 ;adding if the number is negative
LABEL1: INC R0
DJNZ R1,LOOP ;checking the counter