Nasm Assembly

Assembly programing help please?
how to calculate number of one bits in BX and complement an equal number of least significant bits in AX.
i am using iapx 88 nasm
xor dx, dx
mov cx, 16
count:
rol bx, 1
jnc next
inc dx
next:
loop count
mov bx, 1
shl bx, dx
dec bx
rol bx, dx
xor ax, bx
Cheers,
Bogdan
