Code:
; Program to find number of 0s from 16 bit number
.MODEL SMALL
.STACK 100H
.DATA
NUM DW 1234H
COUNT DB 0H
.CODE
MOV AX , @DATA ;Initializing Data Segment
MOV DS , AX
MOV AX , NUM
MOV CX , 16
MOV BL , 00
NEXT:
ROR AX , 1H ; Rotate right by 1 bit
JC UP ; Jump if carry
INC BL ; INC COUNT
UP:
LOOP NEXT ; Decrement CX if cx == 0 then exit
MOV COUNT , BL
MOV DH , 00
MOV DL , COUNT
MOV AH , 2 ; Service routine to print contain of DX
INT 21H
MOV AH , 4CH ; Service routine 4ch to exit
INT 21H
END
; Program to find number of 0s from 16 bit number
.MODEL SMALL
.STACK 100H
.DATA
NUM DW 1234H
COUNT DB 0H
.CODE
MOV AX , @DATA ;Initializing Data Segment
MOV DS , AX
MOV AX , NUM
MOV CX , 16
MOV BL , 00
NEXT:
ROR AX , 1H ; Rotate right by 1 bit
JC UP ; Jump if carry
INC BL ; INC COUNT
UP:
LOOP NEXT ; Decrement CX if cx == 0 then exit
MOV COUNT , BL
MOV DH , 00
MOV DL , COUNT
MOV AH , 2 ; Service routine to print contain of DX
INT 21H
MOV AH , 4CH ; Service routine 4ch to exit
INT 21H
END