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

  1. hexout_ptr    dw    0
  2. hexout_color    db    70h
  3.  
  4. hexout_set:
  5.     mov    cs:hexout_color,ah
  6.     call    hexout_more
  7.     mov    cs:hexout_color,70h
  8.     ret
  9.  
  10. hexout_more:
  11.     push    di
  12.     mov    di,cs:hexout_ptr
  13.     call    hexout
  14.     add    di,4
  15.     cmp    di,25*80*2
  16.     jb    hexout_more_1
  17.     xor    di,di
  18. hexout_more_1:
  19.     mov    cs:hexout_ptr,di
  20.     pop    di
  21.     ret
  22.  
  23. hexout:
  24. ;enter with al = number, di->place on screen to store chars.
  25.     push    ax
  26.     push    es
  27.  
  28.     push    di
  29.     mov    di,0b800h
  30.     mov    es,di
  31.     pop    di
  32.  
  33.     push    ax
  34.     shr    al,1
  35.     shr    al,1
  36.     shr    al,1
  37.     shr    al,1
  38.     call    nibble2hex
  39.     mov    byte ptr es:[di+0],al
  40.     mov    al,cs:hexout_color
  41.     mov    byte ptr es:[di+1],al
  42.     pop    ax
  43.     call    nibble2hex
  44.     mov    byte ptr es:[di+2],al
  45.     mov    al,cs:hexout_color
  46.     mov    byte ptr es:[di+3],al
  47.  
  48.     mov    byte ptr es:[di+4],' '    ;output a space as a cursor.
  49.     mov    al,cs:hexout_color
  50.     mov    byte ptr es:[di+5],al
  51.  
  52.     pop    es
  53.     pop    ax
  54.     ret
  55.  
  56.  
  57. nibble2hex:
  58.     and    al,0fh
  59.     add    al,90h            ;binary digit to ascii hex digit.
  60.     daa
  61.     adc    al,40h
  62.     daa
  63.     ret
  64.  
  65.  
  66. hexout_char:
  67. ;enter with al = character
  68.     push    ax
  69.     push    es
  70.     push    di
  71.  
  72.     mov    di,0b800h
  73.     mov    es,di
  74.  
  75.     mov    di,cs:hexout_ptr
  76.     mov    ah,cs:hexout_color
  77.     stosw
  78.     cmp    di,25*80*2
  79.     jb    hexout_char_1
  80.     xor    di,di
  81. hexout_char_1:
  82.     mov    cs:hexout_ptr,di
  83.  
  84.     pop    di
  85.     pop    es
  86.     pop    ax
  87.     ret
  88.  
  89.  
  90. hexout_word:
  91.     push    ax
  92.     push    ax
  93.     mov    al,ah
  94.     mov    ah,07h
  95.     call    hexout_set
  96.     pop    ax
  97.     mov    ah,07h
  98.     call    hexout_set
  99.     pop    ax
  100.     ret
  101.