Solved programming problem

Count Total 1s in The Number in Assembly.

Source code

org 100h

.model samll

.data

     ones db 0

.code

main proc

   

   

    mov ax,100

   

    mov cx,16 ;for count total 16 bit

   

    L1:

        test ax,1       ;and operation

        jz lastbitzero  ;if both value are not same

        jnz lastbitone   ;if both value same 1&1

       

        lastbitzero:  

        jmp done

       

        lastbitone:      

        inc ones

       

        done:

        rcr ax,1 ;shift right use carry

       

        loop L1 ;calll L1 while cx>0

                                         

                                   

ret

Output

O

utput:
(click on the var to show output)

 

   
Join the discussion

Add your comment