This code will print 03 for length of 3, hope that's ok with you. Otherwise, you need to test the first digit for zero before printing.
What you want to do here is divide by 100 the first time, print the 100's digit, then with the remainder, divide by 10. Or, if you want to print 4 digits, then divide by 1000, print a digit, then 100, print a digit, then 10, print a digit, and print the final remainder.
Note that your program is only good for 16-bit values, so a string longer than 65535 will wrap around with the indexing you're using, and the program will loop forever.
There is also a recursive method of printing a number that uses the stack. It's quite elegant, automatically supresses leading zeroes, and works for as many digits as will fit in an integer size.
Algorithm:
DecPrint(unsigned ax) {
if (ax/10 !=0)
DecPrint(ax / 10);
PrintDigit(ax % 10);
}
; input argument is unsigned in ax
DecPrint:
mov dx,0 ; must do 32-bit divide, or could overflow
mov bx,10
div bx ; ax = quotient, dx = remainder
and ax,ax ; if quotient is 0, don't need to print another level
je finish
push dx ; recursive call to self
call DecPrint
pop dx
finish:
add dl,'0' ; convert to ASCII
mov ah,2 ; DOS char print
int 21h
ret