🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #1172

Re: Efficient byte/word mirroring request

#1172
From: dueck
Date: Mon, 31 Aug 1992 22:03
36 lines
1229 bytes
In article <1992Aug28.083405.164422@dstos3.dsto.gov.au>, egg@dstos3.dsto.gov.au writes:
> Does anyone know how to quickly and efficiently mirror a byte.
> ie
>     11001010 to 01010011
> 
> the only way I know is this
> 
>    mov  al,byte_to_shift
>    mov  cx,8
> ShiftLoop:
>    rcr  al
>    rcl  ah
>    loop ShiftLoop
>    mov  shifted_byte,ah
> 
> There must be an easier (and smarter) way to speed this up using logical
> op's perhaps ?
> Any Help appreciated.
> 
If its speed you are after, generate a table with 256 one-byte entries
and use table lookup.

table:
   dw 0, 1, 2		; first three entries
   ...
   dw 40h, 80h, 0ffh    ; last three entries


To do the lookup:

   mov bl, byte_to_shift
   xor	bh,hx
   mov	al, table[bx]

Gery Dueck
dueck@brandonu.ca
Technical Details
Message-ID: <1992Aug31.160328.2192@brandonu.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!access.usask.ca!ccu.umanitoba.ca!ciit85.ciit.nrc.ca!brandonu.ca!dueck
References: <1992Aug28.083405.164422@dstos3.dsto.gov.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!access.usask.ca!ccu.umanitoba.ca!ciit85.ciit.nrc.ca!brandonu.ca!dueck
Newsgroups: comp.os.msdos.programmer
Subject: Re: Efficient byte/word mirroring request
Message-ID: <1992Aug31.160328.2192@brandonu.ca>
From: dueck@brandonu.ca
Date: 31 Aug 92 16:03:28 CST
References: <1992Aug28.083405.164422@dstos3.dsto.gov.au>
Organization: Brandon University, Brandon, Manitoba, Canada
Lines: 36