home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / zenasmlg / zen_list.exe / LST9-23.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  573b  |  27 lines

  1. ;
  2. ; *** Listing 9-23 ***
  3. ;
  4. ; Performs bit-doubling of a byte in AL to a word in AX
  5. ; by using SAR. This is not as fast as bit-doubling with
  6. ; a look-up table, but it is faster than any other
  7. ; shift-based approach.
  8. ; (Conceived by Dan Illowsky.)
  9. ;
  10. DOUBLE_BYTE    macro
  11.     mov    bl,al
  12.     rept    8
  13.     shr    bl,1    ;get the next bit to double
  14.     rcr    ax,1    ;move it into the msb...
  15.     sar    ax,1    ;...and replicate it
  16.     endm
  17.     endm
  18. ;
  19.     call    ZTimerOn
  20. BYTE_TO_DOUBLE=0
  21.     rept    100
  22.     mov    al,BYTE_TO_DOUBLE
  23.     DOUBLE_BYTE
  24. BYTE_TO_DOUBLE=(BYTE_TO_DOUBLE+1) and 0ffH
  25.     endm
  26.     call    ZTimerOff
  27.