In the article, program of Microprocessor 8085 to count negative numbers from block of data in assembly language programming (ALP) is explained.
It is highly recommended to learn the instruction set of 8085 in detail before programming.
Find the number of negative elements (most significant bit 1) in a block of data. The length of the block is in memory location 2200H and the block itself begins in memory location 2201H. Store the number of negative elements in memory location 2300H
Flowchart for Program
MOV C, A ; Initialize count
MVI B, 00 ; Negative number = 0
LXI H, 2201H ; Initialize pointer
BACK: MOV A, M ; Get the number
ANI 80H ; Check for MSB
JZ SKIP ; If MSB = 1
INR B ; Increment negative number count
SKIP: INX H ; Increment pointer
DCR C ; Decrement count
JNZ BACK ; If count 0 repeat
MOV A, B
STA 2300H ; Store the result
HLT ; Terminate program execution
(2200H) = 04H
(2201H) = 56H
(2202H) = A9H
(2203H) = 73H
(2204H) = 82H
Result = 02 since 2202H and 2204H contain numbers with a MSB of 1.