Monday, April 4, 2011

Program to find number of negative numbers in array


I am personally not able to understand this particular program as it uses MSB instead of sign flag. This is direct rip off untested version from a book.
--------------------
        MVI C, 05H ; SIZE OF ARRAY
MVI B, 00H ; COUNT OF NEGATIVE NUMBERS
LXI H, 2000H ; LOAD STARTING ADDRESS
BACK MOV A, M ;
ANI 80H ;
JZ SKIP ; CHECK IF MSB = 1 IF MSB = 1 THEN NUMBER IS NEGATIVE
INR B ;
SKIP INX H ;
DCR C ;
JNZ BACK ;
STA 1FFFH ;
HLT ;

No comments:

Post a Comment