in case of 10b first 0 is pushed to stack and then 1 is pushed
This seems to be where you're going wrong, Tomar. When we divide 10b or 2 decimal by 10 decimal, the quotient is zero (in ax) and the remainer is 2 (in dx). It is this 2 (or 10b if you like) that gets pushed to the stack. Since the quotient is zero, we're all done, and the 2 is the only thing pushed to the stack. Then we pop it and add '0' (or 30h or 48 decimal). this "converts" the number 2 to the ascii code for the character '2' (32h or 50 decimal) which is what we want to print.
If we wanted to print a character '1' followed by a character '0', we could have divided by 2 (10b) instead of 10 decimal (0Ah or 1010b). It's much faster to divide by 2 with a "shr" than with a "div", but "div" works too - try it!
"hexadecimal", "decimal" and "binary" are just different ways to represent a number - it's the same number. "binary" may be confusing, since we might mean "a string of '1's and '0's" or we might mean "a plain number". The computer stores everything as a series of 1 bits and 0 bits, but we do not usually see the individual bits, even in a debugger.
Joe/dogman is correct that stepping through your code in a debugger will help you understand it. Keep in mind that a debugger represents everything as hex. When you do "mov si, 10", you'll see "0A", not "10" - its the same number. When I first tried to use "debug" I didn't know that 'q' would get me back to the command prompt - I had to reboot to get out of "debug". The other important command is '?' - this will print out the other commands you can use. When you get to "int 21h" (the debugger won't show the 'h'), use 'p' (proceed) not 't' (trace). Tracing through the "bowels of DOS" may be interesting, but my experience is that it crashes debug before you learn much. Note that to debug your program, do "debug myprog.com" - the ".com" has to be there! There are other (better?) debuggers besides "debug", but "debug" is usually available. Try it - you won't break anything (probably
).
Your code, as posted, doesn't contain any "exit" to get back to dos. This will probably cause a crash.
mov ah, 4Ch
mov al, 0 ; indicate "no error"
int 21h
is the recommended method to get back to dos, although there are other ways.
Best,
Frank