Statement: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


Home
8085 Forum
8085 Free Projects
8085 Free Programs
8085 Tutorials
8085 details
Interfacing Techniques
Electronic Tutorials
Electronic Projects
Assembler/ IDE
Datasheets
Guest Book
About Me
Sample problem

       (2200H) = 04H
       (2201H) = 56H
       (2202H) = A9H
       (2203H) = 73H
       (2204H) = 82H

Result = 02 since 2202H and 2204H contain numbers with a MSB of 1.

Source program

               LDA 2200H
               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


FLOWCHART