8085 Program to Find the Number of Negative Numbers in Array

In this program, we will write an 8085 Program to Find the Number of Negative Numbers in Array in the 8085 microprocessor with a program flow chart and explanation of the program.

8085 Program to Find the Number of Negative Numbers in Array

Program Statement

Given an array of N numbers. Write a program in the Assembly language program of 8084 to find the number of negative numbers in the array. Assume the array begins at memory location D001H and memory location D000H consists size of the array. Store the result at memory location E000H.

Explanation of Program

  • We have an array of N numbers. For e.g., we initialize the count with 5.
  • Also, we initialize a pointer to point the elements in the array.
  • We will check for the MSB. If the MSB of the number is 1, the number is negative.
  • Increment count for counting the negative numbers.
  • Increment the pointer to point to the next element. Check if MSB is 1. Repeat the process till all the numbers are scanned.
  • Store the count of negative numbers.

Flow Chart of Program

8085 Program to Find the Number of Negative Numbers in Array

Assembly Language Program

LabelInstructionCommentOperation
LDA D000HLoad count in the accumulatorA = 05 H
MOV C, AInitialize countC = 05 H
MVI B, 00Initialize the negative number count = 0B = 00 H
LXI H, D001HInitialize pointer to arrayH = D0H, L = 01H
BACK:MOV A, MGet the numberA ← (HL)
ANI 80Hcheck for MSBANDing with 80H
JZ SKIPCheck if MSB = 1if MSB = 1, the number is negative
INR BIncrement negative number countB = B + 1
SKIP:INX HIncrement memory pointerHL = HL + 1
DCR Cdecrement countC = C – 1
JNZ BACKif the count is 0 repeat
MOV A, BLoad negative count in AA = B
STA E000HStore the resultE000H = No. of negative numbers
HLTTerminate program executionStop
Sr. No.Name of the 8085 Programs
1.Write a program to load the data into the accumulator and any register.
2.Write a program to exchange the contents of memory locations.
3.Add two 8-bit numbers.
4.Subtract two 8-bit numbers.
5.Add two 16-bit numbers.
6.Subtract two 16-bit numbers
7.Find the 1’s complement of a Number
8.Find the 2’s complement of a Number
9.8085 Program To Mask The Lower Nibble
10.8085 Program To Mask The Upper Nibble
11.8085 program to pack the two unpacked BCD numbers
12.8085 program to Unpack the two packed BCD numbers
13.8085 program to find the sum of a series of 8-bit numbers
14.8085 Program to sort the numbers in ascending order
15.8085 Program to sort the numbers in Descending order
16.8085 Program to Multiply Two 8-bit Numbers
17.8085 Program to Divide 16-bit number by 8-bit number
18.8085 Program to Find the Number of Negative Numbers in Array
19.8085 Program to Find Maximum Number in Array
20.8085 Program to count the number of 1’s in a register
21.8085 Program to Calculate the sum of a series of even numbers
22.8085 Program to find the square of numbers
23.8085 Program to find the smallest number in the array

Hello friends, my name is Trupal Bhavsar, I am the Writer and Founder of this blog. I am Electronics Engineer(2014 pass out), Currently working as Junior Telecom Officer(B.S.N.L.) also I do Project Development, PCB designing and Teaching of Electronics Subjects.

Leave a Comment

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

telegram logo Join Our Telegram Group!