home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / src / dumphex.asm < prev    next >
Assembly Source File  |  1995-06-25  |  1KB  |  76 lines

  1. ;put into the public domain by Russell Nelson, nelson@crynwr.com
  2.  
  3. dump_hex:
  4. ;enter with ds:si -> data to dump in hex & ASCII, cx = length.
  5.     xor    bx,bx
  6. dump_hex_0:
  7.     push    cx
  8.     cmp    cx,16
  9.     jb    dump_hex_1
  10.     mov    cx,16
  11. dump_hex_1:
  12.     call    dump_line
  13.     pop    cx
  14.     add    bx,16
  15.     sub    cx,16
  16.     ja    dump_hex_0
  17.     ret
  18.  
  19.  
  20. dump_line:
  21. ;enter with ds:si -> data to dump in hex & ASCII, cx = length (<16),
  22. ;  bx = offset.
  23. ;exit with si advanced by cx.
  24.     push    cx
  25.     mov    ax,bx
  26.     call    wordout
  27.     pop    cx
  28.     mov    al,' '
  29.     call    chrout
  30.     call    chrout
  31.     push    cx
  32. dump_line_1:
  33.     lodsb
  34.     push    cx
  35.     call    byteout
  36.     pop    cx
  37.  
  38.     mov    al,' '            ;put a dash in the middle.
  39.     cmp    cx,9
  40.     jne    dump_line_7
  41.     mov    al,'-'
  42. dump_line_7:
  43.     call    chrout
  44.  
  45.     loop    dump_line_1
  46.     pop    ax
  47.  
  48.     push    ax
  49.     mov    cx,16
  50.     sub    cx,ax
  51.     mov    al,' '
  52.     jcxz    dump_line_3
  53. dump_line_2:
  54.     call    chrout
  55.     call    chrout
  56.     call    chrout
  57.     loop    dump_line_2
  58. dump_line_3:
  59.     call    chrout
  60.     pop    cx
  61.     sub    si,cx
  62. dump_line_4:
  63.     lodsb
  64.     cmp    al,' '
  65.     jb    dump_line_5
  66.     cmp    al,7fh
  67.     jb    dump_line_6
  68. dump_line_5:
  69.     mov    al,'.'
  70. dump_line_6:
  71.     call    chrout
  72.     loop    dump_line_4
  73.     call    crlf
  74.     ret
  75.  
  76.