The program looks fine.
However, your input isn't correct. In this instruction:
mov dx,10
You're setting the input to 10
decimal, but you are intending to set it to 10
binary. The binary value in dx
at that point is 1010
(because you set it to 10
decimal). So the output is coming out 10
, which is what you'd expect. If you want to set dx
to 10
binary, you can do this:
mov dx,10b
Then when you run your program, the output should be 2
.