home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 8929 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  1.2 KB

  1. Path: sparky!uunet!decwrl!access.usask.ca!ccu.umanitoba.ca!ciit85.ciit.nrc.ca!brandonu.ca!dueck
  2. Newsgroups: comp.os.msdos.programmer
  3. Subject: Re: Efficient byte/word mirroring request
  4. Message-ID: <1992Aug31.160328.2192@brandonu.ca>
  5. From: dueck@brandonu.ca
  6. Date: 31 Aug 92 16:03:28 CST
  7. References: <1992Aug28.083405.164422@dstos3.dsto.gov.au>
  8. Organization: Brandon University, Brandon, Manitoba, Canada
  9. Lines: 36
  10.  
  11. In article <1992Aug28.083405.164422@dstos3.dsto.gov.au>, egg@dstos3.dsto.gov.au writes:
  12. > Does anyone know how to quickly and efficiently mirror a byte.
  13. > ie
  14. >     11001010 to 01010011
  15. > the only way I know is this
  16. >    mov  al,byte_to_shift
  17. >    mov  cx,8
  18. > ShiftLoop:
  19. >    rcr  al
  20. >    rcl  ah
  21. >    loop ShiftLoop
  22. >    mov  shifted_byte,ah
  23. > There must be an easier (and smarter) way to speed this up using logical
  24. > op's perhaps ?
  25. > Any Help appreciated.
  26. If its speed you are after, generate a table with 256 one-byte entries
  27. and use table lookup.
  28.  
  29. table:
  30.    dw 0, 1, 2        ; first three entries
  31.    ...
  32.    dw 40h, 80h, 0ffh    ; last three entries
  33.  
  34.  
  35. To do the lookup:
  36.  
  37.    mov bl, byte_to_shift
  38.    xor    bh,hx
  39.    mov    al, table[bx]
  40.  
  41. Gery Dueck
  42. dueck@brandonu.ca
  43.