home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / asm / SCSIDRV.ZIP / DUMP.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-11-06  |  1.3 KB  |  96 lines

  1. ;
  2. ; Convert bin (ax) to ascii (bx => buffer)
  3. ;
  4. bin_ascii    proc    near
  5.         pusha
  6.         push    ax
  7.         mov    cx,6
  8. fill_buff:    mov    byte ptr [bx],' '
  9.         inc    bx
  10.         loop    fill_buff
  11.         mov    si,10
  12.         or    ax,ax
  13.         jns    clr_dvd
  14.         neg    ax
  15. clr_dvd:    sub    dx,dx
  16.         div    si
  17.         add    dx,'0'
  18.         dec    bx
  19.         mov    [bx],dl
  20.         inc    cx
  21.         or    ax,ax
  22.         jnz    clr_dvd
  23.         pop    ax
  24.         or    ax,ax
  25.         jns    no_more
  26.         dec    bx
  27.         mov    byte ptr [bx],'-'
  28. no_more:    popa
  29.         ret
  30. bin_ascii    endp
  31.  
  32. ;
  33. ; Convert Hex (dx) to Ascii (bx => buffer)
  34. ;
  35. hex2asc4    proc    near
  36.         push    cx
  37.         push    ax
  38.         mov    cx,4        ;Do Four Digits
  39. h241:        rol    dx,1
  40.         rol    dx,1
  41.         rol    dx,1
  42.         rol    dx,1
  43.         mov    al,dl        ;Get the Current Digit
  44.         and    al,0Fh
  45.         cmp    al,0Ah        ;Is It Hex?
  46.         jge    h242
  47.         add    al,30h        ;Normal Digit
  48.         jmp    h243
  49. h242:        add    al,37h        ;Hex Digit
  50. h243:        mov    [bx],al        ;Insert in Buffer
  51.         inc    bx
  52.         loop    h241
  53.         pop    ax
  54.         pop    cx
  55.         ret
  56. hex2asc4    endp
  57.  
  58. ;
  59. ; Convert Hex (dl) to Ascii (bx => buffer)
  60. ;
  61. hex2asc2    proc    near
  62.         push    cx
  63.         push    ax
  64.         mov    cx,2        ;Do Two Digits
  65. h221:        rol    dl,1
  66.         rol    dl,1
  67.         rol    dl,1
  68.         rol    dl,1
  69.         mov    al,dl        ;Get the Current Digit
  70.         and    al,0Fh
  71.         cmp    al,0Ah        ;Is It Hex?
  72.         jge    h222
  73.         add    al,30h        ;Normal Digit
  74.         jmp    h223
  75. h222:        add    al,37h        ;Hex Digit
  76. h223:        mov    [bx],al        ;Insert in Buffer
  77.         inc    bx
  78.         loop    h221
  79.         pop    ax
  80.         pop    cx
  81.         ret
  82. hex2asc2    endp
  83.  
  84. ;
  85. ; Print a string
  86. ;
  87. ; ds:dx => string
  88. ;
  89. puts        proc    near
  90.         pusha
  91.         mov    ah,9        ;DOS print string
  92.         int    21h
  93.         popa
  94.         ret
  95. puts        endp
  96.