"Mirror image" a byte
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
> 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;
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
See also: www.piclist.com/techref/index.htm?key=mirror+image+byte
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the