Count bits - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Count bits

Hi there,

I am trying write a program which count number of 1 in the 8-bit. I am storing input number in decimal and trying to find out how many 1 is there in binary 1. But not getting how to do. Please find my code as follow:

[code]
data segment
n db 7 ;Define input number data ends



code segment
assume cs:code, ds:data, ss:stack1

start:

mov ax, data
mov ds, ax
mov al, 0
mov bl, n
;and bl, 00000001b

inc al

mov ah, 4ch
int 21h
code ends

end start
[/code]

Is any one can help me?

Thanking You,

Comments

Sign In or Register to comment.