qa.hlp (Table of Contents; Topic list)
IntToAsc
   Example  Back  Contents  Index
──────────────────────────────────────────────────────────────────────────────
 
;* IntToAsc - Converts integer to ASCII string. This procedure is useful
;* only for assembly language, and is not intended to be C-callable.
;*
;* Shows:   Instructions - cwd     aam     xchg
;*
;* Entry:   AX = integer (9999 max)
;*
;* Return:  DX:AX = 4-digit ASCII number
 
IntToAsc PROC
 
        cwd                             ; Zero DX register
        mov     cx, 100                 ; Divide AX by 100, yields
        div     cx                      ;   AX=quotient, DX=remainder
        aam                             ; Make digits unpacked BCD
        or      ax, '00'                ; Convert to ASCII
        xchg    ax, dx                  ; Do same thing for DX
        aam
        or      ax, '00'
        ret                             ; Return DX:AX = ASCII number
 
IntToAsc ENDP
                                    -♦-