;This program inputs a byte from location 300h
; and outputs the number of '1' bits in that byte into location 301h
;
;
        mov     cl,     8       ;look at all 8 bits
        mov     ah,     byte ptr 300h   ;grab the input
        mov     bh,     0       ;count of the one bits
deloop:
        add     ah,     ah      ;double the number (mult by 10, base 2)
;                               this shifts the number one position to left
;                               leaving the leftmost bit in the carry flag
        jnc     nextbit
        add     bh, 1           ;count the '1' bit
nextbit:
        sub     cl, 1           ;check for eight times
        jnz     deloop
        mov     byte ptr 301h, bh       ;move out the count of '1' bits
        hlt
        end