 
; proc: numtoascii - get a number and turn it into a string of digits
; 123 -> '123$'  :  1230/10  -->  12  (3)    , 12/10 -> 1 (2), 1/10   0 (1)


;  '1'   31h,   '0'  30h,   '2'  32h
IDEAL
MODEL small
STACK 100h
DATASEG
numtoprint   db  '$$$$$'
; --------------------------
; Your variables here
; --------------------------
CODESEG

proc          numtoascii
              push  bp
              mov   bp,sp
              push  cx
              push  bx
              mov   ax,[bp+4]
              mov   si,[bp+6]
              mov   bx,10
              xor   cx,cx
digit1:
              xor   dx,dx
              div   bx   ;  result ax,  remainder: dx
              push  dx
              inc   cx
              cmp   ax,0
              jne   digit1         ;      1 2 3
convdigit:
              pop   dx
              add   dl,30h         ; make the ascii code of the digit
              mov   [si],dl
              inc   si 
              loop  convdigit
              pop   bx
              pop   cx
              pop   bp 
              ret   4
endp          numtoascii 
;--------------------------------------------------------------------
start:
	          mov ax, @data
	          mov ds, ax

              push offset  numtoprint
              mov  ax,3541
              push ax
              call numtoascii ;  numtoprint = '125$'
              mov   dx, offset numtoprint
              mov   ah,9h
              int   21h 

    		
exit:
	          mov ax, 4c00h
	          int 21h
END start


