;This program counts all the '1' bits in an array
;
len equ 100
jmp startit
count dw 0
nums db len dup (0)
;
startit: mov si,0 ;offset into array
mov dl, 00000001b ;mask
mov cx, len*8
top: test nums[si], dl ;inspect bit
jz nxtbit ;bit was off, don't count it
inc count
nxtbit: rol dl, 1
jnc checkend
inc si ;inspect next byte in memory
checkend: sub cx, 1 ;end of array
jnz top
int 20h
end