Monday, 6 July 2015

Use ROL To Count The Number Of 1 Bits In BX, Without Changing BX.Put The Answer In AX In Assembly Language.

/*
Use ROL To Count The Number Of 1 Bits In BX, Without Changing BX.Put The Answer In AX In Assembly Language.
*/

/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/

Solution:

.MODEL SMALL
.STACK 100H
.DATA
 
.CODE

MAIN PROC
 
    XOR AX,AX
    MOV CX,0
    MOV BX,0000000000000011B
    TOP:
       CMP CX,16
       JE END_
     
       INC CX
     
       ROL BX,1
       JNC NEXT
       INC AX
    NEXT:
        JMP TOP
 
    END_:
    ADD AX,30H  
    MOV AH,2
    MOV DX,AX
    INT 21H
                 
    MOV AH,4CH
    INT 21H  
   
    MAIN ENDP
END MAIN

No comments:

Post a Comment