Article View: comp.os.msdos.programmer
Article #1021Re: Efficient byte/word mirroring request
From: Stig Venaas
Date: Fri, 28 Aug 1992 07:28
Date: Fri, 28 Aug 1992 07:28
40 lines
1517 bytes
1517 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. > >Themie Gouthas >egg@dstos3.dsto.gov.au The fastest way of doing this is to use look up tables. You could make a look up table for the nibbles. 0000 to 1111. That's just 16 bytes. You could squeeze it into 8 bytes, but the code would be longer and it would take more time. Then to mirror a byte, you just look up the two nibbles, and swap them. This procedure can be used for words etc. of course. I don't think this algorithm including the table would take much more space than yours. If time is more important than size, use a look up table for the bytes. -- Stig (venaas@siri.unit.no)
Technical Details
Message-ID:
<1992Aug28.072811.27715@ugle.unit.no>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ugle.unit.no!venaasReferences:
<1992Aug28.083405.164422@dstos3.dsto.gov.au>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ugle.unit.no!venaas From: venaas@siri.unit.no (Stig Venaas) Subject: Re: Efficient byte/word mirroring request Message-ID: <1992Aug28.072811.27715@ugle.unit.no> Sender: news@ugle.unit.no (NetNews Administrator) Organization: University of Trondheim References: <1992Aug28.083405.164422@dstos3.dsto.gov.au> Date: Fri, 28 Aug 92 07:28:11 GMT Lines: 40