8051 code to find the sum of negative numbers stored in an array.

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.


1)Initializing register R0 with the array address and register R1 with counter.
2)Storing the first value of array in accumalator.
3)Rotating it left to check whether the carry bit is 1 or 0.
4)If carry bit is 1 adding and if the carry bit 0 then repeating the above steps.
5)Repeating all the above steps till the counter is 0.

Code goes here:

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