I am new to assembly language and trying to learn it by means of code ,I found a piece of code which says it will convert binary to decimal and output as ascii on to screen .Below is the code
org 100h
push ax
push cx
push dx
push si
mov dx,10
mov ax,dx ;Assuming number to print starts in DX
mov si,10 ;decimal 10
xor cx,cx ;Initialize count at 0
NonZero:
xor dx,dx ;Clear last remainder
div si
push dx ;Save digits in reverse order
inc cx
or ax,ax ;Is original number down to 0 yet?
jnz NonZero ;No, continue looping
mov ah,02h
WriteDigitLoop:
pop dx
add dx,"0" ;Convert to ASCII
int 21h ; and print
loop WriteDigitLoop
EndDecimal:
pop si
pop dx
pop cx
pop ax
Now lets assume ,initial value of dx is 10 ,so I guess output should comes out to be 2 . but actual output coming out to be 10 which is obvious as per code flow.
If it is a problem then what changes should I make to rectify this.