qa.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
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
                                    -♦-