piclist 2002\10\10\140429a >
Thread: "Mirror image" a byte
www.piclist.com/techref/index.htm?key=mirror+image+byte
flavicon
face BY : Wagner Lipnharski email (remove spam text)



Sam S Man wrote:
> Hi all
> Can anyone help improve the code below. I need a "mirror image" of a
> byte. For example b7,b6,b5,b4,b3,b2,b1,b0 will become
> b0,b1,b2,b3,b4,b5,b6,b7.... in the shortest time possible!! AND if
> possible no B and C....result in w.
>
>
> A= the file, B = the "mirror image", C=8
>
>     clrf    B
> X
>     rlf    A,f
>     rrf    b,f
>     decfsz    C,f
>     goto    X
>     goto    done

Ah, forgot to say, do you have by any chance two 8 bits port available?
Just hardwire them bit mirrored, output in A - mirrored input in B.

You can do it using one single 8 bits port, just hardwire lower 4 bits
mirrored to the higher 4 bits.  When higher 4 bits as output, you have it
mirrored at the lower 4 bits as input, then lower 4 bits as output, will
mirror at the 4 high input bits. And/Or the input, voilá.

Also, by software doesn't mean you need to rotate it.
There are certain combinations of bits that will not mirror at all.
00, FF, 18, 24, 3C, 42, 66, 7E, 81, A5, C3, E7...  it would be possible to
detect and convert faster than 8 rotates?

In theory, the following logic uses only 7 operations, faster than rotate;

ABCD  EFGH
   \/
   /\       swap
EFGH  ABCD
\/
/\          swap
GHEF  ABCD
      \/
      /\    swap
GHEF  CDAB
X            swap
HGEF
 X          swap
HGFE  CDAB
     X      swap
     DCAB
       X    swap
HGFE  DCBA


VV46NER

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


<013e01c27087$3e44fe40$9acc1b18@cfl.rr.com> quoted-printable

See also: www.piclist.com/techref/index.htm?key=mirror+image+byte
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) "Mirror image" a byte

month overview.

new search...