home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / asm / ucrstdlb / htoa.asm < prev    next >
Assembly Source File  |  1991-10-12  |  1KB  |  92 lines

  1. StdGrp        group    stdlib,stddata
  2. stddata        segment    para public 'sldata'
  3. stddata        ends
  4. ;
  5. stdlib        segment    para public 'slcode'
  6.         assume    cs:stdgrp
  7.         extrn    sl_malloc:far
  8. ;
  9. ;
  10. ;
  11. ; HTOA- Converts value in AL to a string of length two containing two
  12. ;    hexadecimal characters.  Stores result into string at address
  13. ;    ES:DI.
  14. ;
  15. ; HTOA2-Just like HTOA except it does not preserve DI.
  16. ;
  17.         public    sl_htoa
  18. sl_htoa        proc    far
  19.         push    di
  20.         call    far ptr sl_htoa2
  21.         pop    di
  22.         ret
  23. sl_htoa        endp
  24. ;
  25. ;
  26.         public    sl_htoa2
  27. sl_htoa2    proc    far
  28.         push    ax
  29.         call    hextoa
  30.         mov    byte ptr es:[di], 0
  31.         clc                ;Needed by sl_htoam
  32.         pop    ax
  33.         ret
  34. sl_htoa2    endp
  35. ;
  36. ;
  37. ; WTOA- Converts the binary value in AX to a string of four hexadecimal
  38. ;    characters.
  39. ;
  40. ; WTOA2-Like the above, except it does not preserve DI.
  41. ;
  42.         public    sl_wtoa
  43. sl_wtoa        proc    far
  44.         push    di
  45.         call    far ptr sl_wtoa2
  46.         pop    di
  47.         ret
  48. sl_wtoa        endp
  49. ;
  50.         public    sl_wtoa2
  51. sl_wtoa2    proc    far
  52.         push    ax
  53.         xchg    al, ah
  54.         call    hextoa
  55.         xchg    al, ah
  56.         call    hextoa
  57.         mov    byte ptr es:[di], 0
  58.         clc                ;Needed by sl_wtoam
  59.         pop    ax
  60.         ret
  61. sl_wtoa2    endp
  62. ;
  63. ;
  64. ;
  65. hextoa        proc    near
  66.         push    ax
  67.         mov    ah, al
  68.         shr    al, 1
  69.         shr    al, 1
  70.         shr    al, 1
  71.         shr    al, 1
  72.         add    al, 90h
  73.         daa
  74.         adc    al, 40h
  75.         daa
  76.         mov    es:[di], al
  77.         inc    di
  78.         mov    al, ah
  79.         and    al, 0fh
  80.         add    al, 90h
  81.         daa
  82.         adc    al, 40h
  83.         daa
  84.         mov    es:[di], al
  85.         inc    di
  86.         pop    ax
  87.         ret
  88. hextoa        endp
  89. ;
  90. stdlib        ends
  91.         end
  92.